mfd: cros_ec_dev: Only register PCHG device if present
Subsystems (2)
PATCH v2 1/1 mfd: cros_ec_dev: Only register PCHG device if present
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.
---
Changes from v1 (https://lore.kernel.org/r/[email protected]):
* 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(+)
drivers/mfd/cros_ec_dev.c +19 -0
@@ -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
Signature · 1 line
https://chromeos.dev
Hey Stephen,
Quoted 5 lines · Stephen Boyd
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.
Quoted 7 lines
Cc Prashant Malani <[email protected]>Cc Tzung-Bi Shih <[email protected]>Cc Daisuke Nojiri <[email protected]>Cc Benson Leung <[email protected]>Cc Guenter Roeck <[email protected]>Cc <[email protected]>Signed-off-by Stephen Boyd <[email protected]>
FWIW:
Quoted 38 lines
---
Changes from v1 (https://lore.kernel.org/r/[email protected]):
* Usecros_ec_command()
* Drop the other patches that aren't needed anymoredrivers/mfd/cros_ec_dev.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)drivers/mfd/cros_ec_dev.c +7
-0@@ -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.
drivers/mfd/cros_ec_dev.c static int ec_device_probe(struct platform_device *pdev) · line 261
Quoted 10 lines
drivers/mfd/cros_ec_dev.c +10
-0+*/ + 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
Quoting Prashant Malani (2022-04-18 17:22:19)
Quoted 9 lines · Stephen Boyd
drivers/mfd/cros_ec_dev.c static int ec_device_probe(struct platform_device *pdev) · line 261
Quoted 6 lines
drivers/mfd/cros_ec_dev.c +6
-0+ 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.
Quoted 9 lines · Stephen Boyd
Quoting Prashant Malani (2022-04-18 17:22:19)
Quoted 7 lines · Stephen Boyd
Quoted 6 lines
drivers/mfd/cros_ec_dev.c +6
-0+ 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);
Quoted 5 lines
Quoted 2 lines
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.
The patch v2 looks good to me.
Quoted 18 lines · Prashant Malani
Quoted 9 lines · Stephen Boyd
Quoting Prashant Malani (2022-04-18 17:22:19)
Quoted 7 lines · Stephen Boyd
Quoted 6 lines
drivers/mfd/cros_ec_dev.c +6
-0+ 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);Quoted 5 lines
Quoted 2 lines
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.
Quoted 1 line · Daisuke Nojiri
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.
Quoted 19 lines · Prashant Malani
Quoted 18 lines · Stephen Boyd
Quoted 9 lines
Quoting Prashant Malani (2022-04-18 17:22:19)
Quoted 7 lines · Stephen Boyd
Quoted 6 lines
drivers/mfd/cros_ec_dev.c +6
-0+ 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);Quoted 5 lines
Quoted 2 lines
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.
Signature · 4 lines
Lee Jones [李琼斯] Principal Technical Lead - Developer Services Linaro.org │ Open source software for Arm SoCs Follow Linaro: Facebook | Twitter | Blog
Lee Jones
AppliedQuoted 12 lines · Stephen Boyd
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 <[email protected]>Cc Tzung-Bi Shih <[email protected]>Cc Daisuke Nojiri <[email protected]>Cc Benson Leung <[email protected]>Cc Guenter Roeck <[email protected]>Cc <[email protected]>Signed-off-by Stephen Boyd <[email protected]>
Quoted 8 lines
---
Changes from v1 (https://lore.kernel.org/r/[email protected]):
* Usecros_ec_command()
* Drop the other patches that aren't needed anymoredrivers/mfd/cros_ec_dev.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
Applied, thanks.
Signature · 4 lines
Lee Jones [李琼斯] Principal Technical Lead - Developer Services Linaro.org │ Open source software for Arm SoCs Follow Linaro: Facebook | Twitter | Blog