From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757335AbcBSDQq (ORCPT ); Thu, 18 Feb 2016 22:16:46 -0500 Received: from bh-25.webhostbox.net ([208.91.199.152]:46602 "EHLO bh-25.webhostbox.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753790AbcBSDQo (ORCPT ); Thu, 18 Feb 2016 22:16:44 -0500 Date: Thu, 18 Feb 2016 19:16:40 -0800 From: Guenter Roeck To: Peter Rosin Cc: Dirk Eibach , Peter Rosin , Jean Delvare , lm-sensors@lm-sensors.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] hwmon: (ads1015) Handle negative conversion values correctly Message-ID: <20160219031640.GA8786@roeck-us.net> References: <1455800872-24431-1-git-send-email-peda@lysator.liu.se> <56C65027.5010403@lysator.liu.se> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <56C65027.5010403@lysator.liu.se> User-Agent: Mutt/1.5.23 (2014-03-12) X-Authenticated_sender: guenter@roeck-us.net X-OutGoing-Spam-Status: No, score=-1.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - bh-25.webhostbox.net X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - roeck-us.net X-Get-Message-Sender-Via: bh-25.webhostbox.net: authenticated_id: guenter@roeck-us.net X-Authenticated-Sender: bh-25.webhostbox.net: guenter@roeck-us.net X-Source: X-Source-Args: X-Source-Dir: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 19, 2016 at 12:13:43AM +0100, Peter Rosin wrote: > Hi! > > Sorry for the noise, but... > > On 2016-02-18 14:07, Peter Rosin wrote: > > From: Peter Rosin > > > > Make the divisor signed as DIV_ROUND_CLOSEST is undefined for negative > > dividends when the divisor is unsigned. > > > > Signed-off-by: Peter Rosin > > ...I forgot to add this to the commit message > Cc: stable@vger.kernel.org > No problem, I prefer to do that myself anyway. Patch applied. Thanks, Guenter > I also didn't explicitly mention any example platform where this > bug causes real problems; it was triggered on ARM (atmel sama5d). > > Cheers, > Peter > > > --- > > 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); > > } > >