chrome-platform.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] mfd: cros_ec_dev: Only register PCHG device if present
@ 2022-04-19  0:04 Stephen Boyd
  2022-04-19  0:22 ` Prashant Malani
  2022-04-26 14:19 ` Lee Jones
  0 siblings, 2 replies; 7+ messages in thread
From: Stephen Boyd @ 2022-04-19  0:04 UTC (permalink / raw)
  To: Lee Jones
  Cc: linux-kernel, patches, Prashant Malani, Tzung-Bi Shih,
	Daisuke Nojiri, Benson Leung, Guenter Roeck, chrome-platform

Don't create a device for the peripheral charger (PCHG) if there aren't
any peripheral charger ports. This removes a device on most ChromeOS
systems, because the peripheral charger functionality isn't always
present.

Cc: Prashant Malani <pmalani@chromium.org>
Cc: Tzung-Bi Shih <tzungbi@kernel.org>
Cc: Daisuke Nojiri <dnojiri@chromium.org>
Cc: Benson Leung <bleung@chromium.org>
Cc: Guenter Roeck <groeck@chromium.org>
Cc: <chrome-platform@lists.linux.dev>
Signed-off-by: Stephen Boyd <swboyd@chromium.org>
---

Changes from v1 (https://lore.kernel.org/r/20220415003253.1973106-1-swboyd@chromium.org):
 * Use cros_ec_command()
 * Drop the other patches that aren't needed anymore

 drivers/mfd/cros_ec_dev.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/drivers/mfd/cros_ec_dev.c b/drivers/mfd/cros_ec_dev.c
index 546feef851ab..596731caf407 100644
--- a/drivers/mfd/cros_ec_dev.c
+++ b/drivers/mfd/cros_ec_dev.c
@@ -114,6 +114,9 @@ static const struct mfd_cell cros_ec_platform_cells[] = {
 	{ .name = "cros-ec-chardev", },
 	{ .name = "cros-ec-debugfs", },
 	{ .name = "cros-ec-sysfs", },
+};
+
+static const struct mfd_cell cros_ec_pchg_cells[] = {
 	{ .name = "cros-ec-pchg", },
 };
 
@@ -137,6 +140,7 @@ static int ec_device_probe(struct platform_device *pdev)
 	struct device *dev = &pdev->dev;
 	struct cros_ec_platform *ec_platform = dev_get_platdata(dev);
 	struct cros_ec_dev *ec = kzalloc(sizeof(*ec), GFP_KERNEL);
+	struct ec_response_pchg_count pchg_count;
 	int i;
 
 	if (!ec)
@@ -242,6 +246,21 @@ static int ec_device_probe(struct platform_device *pdev)
 		}
 	}
 
