linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] Minor thermal_hwmon cleanups
@ 2018-07-10 15:40 Marc Zyngier
  2018-07-10 15:40 ` [PATCH 1/2] thermal_hwmon: Sanitize attribute name passed to hwmon Marc Zyngier
  2018-07-10 15:40 ` [PATCH 2/2] thermal_hwmon: Pass the originating device down to hwmon_device_register_with_info Marc Zyngier
  0 siblings, 2 replies; 5+ messages in thread
From: Marc Zyngier @ 2018-07-10 15:40 UTC (permalink / raw)
  To: Zhang Rui, Eduardo Valentin; +Cc: linux-pm, linux-kernel

These two patches address a couple of minor issues I noticed while
hacking on a Chromebook (Google kevin platform).

The first one converts the device name passed to hwmon to containing
'_' instead of '-' (which hwmon barfs at).

The second one passes the thermal zone device to the hwmon subsystem,
making sure that messages from hwmon are not completely misleading,
and placing the related hwmon device at the correct spot in the
hierarchy.

Thanks,

	M.

Marc Zyngier (2):
  thermal_hwmon: Sanitize attribute name passed to hwmon
  thermal_hwmon: Pass the originating device down to
    hwmon_device_register_with_info

 drivers/thermal/thermal_hwmon.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

-- 
2.18.0


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

* [PATCH 1/2] thermal_hwmon: Sanitize attribute name passed to hwmon
  2018-07-10 15:40 [PATCH 0/2] Minor thermal_hwmon cleanups Marc Zyngier
@ 2018-07-10 15:40 ` Marc Zyngier
  2018-07-18  9:42   ` Enric Balletbo Serra
  2018-07-10 15:40 ` [PATCH 2/2] thermal_hwmon: Pass the originating device down to hwmon_device_register_with_info Marc Zyngier
  1 sibling, 1 reply; 5+ messages in thread
From: Marc Zyngier @ 2018-07-10 15:40 UTC (permalink / raw)
  To: Zhang Rui, Eduardo Valentin; +Cc: linux-pm, linux-kernel

My Chromebook Plus (kevin) is spitting the following at boot time:

(NULL device *): hwmon: 'sbs-9-000b' is not a valid name attribute, please fix

Clearly, __hwmon_device_register is unhappy about the property name.
Some investigation reveals that thermal_add_hwmon_sysfs doesn't
sanitize the name of the attribute.

In order to keep it quiet, let's replace '-' with '_' in hwmon->type
This is consistent with what iio-hwmon does since b92fe9e3379c8.

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

diff --git a/drivers/thermal/thermal_hwmon.c b/drivers/thermal/thermal_hwmon.c
index 11278836ed12..0bd47007c57f 100644
--- a/drivers/thermal/thermal_hwmon.c
+++ b/drivers/thermal/thermal_hwmon.c
@@ -142,6 +142,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, NULL, NULL);
 	if (IS_ERR(hwmon->device)) {
-- 
2.18.0


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

* [PATCH 2/2] thermal_hwmon: Pass the originating device down to hwmon_device_register_with_info
  2018-07-10 15:40 [PATCH 0/2] Minor thermal_hwmon cleanups Marc Zyngier
  2018-07-10 15:40 ` [PATCH 1/2] thermal_hwmon: Sanitize attribute name passed to hwmon Marc Zyngier
@ 2018-07-10 15:40 ` Marc Zyngier
  2018-07-18  9:43   ` Enric Balletbo Serra
  1 sibling, 1 reply; 5+ messages in thread
From: Marc Zyngier @ 2018-07-10 15:40 UTC (permalink / raw)
  To: Zhang Rui, Eduardo Valentin; +Cc: linux-pm, linux-kernel

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


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

* Re: [PATCH 1/2] thermal_hwmon: Sanitize attribute name passed to hwmon
  2018-07-10 15:40 ` [PATCH 1/2] thermal_hwmon: Sanitize attribute name passed to hwmon Marc Zyngier
@ 2018-07-18  9:42   ` Enric Balletbo Serra
  0 siblings, 0 replies; 5+ messages in thread
From: Enric Balletbo Serra @ 2018-07-18  9:42 UTC (permalink / raw)
  To: marc.zyngier; +Cc: Zhang Rui, Eduardo Valentin, Linux PM list, linux-kernel

Hi Marc,
Missatge de Marc Zyngier <marc.zyngier@arm.com> del dia dt., 10 de
jul. 2018 a les 17:42:
>
> My Chromebook Plus (kevin) is spitting the following at boot time:
>
> (NULL device *): hwmon: 'sbs-9-000b' is not a valid name attribute, please fix
>
> Clearly, __hwmon_device_register is unhappy about the property name.
> Some investigation reveals that thermal_add_hwmon_sysfs doesn't
> sanitize the name of the attribute.
>
> In order to keep it quiet, let's replace '-' with '_' in hwmon->type
> This is consistent with what iio-hwmon does since b92fe9e3379c8.
>
> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
> ---
>  drivers/thermal/thermal_hwmon.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/drivers/thermal/thermal_hwmon.c b/drivers/thermal/thermal_hwmon.c
> index 11278836ed12..0bd47007c57f 100644
> --- a/drivers/thermal/thermal_hwmon.c
> +++ b/drivers/thermal/thermal_hwmon.c
> @@ -142,6 +142,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, NULL, NULL);
>         if (IS_ERR(hwmon->device)) {
> --
> 2.18.0
>

That's one of the annoying messages you saw for a long time during
boot but you had never time to look at. I am happy that when I found a
slot to look at I found already it was fixed.
Thanks!

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

Best regards,
 Enric

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

* Re: [PATCH 2/2] thermal_hwmon: Pass the originating device down to hwmon_device_register_with_info
  2018-07-10 15:40 ` [PATCH 2/2] thermal_hwmon: Pass the originating device down to hwmon_device_register_with_info Marc Zyngier
@ 2018-07-18  9:43   ` Enric Balletbo Serra
  0 siblings, 0 replies; 5+ messages in thread
From: Enric Balletbo Serra @ 2018-07-18  9:43 UTC (permalink / raw)
  To: marc.zyngier; +Cc: Zhang Rui, Eduardo Valentin, Linux PM list, linux-kernel

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

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

end of thread, other threads:[~2018-07-18  9:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-10 15:40 [PATCH 0/2] Minor thermal_hwmon cleanups Marc Zyngier
2018-07-10 15:40 ` [PATCH 1/2] thermal_hwmon: Sanitize attribute name passed to hwmon Marc Zyngier
2018-07-18  9:42   ` Enric Balletbo Serra
2018-07-10 15:40 ` [PATCH 2/2] thermal_hwmon: Pass the originating device down to hwmon_device_register_with_info Marc Zyngier
2018-07-18  9:43   ` Enric Balletbo Serra

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).