@@ -303,20 +303,34 @@ static inline u16 volt2reg(int channel, long volt, u8 bypass_attn)
return clamp_val(reg, 0, 1023) & (0xff << 2);
}
-static u16 adt7475_read_word(struct i2c_client *client, int reg)
+static int adt7475_read_word(struct i2c_client *client, int reg)
{
- u16 val;
+ int val, val2;
- val = i2c_smbus_read_byte_data(client, reg);
- val |= (i2c_smbus_read_byte_data(client, reg + 1) << 8);
+ val = adt7475_read(reg);
+ if (val < 0)
+ return val;
- return val;
+ val2 = adt7475_read(reg + 1);
+ if (val2 < 0)
+ return val2;
+
+ return val | (val2 << 8);
}
-static void adt7475_write_word(struct i2c_client *client, int reg, u16 val)
+static int adt7475_write_word(struct i2c_client *client, int reg, u16 val)
{
- i2c_smbus_write_byte_data(client, reg + 1, val >> 8);
- i2c_smbus_write_byte_data(client, reg, val & 0xFF);
+ int ret;
+
+ ret = i2c_smbus_write_byte_data(client, reg + 1, val >> 8);
+ if (ret < 0)
+ return ret;
+
+ ret = i2c_smbus_write_byte_data(client, reg, val & 0xFF);
+ if (ret < 0)
+ return ret;
+
+ return 0;
}
static ssize_t show_voltage(struct device *dev, struct device_attribute *attr,
Currently adt7475_read_word and adt7475_write_word do not return error. So change both functions to return error codes correctly. Signed-off-by: Tokunori Ikegami <ikegami@allied-telesis.co.jp> Cc: Chris Packham <chris.packham@alliedtelesis.co.nz> Cc: linux-hwmon@vger.kernel.org --- drivers/hwmon/adt7475.c | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-)