Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

power: supply: core: Avoid duplicate hwmon device from thermal framework

When the power supply device being registered supports a temperature
readout, the core registers a thermal zone for it. The thermal core
would register a hwmon device for that unless told otherwise.

When CONFIG_POWER_SUPPLY_HWMON is enabled, the power supply core creates
a hwmon device. This results in a second entry, one which has a better
name than the one registered through the thermal framework. It could
potentially have readouts other than temperature.

To simplify the result, tell the thermal framework to not register a
hwmon device if CONFIG_POWER_SUPPLY_HWMON is enabled. The result is
one hwmon device with all the readings the device supports.

Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>

authored by

Chen-Yu Tsai and committed by
Sebastian Reichel
b52d51d8 1a805883

+5 -1
+5 -1
drivers/power/supply/power_supply_core.c
··· 1305 1305 1306 1306 /* Register battery zone device psy reports temperature */ 1307 1307 if (psy_has_property(psy->desc, POWER_SUPPLY_PROP_TEMP)) { 1308 + /* Prefer our hwmon device and avoid duplicates */ 1309 + struct thermal_zone_params tzp = { 1310 + .no_hwmon = IS_ENABLED(CONFIG_POWER_SUPPLY_HWMON) 1311 + }; 1308 1312 psy->tzd = thermal_zone_device_register(psy->desc->name, 1309 - 0, 0, psy, &psy_tzd_ops, NULL, 0, 0); 1313 + 0, 0, psy, &psy_tzd_ops, &tzp, 0, 0); 1310 1314 if (IS_ERR(psy->tzd)) 1311 1315 return PTR_ERR(psy->tzd); 1312 1316 ret = thermal_zone_device_enable(psy->tzd);