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 <[email protected]>
Cc: Chris Packham <[email protected]>
Cc: [email protected]
---
 drivers/hwmon/adt7475.c | 30 ++++++++++++++++++++++--------
 1 file changed, 22 insertions(+), 8 deletions(-)

diff --git a/drivers/hwmon/adt7475.c b/drivers/hwmon/adt7475.c
index 234f725213f9..a40eb62ee6b1 100644
--- a/drivers/hwmon/adt7475.c
+++ b/drivers/hwmon/adt7475.c
@@ -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,
-- 
2.16.1

--
To unsubscribe from this list: send the line "unsubscribe linux-hwmon" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to