Skip to contentSkip to conversation

hwmon: (emc2103) Return error from i2c_smbus_read_byte_data

PATCH In review Guenter Roeck 2 participants 3 messages Feb 12, 2014

Subsystems (2)
lore
Share & tools
lore

Guenter Roeck

author maintainer
#0 lore raw

PATCH 1/2 hwmon: (emc2103) Return error from i2c_smbus_read_byte_data

There is no reason to replace one error with another.

smatch message:
drivers/hwmon/emc2103.c:352 set_fan_div() info: why not propagate 'status' from i2c_smbus_read_byte_data() instead of (-5)?

---
 drivers/hwmon/emc2103.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwmon/emc2103.c +1 -1
index 2c137b2..fd892dd 100644
@@ -349,7 +349,7 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *da,
 		dev_dbg(&client->dev, "reg 0x%02x, err %d\n",
 			REG_FAN_CONF1, status);
 		mutex_unlock(&data->update_lock);
-		return -EIO;
+		return status;
 	}
 	status &= 0x9F;
 	status |= (new_range_bits << 5);
Signature · 7 lines
1.7.9.7


_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Reviewed-by on v1 1/2
#1 lore raw
Quoted 16 lines · Guenter Roeck

There is no reason to replace one error with another.

smatch message:
drivers/hwmon/emc2103.c:352 set_fan_div() info: why not propagate 'status' from i2c_smbus_read_byte_data() instead of (-5)?

---
 drivers/hwmon/emc2103.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwmon/emc2103.c +0 -0
index 2c137b2..fd892dd 100644

drivers/hwmon/emc2103.c static ssize_t set_fan_div(struct device *dev, struct device_attribute *da, · line 355

Quoted 8 lines
drivers/hwmon/emc2103.c +1 -1
@@ -349,7 +349,7 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *da,
 		dev_dbg(&client->dev, "reg 0x%02x, err %d\n",
 			REG_FAN_CONF1, status);
 		mutex_unlock(&data->update_lock);
-		return -EIO;
+		return status;
 	}
 	status &= 0x9F;
 	status |= (new_range_bits << 5);

Good catch.

Signature · 7 lines
Jean Delvare
Suse L3 Support

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
author maintainer
#2 lore raw
In reply to Guenter Roeck
Quoted 12 lines · Jean Delvare
Quoted 11 lines · Guenter Roeck

There is no reason to replace one error with another.

smatch message:
drivers/hwmon/emc2103.c:352 set_fan_div() info: why not propagate 'status' from i2c_smbus_read_byte_data() instead of (-5)?

---
  drivers/hwmon/emc2103.c |    2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 16 lines

drivers/hwmon/emc2103.c static ssize_t set_fan_div(struct device *dev, struct device_attribute *da, · line 355

Quoted 13 lines
drivers/hwmon/emc2103.c +1 -1
index 2c137b2..fd892dd 100644
@@ -349,7 +349,7 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *da,
  		dev_dbg(&client->dev, "reg 0x%02x, err %d\n",
  			REG_FAN_CONF1, status);
  		mutex_unlock(&data->update_lock);
-		return -EIO;
+		return status;
  	}
  	status &= 0x9F;
  	status |= (new_range_bits << 5);

Good catch.

Hi Jean.

Easy with an auto-builder ...

This is the current list of problems reported by smatch.

drivers/hwmon/lm90.c:1204 lm90_detect() info: why not propagate 'config2' from i2c_smbus_read_byte_data() instead of (-19)? drivers/hwmon/w83627hf.c:1857 w83627hf_update_device() error: buffer overflow 'regpwm_627hf' 2 <= 2 drivers/hwmon/f71882fg.c:2374 f71882fg_probe() warn: missing break? reassigning 'data->auto_point_temp_signed' drivers/hwmon/max1668.c:386 max1668_detect() info: why not propagate 'dev_id' from i2c_smbus_read_byte_data() instead of (-19)? drivers/hwmon/tmp401.c:214 tmp401_update_device_reg16() error: buffer overflow 'TMP432_TEMP_MSB_READ' 4 <= 5 drivers/hwmon/tmp401.c:215 tmp401_update_device_reg16() error: buffer overflow 'TMP401_TEMP_MSB_READ[j]' 2 <= 2 drivers/hwmon/tmp401.c:222 tmp401_update_device_reg16() error: buffer overflow 'TMP432_TEMP_LSB' 3 <= 5 drivers/hwmon/tmp401.c:223 tmp401_update_device_reg16() error: buffer overflow 'TMP401_TEMP_LSB[j]' 2 <= 2 drivers/hwmon/w83791d.c:996 store_temp23() warn: '32768' 32768 can't fit into 32767 'data->temp_add[nr][index]' drivers/hwmon/lm63.c:594 set_temp11() warn: '65504' 65504 can't fit into 32767 'data->temp11[nr]' drivers/hwmon/lm63.c:596 set_temp11() warn: '32768' 32768 can't fit into 32767 'data->temp11[nr]'

All false positives as far as I can see, but except for the detect functions, it points to less than perfect code. No idea how to make it better without making the code more complicated, though. Just in case you have too much time and want to have a look :-)

Guenter

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors