Skip to content

Commit 370f995

Browse files
pmamonovdlezcano
authored andcommitted
thermal: of: Make thermal_zone_of_sensor_register return -ENODEV if a sensor OF node is missing
When devm_thermal_zone_of_sensor_register() is called from hwmon_thermal_add_sensor() it is possible that the relevant sensor is missing an OF node. In this case thermal_zone_of_sensor_register() returns -EINVAL which causes hwmon_thermal_add_sensor() to fail as well. This patch changes relevant return code of thermal_zone_of_sensor_register() to -ENODEV, which is tolerated by hwmon_thermal_add_sensor(). Here is a particular case of such behaviour: the Marvell ethernet PHYs driver registers hwmon device for the built-in temperature sensor (see drivers/net/phy/marvell.c). Since the sensor doesn't have associated OF node devm_hwmon_device_register() returns error which ultimately causes failure of the PHY driver's probe function. Signed-off-by: Peter Mamonov <[email protected]> Signed-off-by: Daniel Lezcano <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 0f510a2 commit 370f995

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/thermal/of-thermal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ thermal_zone_of_sensor_register(struct device *dev, int sensor_id, void *data,
493493

494494
if (!dev || !dev->of_node) {
495495
of_node_put(np);
496-
return ERR_PTR(-EINVAL);
496+
return ERR_PTR(-ENODEV);
497497
}
498498

499499
sensor_np = of_node_get(dev->of_node);

0 commit comments

Comments
 (0)