+	/*
+	 * The PCHG device cannot be detected by sending EC_FEATURE_GET_CMD, but
+	 * it can be detected by querying the number of peripheral chargers.
+	 */
+	retval = cros_ec_command(ec->ec_dev, 0, EC_CMD_PCHG_COUNT, NULL, 0,
+				 &pchg_count, sizeof(pchg_count));
+	if (retval >= 0 && pchg_count.port_count) {
+		retval = mfd_add_hotplug_devices(ec->dev,
+					cros_ec_pchg_cells,
+					ARRAY_SIZE(cros_ec_pchg_cells));
+		if (retval)
+			dev_warn(ec->dev, "failed to add pchg: %d\n",
+				 retval);
+	}
+
 	/*
 	 * The following subdevices cannot be detected by sending the
 	 * EC_FEATURE_GET_CMD to the Embedded Controller device.

base-commit: 3123109284176b1532874591f7c81f3837bbdc17
-- 
https://chromeos.dev


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] mfd: cros_ec_dev: Only register PCHG device if present
  2022-04-19  0:04 [PATCH v2] mfd: cros_ec_dev: Only register PCHG device if present Stephen Boyd
@ 2022-04-19  0:22 ` Prashant Malani
  2022-04-19 14:55   ` Stephen Boyd
  2022-04-26 14:19 ` Lee Jones
  1 sibling, 1 reply; 7+ messages in thread
From: Prashant Malani @ 2022-04-19  0:22 UTC (permalink / raw)
  To: Stephen Boyd
  Cc: Lee Jones, linux-kernel, patches, Tzung-Bi Shih, Daisuke Nojiri,
	Benson Leung, Guenter Roeck, chrome-platform

Hey Stephen,

On Apr 18 17:04, Stephen Boyd wrote:
> Don't create a device for the peripheral charger (PCHG) if there aren't
> any peripheral charger ports. This removes a device on most ChromeOS
> systems, because the peripheral charger functionality isn't always
> present.
> 
> Cc: Prashant Malani <pmalani@chromium.org>
> Cc: Tzung-Bi Shih <tzungbi@kernel.org>
> Cc: Daisuke Nojiri <dnojiri@chromium.org>
> Cc: Benson Leung <bleung@chromium.org>
> Cc: Guenter Roeck <groeck@chromium.org>
> Cc: <chrome-platform@lists.linux.dev>
> Signed-off-by: Stephen Boyd <swboyd@chromium.org>
FWIW:
Reviewed-by: Prashant Malani <pmalani@chromium.org>

> ---
> 
> Changes from v1 (https://lore.kernel.org/r/20220415003253.1973106-1-swboyd@chromium.org):
>  * Use cros_ec_command()
>  * Drop the other patches that aren't needed anymore
> 
>  drivers/mfd/cros_ec_dev.c | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
> 
> diff --git a/drivers/mfd/cros_ec_dev.c b/drivers/mfd/cros_ec_dev.c
> index 546feef851ab..596731caf407 100644
> --- a/drivers/mfd/cros_ec_dev.c
> +++ b/drivers/mfd/cros_ec_dev.c
> @@ -114,6 +114,9 @@ static const struct mfd_cell cros_ec_platform_cells[] = {
>  	{ .name = "cros-ec-chardev", },
>  	{ .name = "cros-ec-debugfs", },
>  	{ .name = "cros-ec-sysfs", },
> +};
> +
> +static const struct mfd_cell cros_ec_pchg_cells[] = {
>  	{ .name = "cros-ec-pchg", },
>  };
>  
> @@ -137,6 +140,7 @@ static int ec_device_probe(struct platform_device *pdev)
>  	struct device *dev = &pdev->dev;
>  	struct cros_ec_platform *ec_platform = dev_get_platdata(dev);
>  	struct cros_ec_dev *ec = kzalloc(sizeof(*ec), GFP_KERNEL);
> +	struct ec_response_pchg_count pchg_count;
>  	int i;
>  
>  	if (!ec)
> @@ -242,6 +246,21 @@ static int ec_device_probe(struct platform_device *pdev)
>  		}
>  	}
>  
> +	/*
> +	 * The PCHG device cannot be detected by sending EC_FEATURE_GET_CMD, but
> +	 * it can be detected by querying the number of peripheral chargers.
> +	 */
> +	retval = cros_ec_command(ec->ec_dev, 0, EC_CMD_PCHG_COUNT, NULL, 0,
> +				 &pchg_count, sizeof(pchg_count));
> +	if (retval >= 0 && pchg_count.port_count) {
> +		retval = mfd_add_hotplug_devices(ec->dev,
> +					cros_ec_pchg_cells,
> +					ARRAY_SIZE(cros_ec_pchg_cells));
> +		if (retval)
> +			dev_warn(ec->dev, "failed to add pchg: %d\n",
> +				 retval);
Tiny nit: Can this fit in 1 line (100 chars[1])?


BR,

-Prashant

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=bdc48fa11e46f867ea4d75fa59ee87a7f48be144

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] mfd: cros_ec_dev: Only register PCHG device if present
  2022-04-19  0:22 ` Prashant Malani
@ 2022-04-19 14:55   ` Stephen Boyd
  2022-04-19 14:58     ` Prashant Malani
  0 siblings, 1 reply; 7+ messages in thread
From: Stephen Boyd @ 2022-04-19 14:55 UTC (permalink / raw)
  To: Prashant Malani
  Cc: Lee Jones, linux-kernel, patches, Tzung-Bi Shih, Daisuke Nojiri,
	Benson Leung, Guenter Roeck, chrome-platform

Quoting Prashant Malani (2022-04-18 17:22:19)
> On Apr 18 17:04, Stephen Boyd wrote:
> > +             retval = mfd_add_hotplug_devices(ec->dev,
> > +                                     cros_ec_pchg_cells,
> > +                                     ARRAY_SIZE(cros_ec_pchg_cells));
> > +             if (retval)
> > +                     dev_warn(ec->dev, "failed to add pchg: %d\n",
> > +                              retval);
> Tiny nit: Can this fit in 1 line (100 chars[1])?
>

I'm matching the style of other lines in this file (this is copy
pasta). I'll let the maintainer decide what to do.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] mfd: cros_ec_dev: Only register PCHG device if present
  2022-04-19 14:55   ` Stephen Boyd
