Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754207AbdG3NvF convert rfc822-to-8bit (ORCPT ); Sun, 30 Jul 2017 09:51:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:40092 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751002AbdG3NvD (ORCPT ); Sun, 30 Jul 2017 09:51:03 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2873022BE3 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=jic23@kernel.org Date: Sun, 30 Jul 2017 14:50:59 +0100 From: Jonathan Cameron To: Stefan =?UTF-8?B?QnLDvG5z?= Cc: , , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler Subject: Re: [PATCH] iio: adc: ina219: Avoid underflow for sleeping time Message-ID: <20170730145059.5975d2fa@kernel.org> In-Reply-To: References: X-Mailer: Claws Mail 3.15.0-dirty (GTK+ 2.24.31; x86_64-unknown-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1223 Lines: 35 On Wed, 26 Jul 2017 23:32:06 +0200 Stefan Brüns wrote: > Proper support for the INA219 lowered the minimum sampling period from > 2*140us to 2*84us. Subtracting 200us later leads to an underflow and > an almost infinite udelay later. > > Using a signed int for the sampling period provides sufficient range > (at most 2*8640*1024us), but catches the underflow when comparing with > buffer_us. > > Fixes: 18edac2e22f4 ("iio: adc: Fix integration time/averaging for INA219/220") > Signed-off-by: Stefan Brüns applied to the fixes-togreg branch of iio.git Thanks, Jonathan > --- > drivers/iio/adc/ina2xx-adc.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/iio/adc/ina2xx-adc.c b/drivers/iio/adc/ina2xx-adc.c > index b0d9e3b80e6d..85b419ea9ba9 100644 > --- a/drivers/iio/adc/ina2xx-adc.c > +++ b/drivers/iio/adc/ina2xx-adc.c > @@ -657,7 +657,7 @@ static int ina2xx_capture_thread(void *data) > { > struct iio_dev *indio_dev = data; > struct ina2xx_chip_info *chip = iio_priv(indio_dev); > - unsigned int sampling_us = SAMPLING_PERIOD(chip); > + int sampling_us = SAMPLING_PERIOD(chip); > int buffer_us; > > /*