Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1337345

[PATCH] hwmon: (ads1015) Handle negative conversion values correctly

From Peter Rosin <peda@lysator.liu.se>
Newsgroups linux.kernel
Subject [PATCH] hwmon: (ads1015) Handle negative conversion values correctly
Date 2016-02-18 14:20 +0100
Message-ID <r3wEW-626-13@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


From: Peter Rosin <peda@axentia.se>

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>
---
 drivers/hwmon/ads1015.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hwmon/ads1015.c b/drivers/hwmon/ads1015.c
index f155b8380481..2b3105c8aed3 100644
--- a/drivers/hwmon/ads1015.c
+++ b/drivers/hwmon/ads1015.c
@@ -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);
 }
-- 
2.1.4

Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

[PATCH] hwmon: (ads1015) Handle negative conversion values correctly Peter Rosin <peda@lysator.liu.se> - 2016-02-18 14:20 +0100
  Re: [PATCH] hwmon: (ads1015) Handle negative conversion values correctly Peter Rosin <peda@lysator.liu.se> - 2016-02-19 00:20 +0100
    Re: [PATCH] hwmon: (ads1015) Handle negative conversion values  correctly Guenter Roeck <linux@roeck-us.net> - 2016-02-19 04:20 +0100
  Re: [PATCH] hwmon: (ads1015) Handle negative conversion values  correctly Greg KH <gregkh@linuxfoundation.org> - 2016-02-19 23:30 +0100

csiph-web