Skip to contentSkip to conversation

hwmon: (adt7462) ADT7462_REG_VOLT_MAX() should return 0

PATCH In review Dan Carpenter 2 participants 3 messages Aug 14, 2013

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

PATCH 1/1 hwmon: (adt7462) ADT7462_REG_VOLT_MAX() should return 0

The callers never check for negative but they sometimes check for zero returns:

	int reg = ADT7462_REG_VOLT_MAX(data, i);
        data->volt_max[i] 		(reg ? i2c_smbus_read_byte_data(client, reg) : 0);

---
Static checker stuff. I don't have this hardware.

drivers/hwmon/adt7462.c +2 -2
index 69481d3..3e6aba1 100644
@@ -333,7 +333,7 @@ static int ADT7462_REG_VOLT_MAX(struct adt7462_data *data, int which)
 			return 0x4C;
 		break;
 	}
-	return -ENODEV;
+	return 0;
 }
 
 static int ADT7462_REG_VOLT_MIN(struct adt7462_data *data, int which)
@@ -392,7 +392,7 @@ static int ADT7462_REG_VOLT_MIN(struct adt7462_data *data, int which)
 			return 0x77;
 		break;
 	}
-	return -ENODEV;
+	return 0;
 }
 
 static int ADT7462_REG_VOLT(struct adt7462_data *data, int which)
#1 lore raw
Quoted 9 lines · Dan Carpenter

The callers never check for negative but they sometimes check for zero returns:

	int reg = ADT7462_REG_VOLT_MAX(data, i);
        data->volt_max[i] > 		(reg ? i2c_smbus_read_byte_data(client, reg) : 0);

---
Static checker stuff. I don't have this hardware.

I should have also said that not all the callers check for error. I don't know if that is a problem.

regards,
dan carpenter

maintainer
#2 lore raw
In reply to Dan Carpenter
Quoted 7 lines · Dan Carpenter
Quoted 6 lines · Dan Carpenter

The callers never check for negative but they sometimes check for zero returns:

	int reg = ADT7462_REG_VOLT_MAX(data, i);
         data->volt_max[i] >> 		(reg ? i2c_smbus_read_byte_data(client, reg) : 0);
Quoted 7 lines
Quoted 3 lines

---
Static checker stuff. I don't have this hardware.

I should have also said that not all the callers check for error. I don't know if that is a problem.

It is undesirable, but would be much more complex to fix. So your patch is the sensible approach to take care of the immediate problem, and we can leave the fancy solution to someone with enough time at hand.

I'll apply it to -next.

Thanks,
Guenter