Commit 8511748b authored by Dan Carpenter's avatar Dan Carpenter Committed by Anton Vorontsov

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: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarAnton Vorontsov <anton.vorontsov@linaro.org>
parent 08d816b8
......@@ -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;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment