Skip to content

Commit 5c2bd0c

Browse files
peda-rgregkh
authored andcommitted
hwmon: (ads1015) Handle negative conversion values correctly
commit acc1469 upstream. Make the divisor signed as DIV_ROUND_CLOSEST is undefined for negative dividends when the divisor is unsigned. Signed-off-by: Peter Rosin <[email protected]> Signed-off-by: Guenter Roeck <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 4bbd7ac commit 5c2bd0c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/hwmon/ads1015.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ static int ads1015_reg_to_mv(struct i2c_client *client, unsigned int channel,
126126
struct ads1015_data *data = i2c_get_clientdata(client);
127127
unsigned int pga = data->channel_data[channel].pga;
128128
int fullscale = fullscale_table[pga];
129-
const unsigned mask = data->id == ads1115 ? 0x7fff : 0x7ff0;
129+
const int mask = data->id == ads1115 ? 0x7fff : 0x7ff0;
130130

131131
return DIV_ROUND_CLOSEST(reg * fullscale, mask);
132132
}

0 commit comments

Comments
 (0)