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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 30 Mar 2023 10:49:13 +0000 (12:49 +0200)
commitf3263768965fb893534f0e04c91d33a49c77950f
treed012c522a922f2679f40d191b00df7fd9913ddcc
parentd716ea059cd3d6abfbedda164a67b3659e19d2de
hwmon: fix potential sensor registration fail if of_node is missing

[ Upstream commit 2315332efcbe7124252f080e03b57d3d2f1f4771 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/hwmon/hwmon.c