Re: [PATCH v3 2/2] power: supply: ucs1002: Add HWMON interface

From: Andrew F. Davis
Date: Wed Jun 05 2019 - 12:30:45 EST


On 6/5/19 3:23 AM, Andrey Smirnov wrote:
Expose current sensors found on UCS1002 via HWMON.

Signed-off-by: Andrey Smirnov <andrew.smirnov@xxxxxxxxx>
Reviewed-by: Guenter Roeck <linux@xxxxxxxxxxxx>
Cc: Chris Healy <cphealy@xxxxxxxxx>
Cc: Cory Tusar <cory.tusar@xxxxxxxx>
Cc: Lucas Stach <l.stach@xxxxxxxxxxxxxx>
Cc: Fabio Estevam <fabio.estevam@xxxxxxx>
Cc: Guenter Roeck <linux@xxxxxxxxxxxx>
Cc: Sebastian Reichel <sre@xxxxxxxxxx>
Cc: linux-kernel@xxxxxxxxxxxxxxx
Cc: linux-pm@xxxxxxxxxxxxxxx
---
drivers/power/supply/ucs1002_power.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/drivers/power/supply/ucs1002_power.c b/drivers/power/supply/ucs1002_power.c
index 677f20a4d76f..a4b6b37549cf 100644
--- a/drivers/power/supply/ucs1002_power.c
+++ b/drivers/power/supply/ucs1002_power.c
@@ -571,6 +571,12 @@ static int ucs1002_probe(struct i2c_client *client,
return ret;
}
+ ret = devm_power_supply_add_hwmon_sysfs(info->charger);

Could this be added to the core power supply framework on registering so all devices get this, vs each driver having to add this line?

Andrew

+ if (ret) {
+ dev_err(dev, "Failed to add hmwon attributes: %d\n", ret);
+ return ret;
+ }
+
ret = regmap_read(info->regmap, UCS1002_REG_PIN_STATUS, &regval);
if (ret) {
dev_err(dev, "Failed to read pin status: %d\n", ret);