Skip to contentSkip to conversation

hwmon: (scmi) return -EINVAL when sensor information is unavailable

PATCH In review Sudeep Holla 2 participants 2 messages Mar 15, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hwmon: (scmi) return -EINVAL when sensor information is unavailable

Passing NULL pointer to PTR_ERR will result in return value of 0 indicating success which is clearly not what it is intended here.

This patch returns -EINVAL instead when the sensor information is not available.

Fixes b23688aefb8b ("hwmon: add support for sensors exported via ARM SCMI")
Cc Guenter Roeck <[email protected]>
---
 drivers/hwmon/scmi-hwmon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Hi Guenter,

I will try to push this via ARM-SoC if possible before v4.17 merge window. So please provide Ack if you are fine.

Regards,
Sudeep

drivers/hwmon/scmi-hwmon.c +1 -1
index 32e750373ced..363bf56eb0f2 100644
@@ -138,7 +138,7 @@ static int scmi_hwmon_probe(struct scmi_device *sdev)
 	for (i = 0; i < nr_sensors; i++) {
 		sensor = handle->sensor_ops->info_get(handle, i);
 		if (!sensor)
-			return PTR_ERR(sensor);
+			return -EINVAL;
 
 		switch (sensor->type) {
 		case TEMPERATURE_C:
Signature · 1 line
2.7.4
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 11 lines · Sudeep Holla

Passing NULL pointer to PTR_ERR will result in return value of 0 indicating success which is clearly not what it is intended here.

This patch returns -EINVAL instead when the sensor information is not available.

Fixes b23688aefb8b ("hwmon: add support for sensors exported via ARM SCMI")
Cc Guenter Roeck <[email protected]>
Quoted 26 lines
---
  drivers/hwmon/scmi-hwmon.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

Hi Guenter,

I will try to push this via ARM-SoC if possible before v4.17 merge window. So please provide Ack if you are fine.

Regards,
Sudeep

drivers/hwmon/scmi-hwmon.c +1 -1
index 32e750373ced..363bf56eb0f2 100644
@@ -138,7 +138,7 @@ static int scmi_hwmon_probe(struct scmi_device *sdev)
  	for (i = 0; i < nr_sensors; i++) {
  		sensor = handle->sensor_ops->info_get(handle, i);
  		if (!sensor)
-			return PTR_ERR(sensor);
+			return -EINVAL;
 
  		switch (sensor->type) {
  		case TEMPERATURE_C: