Skip to content

Commit

Permalink
hwmon: (ads1015) Handle negative conversion values correctly
Browse files Browse the repository at this point in the history
Make the divisor signed as DIV_ROUND_CLOSEST is undefined for negative
dividends when the divisor is unsigned.

Signed-off-by: Peter Rosin <peda@axentia.se>
Cc: stable@vger.kernel.org
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
  • Loading branch information
Peter Rosin authored and Guenter Roeck committed Feb 19, 2016
1 parent 18558ca commit acc1469
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/hwmon/ads1015.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ static int ads1015_reg_to_mv(struct i2c_client *client, unsigned int channel,
struct ads1015_data *data = i2c_get_clientdata(client);
unsigned int pga = data->channel_data[channel].pga;
int fullscale = fullscale_table[pga];
const unsigned mask = data->id == ads1115 ? 0x7fff : 0x7ff0;
const int mask = data->id == ads1115 ? 0x7fff : 0x7ff0;

return DIV_ROUND_CLOSEST(reg * fullscale, mask);
}
Expand Down

0 comments on commit acc1469

Please sign in to comment.