From 8511748ba1ab83a7d89d802a50335115358a8cfc Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Wed, 24 Oct 2012 10:12:29 +0300 Subject: ds2782_battery: Fix signedness bug in ds278x_read_reg16() We need to check for negative values before doing the swab16() for the error handling to work. Signed-off-by: Dan Carpenter Signed-off-by: Anton Vorontsov --- drivers/power/ds2782_battery.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/power') diff --git a/drivers/power/ds2782_battery.c b/drivers/power/ds2782_battery.c index 6bb6e2f5ea81..2fa9b6bf1f3f 100644 --- a/drivers/power/ds2782_battery.c +++ b/drivers/power/ds2782_battery.c @@ -80,13 +80,13 @@ static inline int ds278x_read_reg16(struct ds278x_info *info, int reg_msb, { int ret; - ret = swab16(i2c_smbus_read_word_data(info->client, reg_msb)); + ret = i2c_smbus_read_word_data(info->client, reg_msb); if (ret < 0) { dev_err(&info->client->dev, "register read failed\n"); return ret; } - *val = ret; + *val = swab16(ret); return 0; } -- cgit v1.2.3