@ 2022-04-19 14:58     ` Prashant Malani
  2022-04-19 18:26       ` Daisuke Nojiri
  0 siblings, 1 reply; 7+ messages in thread
From: Prashant Malani @ 2022-04-19 14:58 UTC (permalink / raw)
  To: Stephen Boyd
  Cc: Lee Jones, linux-kernel, patches, Tzung-Bi Shih, Daisuke Nojiri,
	Benson Leung, Guenter Roeck, chrome-platform

On Tue, Apr 19, 2022 at 7:55 AM Stephen Boyd <swboyd@chromium.org> wrote:
>
> Quoting Prashant Malani (2022-04-18 17:22:19)
> > On Apr 18 17:04, Stephen Boyd wrote:
> > > +             retval = mfd_add_hotplug_devices(ec->dev,
> > > +                                     cros_ec_pchg_cells,
> > > +                                     ARRAY_SIZE(cros_ec_pchg_cells));
> > > +             if (retval)
> > > +                     dev_warn(ec->dev, "failed to add pchg: %d\n",
> > > +                              retval);
> > Tiny nit: Can this fit in 1 line (100 chars[1])?
> >
>
> I'm matching the style of other lines in this file (this is copy
> pasta). I'll let the maintainer decide what to do.

Quite a bit of that code predates the char limit update, but OK.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] mfd: cros_ec_dev: Only register PCHG device if present
  2022-04-19 14:58     ` Prashant Malani
@ 2022-04-19 18:26       ` Daisuke Nojiri
  2022-04-26 14:18         ` Lee Jones
  0 siblings, 1 reply; 7+ messages in thread
From: Daisuke Nojiri @ 2022-04-19 18:26 UTC (permalink / raw)
  To: Prashant Malani
  Cc: Stephen Boyd, Lee Jones, linux-kernel, patches, Tzung-Bi Shih,
	Daisuke Nojiri, Benson Leung, Guenter Roeck, chrome-platform

The patch v2 looks good to me.


On Tue, Apr 19, 2022 at 7:59 AM Prashant Malani <pmalani@chromium.org> wrote:
>
> On Tue, Apr 19, 2022 at 7:55 AM Stephen Boyd <swboyd@chromium.org> wrote:
> >
> > Quoting Prashant Malani (2022-04-18 17:22:19)
> > > On Apr 18 17:04, Stephen Boyd wrote:
> > > > +             retval = mfd_add_hotplug_devices(ec->dev,
> > > > +                                     cros_ec_pchg_cells,
> > > > +                                     ARRAY_SIZE(cros_ec_pchg_cells));
> > > > +             if (retval)
> > > > +                     dev_warn(ec->dev, "failed to add pchg: %d\n",
> > > > +                              retval);
> > > Tiny nit: Can this fit in 1 line (100 chars[1])?
> > >
> >
> > I'm matching the style of other lines in this file (this is copy
> > pasta). I'll let the maintainer decide what to do.
>
> Quite a bit of that code predates the char limit update, but OK.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] mfd: cros_ec_dev: Only register PCHG device if present
  2022-04-19 18:26       ` Daisuke Nojiri
