thermal: Fix thermal_zone_of_sensor_register to match documentation

thermal_zone_of_sensor_register is documented as returning a pointer
to either a valid thermal_zone_device on success, or a corresponding
ERR_PTR() value.

In contrast, the function returns NULL when THERMAL_OF is configured
off. Fix this.

Signed-off-by: Punit Agrawal <>
Acked-by: Guenter Roeck <>
Cc: Eduardo Valentin <>
Cc: Zhang Rui <>
Signed-off-by: Eduardo Valentin <>
diff --git a/include/linux/thermal.h b/include/linux/thermal.h
index 17292fe..0c5518e 100644
--- a/include/linux/thermal.h
+++ b/include/linux/thermal.h
@@ -360,7 +360,7 @@
 thermal_zone_of_sensor_register(struct device *dev, int id, void *data,
 				const struct thermal_zone_of_device_ops *ops)
-	return NULL;
+	return ERR_PTR(-ENODEV);
 static inline