Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753846AbdIDP07 (ORCPT ); Mon, 4 Sep 2017 11:26:59 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:5958 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753751AbdIDP05 (ORCPT ); Mon, 4 Sep 2017 11:26:57 -0400 Date: Mon, 4 Sep 2017 16:26:13 +0100 From: Jonathan Cameron To: Dragos Bogdan CC: Lars-Peter Clausen , Michael Hennerich , Jonathan Cameron , "Hartmut Knaack" , Peter Meerwald-Stadler , , Subject: Re: [PATCH] iio:ad7793: Fix the serial interface reset Message-ID: <20170904162613.00003d47@huawei.com> In-Reply-To: <20170904150048.12420-1-dragos.bogdan@analog.com> References: <20170904150048.12420-1-dragos.bogdan@analog.com> Organization: Huawei X-Mailer: Claws Mail 3.15.0 (GTK+ 2.24.31; x86_64-w64-mingw32) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.206.48.115] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020203.59AD70BD.00AF,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 6ea2968ddbbf71f9b9601c064d028ed9 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1399 Lines: 47 On Mon, 4 Sep 2017 18:00:48 +0300 Dragos Bogdan wrote: > The serial interface can be reset by writing 32 consecutive 1s to the device. > The value of 'ret' is overwritten when ad7793_check_platform_data() is called, > so it should be initialized to -1 only before doing the spi_write(). > > Fixes: commit 2edb769d246e ("iio:ad7793: Add support for the ad7798 and ad7799") > > Signed-off-by: Dragos Bogdan Hi Dragos, I'd prefer we introduced a separate variable. Using ret for this is what got us into trouble in the first place. Would you mind respining with that change? Thanks, Jonathan > --- > drivers/iio/adc/ad7793.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/iio/adc/ad7793.c b/drivers/iio/adc/ad7793.c > index e6706a09e100..8680abf72dd2 100644 > --- a/drivers/iio/adc/ad7793.c > +++ b/drivers/iio/adc/ad7793.c > @@ -257,7 +257,7 @@ static int ad7793_setup(struct iio_dev *indio_dev, > unsigned int vref_mv) > { > struct ad7793_state *st = iio_priv(indio_dev); > - int i, ret = -1; > + int i, ret; > unsigned long long scale_uv; > u32 id; > > @@ -266,6 +266,7 @@ static int ad7793_setup(struct iio_dev *indio_dev, > return ret; > > /* reset the serial interface */ > + ret = -1; > ret = spi_write(st->sd.spi, (u8 *)&ret, sizeof(ret)); > if (ret < 0) > goto out;