aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/power/ds2782_battery.c
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2012-10-24 03:12:29 -0400
committerAnton Vorontsov <anton.vorontsov@linaro.org>2012-11-18 17:46:39 -0500
commit8511748ba1ab83a7d89d802a50335115358a8cfc (patch)
tree6a1e43229f4e4831e5d2fac487916baaf4bd0bb9 /drivers/power/ds2782_battery.c
parent08d816b8cb09de1fd8268c8f1dbc97c3cc435d67 (diff)
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 <dan.carpenter@oracle.com> Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
Diffstat (limited to 'drivers/power/ds2782_battery.c')
-rw-r--r--drivers/power/ds2782_battery.c4
1 files changed, 2 insertions, 2 deletions
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,
80{ 80{
81 int ret; 81 int ret;
82 82
83 ret = swab16(i2c_smbus_read_word_data(info->client, reg_msb)); 83 ret = i2c_smbus_read_word_data(info->client, reg_msb);
84 if (ret < 0) { 84 if (ret < 0) {
85 dev_err(&info->client->dev, "register read failed\n"); 85 dev_err(&info->client->dev, "register read failed\n");
86 return ret; 86 return ret;
87 } 87 }
88 88
89 *val = ret; 89 *val = swab16(ret);
90 return 0; 90 return 0;
91} 91}
92 92