diff mbox

[2/2] thermal_hwmon: Pass the originating device down to hwmon_device_register_with_info

Message ID 20180710154035.26828-3-marc.zyngier@arm.com (mailing list archive)
State Accepted
Delegated to: Eduardo Valentin
Headers show

Commit Message

Marc Zyngier July 10, 2018, 3:40 p.m. UTC
When registering the hwmon device, we pass NULL as the device.
While this doesn't result in any immediate breakage, it leaves
the hwmon device at the root of the virtual devices, rather than
attached to the thermal zone hierarchy.

Instead, let's pass the actual device, which is part of the
thermal_zone_device structure. This also avoids the rather
unpleasant ""NULL device *" which can be generated by dev_{err,info}
in the hwmon subsystem.

Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
---
 drivers/thermal/thermal_hwmon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Enric Balletbo Serra July 18, 2018, 9:43 a.m. UTC | #1
Missatge de Marc Zyngier <marc.zyngier@arm.com> del dia dt., 10 de
jul. 2018 a les 17:41:
>
> When registering the hwmon device, we pass NULL as the device.
> While this doesn't result in any immediate breakage, it leaves
> the hwmon device at the root of the virtual devices, rather than
> attached to the thermal zone hierarchy.
>
> Instead, let's pass the actual device, which is part of the
> thermal_zone_device structure. This also avoids the rather
> unpleasant ""NULL device *" which can be generated by dev_{err,info}
> in the hwmon subsystem.
>
> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
> ---
>  drivers/thermal/thermal_hwmon.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/thermal/thermal_hwmon.c b/drivers/thermal/thermal_hwmon.c
> index 0bd47007c57f..40c69a533b24 100644
> --- a/drivers/thermal/thermal_hwmon.c
> +++ b/drivers/thermal/thermal_hwmon.c
> @@ -143,7 +143,7 @@ int thermal_add_hwmon_sysfs(struct thermal_zone_device *tz)
>         INIT_LIST_HEAD(&hwmon->tz_list);
>         strlcpy(hwmon->type, tz->type, THERMAL_NAME_LENGTH);
>         strreplace(hwmon->type, '-', '_');
> -       hwmon->device = hwmon_device_register_with_info(NULL, hwmon->type,
> +       hwmon->device = hwmon_device_register_with_info(&tz->device, hwmon->type,
>                                                         hwmon, NULL, NULL);
>         if (IS_ERR(hwmon->device)) {
>                 result = PTR_ERR(hwmon->device);
> --
> 2.18.0
>

Tested-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>

Best regards,
 Enric
diff mbox

Patch

diff --git a/drivers/thermal/thermal_hwmon.c b/drivers/thermal/thermal_hwmon.c
index 0bd47007c57f..40c69a533b24 100644
--- a/drivers/thermal/thermal_hwmon.c
+++ b/drivers/thermal/thermal_hwmon.c
@@ -143,7 +143,7 @@  int thermal_add_hwmon_sysfs(struct thermal_zone_device *tz)
 	INIT_LIST_HEAD(&hwmon->tz_list);
 	strlcpy(hwmon->type, tz->type, THERMAL_NAME_LENGTH);
 	strreplace(hwmon->type, '-', '_');
-	hwmon->device = hwmon_device_register_with_info(NULL, hwmon->type,
+	hwmon->device = hwmon_device_register_with_info(&tz->device, hwmon->type,
 							hwmon, NULL, NULL);
 	if (IS_ERR(hwmon->device)) {
 		result = PTR_ERR(hwmon->device);