Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753838AbdIDPdc (ORCPT ); Mon, 4 Sep 2017 11:33:32 -0400 Received: from mail-by2nam01on0049.outbound.protection.outlook.com ([104.47.34.49]:26480 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753776AbdIDPd3 (ORCPT ); Mon, 4 Sep 2017 11:33:29 -0400 Authentication-Results: spf=pass (sender IP is 137.71.25.57) smtp.mailfrom=analog.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=bestguesspass action=none header.from=analog.com; From: "Bogdan, Dragos" To: Jonathan Cameron CC: Lars-Peter Clausen , "Hennerich, Michael" , Jonathan Cameron , Hartmut Knaack , Peter Meerwald-Stadler , "linux-iio@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] iio:ad7793: Fix the serial interface reset Thread-Topic: [PATCH] iio:ad7793: Fix the serial interface reset Thread-Index: AQHTJY6dMdVJ9ijKcUOAd6xVjREEAA== Date: Mon, 4 Sep 2017 15:33:25 +0000 Message-ID: <6067964B99C6A049AA5840B6F7BB2D0ABDAD4161@NWD2MBX5.ad.analog.com> References: <20170904150048.12420-1-dragos.bogdan@analog.com> <20170904162613.00003d47@huawei.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.64.7.152] Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:137.71.25.57;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(39860400002)(2980300002)(438002)(377454003)(189002)(199003)(24454002)(106466001)(8666007)(54906002)(55016002)(2920100001)(2900100001)(86362001)(5250100002)(626005)(53546010)(97756001)(189998001)(72206003)(478600001)(47776003)(46406003)(246002)(55846006)(50986999)(54356999)(76176999)(14454004)(50466002)(33656002)(4326008)(5660300001)(23726003)(3846002)(6116002)(8936002)(8676002)(229853002)(7696004)(6916009)(102836003)(7636002)(7736002)(305945005)(356003)(8746002)(6246003)(110136004)(2906002);DIR:OUT;SFP:1101;SCL:1;SRVR:BN3PR03MB2355;H:nwd2mta4.analog.com;FPR:;SPF:Pass;PTR:nwd2mail11.analog.com;MX:1;A:1;LANG:en; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4336253e-8e66-48fe-8cd1-08d4f3aa4932 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(300000502095)(300135100095)(22001)(2017030254152)(8251501002)(300000503095)(300135400095)(2017052603199)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:BN3PR03MB2355; X-MS-TrafficTypeDiagnostic: BN3PR03MB2355: X-Forefront-Antispam-Report-Untrusted: X-Microsoft-Exchange-Diagnostics: 1;BN3PR03MB2355;20:a9rjIPalAirFwdUUNj67S4/Ns0IPD7xzUu5Qo5+Y1L4fx8XzkaAFkE1yENR6zz14ks/GVWH7wvClpeCkVPzEOldd6iW4Y4IERb1a5DCv3zaGcPuLGyDgt4zXgau5joQRUk4Y0WJQlMpS1mXul6Q5+erl/8Bz6TXaAqcuiINEO5CxZBSQv72DXznBzvy3KjOgvOchUEcPZheEs7AdfsMn9s+/thZLjXD6BWHsXNgm8cVmqu/CUJkdt7iK47VXQtglwUd8vhqKOST3CGG4zg7X+YJykMyX46obXO+tsVIbP4hS+Wg/aVcXv2dH4KJ3VOuuTLeBGOHzKsvIjtlbDr/zWPGVFoPG5VX+SClc84UEOu6FwCqdwDyg+rAC/ql/Isu01kZlDhT+1yacE5HtBgPDcCJtMAH17+VSFDjHLZvOIxk7sc1LYisBGw0jnx3dVRM/KkoK3mPoKajem2b4So9LLrbELC1Fj6Qx3rE3TOXLz0ivsJPvXWNqS8Qv+RsCbKEN;4:QnL5iOCoKxg0IxN1eXXsxP8HXXhkOPXaA1OBYK4LrwA6c54d/YMLNJh03llBQB6UqEfXy70Qd/L4hPEiyMs2J5H+ycI4KfxfrChkB/VnYJF5c2BqmxW2Vtui227yTm/VUaz8vus1L7ZYmmaTdCLyR27jsTJ7XsUGfDC8XkM8Y0O6YAZKh/xAba5Gdt2aGaLy2iM8fivsNORZgfrhXQ15/gO7+ikD8l+qA34kBXiFk4ZY1GRVkSz6IgKHsyCB7FlLefRKb+qILH0zSFYJ/s5Xyk3oAgPqbawmf3fyNt3jBcc= X-Exchange-Antispam-Report-Test: UriScan:(232431446821674); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(8121501046)(5005006)(3002001)(100000703101)(100105400095)(10201501046)(93006095)(93004095)(6055026)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(20161123562025)(20161123558100)(20161123560025)(20161123555025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:BN3PR03MB2355;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:BN3PR03MB2355; X-Forefront-PRVS: 0420213CCD X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BN3PR03MB2355;23:tY1roayvZ3JqteCQeTFYizLV9fY5FbLTeizFD4HIk?= =?us-ascii?Q?70eAsNA62e5UXW2cZ4O9KsQHt4wO7gwjDkljygOICncUGUJHOEZeozq4WKcI?= =?us-ascii?Q?6v+RKJIb/Od0c0jJjINaOpwFA0KLvu/I/07LQV++d/sJ1Qh/3HesaGTDekrm?= =?us-ascii?Q?Wi1d2Impf/6JIcI13DNFbq20lubAxZK7oGMCj3EPEUj7xUFPs4sv5jMGkW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ata: NSPM X-OriginatorOrg: analog.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Sep 2017 15:33:26.2874 (UTC) X-MS-Exchange-CrossTenant-Id: eaa689b4-8f87-40e0-9c6f-7228de4d754a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=eaa689b4-8f87-40e0-9c6f-7228de4d754a;Ip=[137.71.25.57];Helo=[nwd2mta4.analog.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN3PR03MB2355 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by nfs id v84FXdmf020729 Content-Length: 1595 Lines: 56 On 09/04/2017 06:27 PM, Jonathan Cameron wrote: > 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 Hi Jonathan, I agree with your suggestion. I'll change it accordingly in v2. Thanks, Dragos >> --- >> 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; > >