Skip to content

Commit

Permalink
hwmon: (adt7475) Make adt7475_read_word() return errors
Browse files Browse the repository at this point in the history
The adt7475_read_word() function was meant to return negative error
codes on failure.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Tokunori Ikegami <ikegami@allied-telesis.co.jp>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
  • Loading branch information
Dan Carpenter authored and Guenter Roeck committed Aug 27, 2018
1 parent 9d19371 commit f196dec
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions drivers/hwmon/adt7475.c
Original file line number Diff line number Diff line change
Expand Up @@ -302,14 +302,18 @@ 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 val1, val2;

val = i2c_smbus_read_byte_data(client, reg);
val |= (i2c_smbus_read_byte_data(client, reg + 1) << 8);
val1 = i2c_smbus_read_byte_data(client, reg);
if (val1 < 0)
return val1;
val2 = i2c_smbus_read_byte_data(client, reg + 1);
if (val2 < 0)
return val2;

return val;
return val1 | (val2 << 8);
}

static void adt7475_write_word(struct i2c_client *client, int reg, u16 val)
Expand Down

0 comments on commit f196dec

Please sign in to comment.