hwmon: fix potential sensor registration fail if of_node is missing
authorPhinex Hung <phinex@realtek.com>
Tue, 21 Mar 2023 06:02:23 +0000 (14:02 +0800)
committerGuenter Roeck <linux@roeck-us.net>
Tue, 21 Mar 2023 14:45:33 +0000 (07:45 -0700)
commit2315332efcbe7124252f080e03b57d3d2f1f4771
tree899f36013cf9f26e6e77c6da089ccaec65b05da3
parent2b91c4a870c9830eaf95e744454c9c218cccb736
hwmon: fix potential sensor registration fail if of_node is missing

It is not sufficient to check of_node in current device.
In some cases, this would cause the sensor registration to fail.

This patch looks for device's ancestors to find a valid of_node if any.

Fixes: d560168b5d0f ("hwmon: (core) New hwmon registration API")
Signed-off-by: Phinex Hung <phinex@realtek.com>
Link: https://lore.kernel.org/r/20230321060224.3819-1-phinex@realtek.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/hwmon.c