@ 2022-04-26 14:18         ` Lee Jones
  0 siblings, 0 replies; 7+ messages in thread
From: Lee Jones @ 2022-04-26 14:18 UTC (permalink / raw)
  To: Daisuke Nojiri
  Cc: Prashant Malani, Stephen Boyd, linux-kernel, patches,
	Tzung-Bi Shih, Daisuke Nojiri, Benson Leung, Guenter Roeck,
	chrome-platform

On Tue, 19 Apr 2022, Daisuke Nojiri wrote:

> The patch v2 looks good to me.

Please place your reply in-line. Top posting is generally frowned upon.

Also, please reply with a *-by (Reviewed-by in this case).

LGTMs do not carry any weight and will not be applied with the patch.

Thanks.

> On Tue, Apr 19, 2022 at 7:59 AM Prashant Malani <pmalani@chromium.org> wrote:
> >
> > On Tue, Apr 19, 2022 at 7:55 AM Stephen Boyd <swboyd@chromium.org> wrote:
> > >
> > > Quoting Prashant Malani (2022-04-18 17:22:19)
> > > > On Apr 18 17:04, Stephen Boyd wrote:
> > > > > +             retval = mfd_add_hotplug_devices(ec->dev,
> > > > > +                                     cros_ec_pchg_cells,
> > > > > +                                     ARRAY_SIZE(cros_ec_pchg_cells));
> > > > > +             if (retval)
> > > > > +                     dev_warn(ec->dev, "failed to add pchg: %d\n",
> > > > > +                              retval);
> > > > Tiny nit: Can this fit in 1 line (100 chars[1])?
> > > >
> > >
> > > I'm matching the style of other lines in this file (this is copy
> > > pasta). I'll let the maintainer decide what to do.
> >
> > Quite a bit of that code predates the char limit update, but OK.

-- 
Lee Jones [李琼斯]
Principal Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] mfd: cros_ec_dev: Only register PCHG device if present
  2022-04-19  0:04 [PATCH v2] mfd: cros_ec_dev: Only register PCHG device if present Stephen Boyd
  2022-04-19  0:22 ` Prashant Malani
@ 2022-04-26 14:19 ` Lee Jones
  1 sibling, 0 replies; 7+ messages in thread
From: Lee Jones @ 2022-04-26 14:19 UTC (permalink / raw)
  To: Stephen Boyd
  Cc: linux-kernel, patches, Prashant Malani, Tzung-Bi Shih,
	Daisuke Nojiri, Benson Leung, Guenter Roeck, chrome-platform

On Mon, 18 Apr 2022, Stephen Boyd wrote:

> Don't create a device for the peripheral charger (PCHG) if there aren't
> any peripheral charger ports. This removes a device on most ChromeOS
> systems, because the peripheral charger functionality isn't always
> present.
> 
> Cc: Prashant Malani <pmalani@chromium.org>
> Cc: Tzung-Bi Shih <tzungbi@kernel.org>
> Cc: Daisuke Nojiri <dnojiri@chromium.org>
> Cc: Benson Leung <bleung@chromium.org>
> Cc: Guenter Roeck <groeck@chromium.org>
> Cc: <chrome-platform@lists.linux.dev>
> Signed-off-by: Stephen Boyd <swboyd@chromium.org>
> ---
> 
> Changes from v1 (https://lore.kernel.org/r/20220415003253.1973106-1-swboyd@chromium.org):
>  * Use cros_ec_command()
>  * Drop the other patches that aren't needed anymore
> 
>  drivers/mfd/cros_ec_dev.c | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)

Applied, thanks.

-- 
Lee Jones [李琼斯]
Principal Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-04-26 14:19 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-19  0:04 [PATCH v2] mfd: cros_ec_dev: Only register PCHG device if present Stephen Boyd
2022-04-19  0:22 ` Prashant Malani
2022-04-19 14:55   ` Stephen Boyd
2022-04-19 14:58     ` Prashant Malani
2022-04-19 18:26       ` Daisuke Nojiri
2022-04-26 14:18         ` Lee Jones
2022-04-26 14:19 ` Lee Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).