* [patch] ds2782_battery: signedness bug in ds278x_read_reg16()
@ 2012-10-24 7:12 Dan Carpenter
2012-11-18 22:47 ` Anton Vorontsov
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2012-10-24 7:12 UTC (permalink / raw)
To: Anton Vorontsov; +Cc: David Woodhouse, linux-kernel, kernel-janitors
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>
diff --git a/drivers/power/ds2782_battery.c b/drivers/power/ds2782_battery.c
index 6bb6e2f..2fa9b6b 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;
}
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [patch] ds2782_battery: signedness bug in ds278x_read_reg16()
2012-10-24 7:12 [patch] ds2782_battery: signedness bug in ds278x_read_reg16() Dan Carpenter
@ 2012-11-18 22:47 ` Anton Vorontsov
0 siblings, 0 replies; 2+ messages in thread
From: Anton Vorontsov @ 2012-11-18 22:47 UTC (permalink / raw)
To: Dan Carpenter; +Cc: David Woodhouse, linux-kernel, kernel-janitors
On Wed, Oct 24, 2012 at 10:12:29AM +0300, Dan Carpenter wrote:
> 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>
Applied, thanks!
> diff --git a/drivers/power/ds2782_battery.c b/drivers/power/ds2782_battery.c
> index 6bb6e2f..2fa9b6b 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;
> }
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-11-18 22:47 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-24 7:12 [patch] ds2782_battery: signedness bug in ds278x_read_reg16() Dan Carpenter
2012-11-18 22:47 ` Anton Vorontsov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox