Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp886273rdb; Fri, 1 Dec 2023 00:47:45 -0800 (PST) X-Google-Smtp-Source: AGHT+IFwun3A7MQCid9yJO57kOrKrTYtcxK6P2Kze5Pc928BEbpn+gnRuMlmNVAh3s73FJ8C1DHW X-Received: by 2002:a05:6358:591e:b0:16d:aead:f764 with SMTP id g30-20020a056358591e00b0016daeadf764mr27875634rwf.12.1701420464766; Fri, 01 Dec 2023 00:47:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701420464; cv=none; d=google.com; s=arc-20160816; b=wIOTW+HkMa8d0K700J6pWM+v+H/2zF8TrE7wYNyN4uBxS2fA0QVE32LRQlrsY0O3TB 8AbQNTYnYRBodmTs9f91m3Bd4qcPGlJfB1ChXqMjKxoDC4rOy3+wUYQItDo0DafX1AvW Sgk9mx2r4rGvb1eMRGDveOmqTbu3OgdchCSUx2jeGMOm+ZUO/buzjpCGF7yiDjulFCzH opYAMkglSK+yGuk1kQ5+kbqYXXZhKS6ejV3yLqy3EQWB2lVV15BQC8t2ZCrQvFz1TAUB YLRELXVEMTIO9lRU7d1U8oB4b9JqvhDW7Yc7w0OQfLIYswgX3GqjSpxZot9iMSQMxX/R ps/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id:dkim-signature; bh=Y5k3hp+Fps+KFaY2xy891TNAjRy9G6LGzZSmFk20j0I=; fh=GQxDNlU0szhKG+eay4kofdBwtci3PaXxPlX9M257frU=; b=JA7eVpkAoyxEfhwcpybqoRiTdI5IlQKRL48Hq0FGsDg6bi69QLlafhl0Nfu21gtgTt mN2lfkA+0z8dgZPmDwYrUlwoodkvRF1N7WXjBL7gl/ReQEYmFK4ysF3s0LW/1g79OwaH PbEcwE+Nk0AI9JBY6mN1+79A5MyRIGNE4Yt17O0v0wFHSq2y9J9QyjncKybJ4NLTq0/U ArUKf+tBAPXUrthhvP+tFNwO+FapnloUGLVPyB9oh5li4oP+o3dc20oa0pY42YLQvO2Q m48aZzHs06Czws4OhVGyhT0MRGsscFdeKlvRrakVRbTli8/nwiF/SmLJHCTDg/nCa6ae nQbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=c7wK3F3y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id p188-20020a6342c5000000b005be2508ce03si2970975pga.569.2023.12.01.00.47.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 00:47:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=c7wK3F3y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 08E5880898DE; Fri, 1 Dec 2023 00:47:41 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377855AbjLAIrX (ORCPT + 99 others); Fri, 1 Dec 2023 03:47:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229455AbjLAIrW (ORCPT ); Fri, 1 Dec 2023 03:47:22 -0500 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 033C8C4; Fri, 1 Dec 2023 00:47:27 -0800 (PST) Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-40b27b498c3so19381965e9.0; Fri, 01 Dec 2023 00:47:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701420445; x=1702025245; darn=vger.kernel.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:from:to:cc:subject :date:message-id:reply-to; bh=Y5k3hp+Fps+KFaY2xy891TNAjRy9G6LGzZSmFk20j0I=; b=c7wK3F3y6AdvN+ox6sT3JMWx5xxt/M7lxTFCNoXDX7vH887AMfYs9UVmnRKaBzfDV7 raAbFFdWh4ZJjRyVQfaL8Hv+AcqGlZvgYTkCXiH7ko61K9vf9M8OnYM+C4qjT6kfLQWe +p3THRKVUSHuAXkqsoNMQLoHhqB6gjTZEZ2DBqLlcwxEi3+Q2i86nB2bpvDWitiwg+6d +//D4hPfkkA3JB1+nTc9Zk1PtUfXKETcJGQn7l7Z4FEU1jka4bUNRcgsxfMdW1cuQG+/ SVgw0w2pM/Z6m8rwNLGTDJLJustXggva3WxW9klGtpgroIwEjVKQuS/iBkBOxkWgdEj9 p4sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701420445; x=1702025245; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=Y5k3hp+Fps+KFaY2xy891TNAjRy9G6LGzZSmFk20j0I=; b=jXXtgPT1klV0WXXJj6Tqo7hh4vlR6enFaJW7nd/6Imr3deX0U79JK6pxun7TzrSIoK aUqGnJUSHAptwwAoeYVxE0621AFiNSGbcH+/Aq1mHugFl1y97mb9uMJZzmFFAepI6MAW ZQrLszyi0Ka8eClVSfET2gBAYObS95a44Ixv3HcPIekf7J2DFRh06YjJQhPLDIwOP2dn 0NYD92oE1S8eUoWMHoyB+b3uMNPPe1KSKtU14qQ3xYIgJQDlbWBFUMp0t9qBocGYnQlJ owVX2hEC7uzFhGpzYYDeQuf8hpljM4u/0I02tmr4+paChgKlHadl+EUEqor6cG5OZvef eENw== X-Gm-Message-State: AOJu0Yzr0F3TZWa95OA0K2sEF+4aXdJGrdXfGAgvcpqQ5U+5dTVJ1Y1y bG6sa/HE+KAhyn5T+aBk67rhFZRftfNda4eq X-Received: by 2002:a05:600c:178a:b0:40b:5e59:ccce with SMTP id x10-20020a05600c178a00b0040b5e59cccemr282792wmo.175.1701420445117; Fri, 01 Dec 2023 00:47:25 -0800 (PST) Received: from ?IPv6:2001:a61:3456:4e01:6ae:b55a:bd1d:57fc? ([2001:a61:3456:4e01:6ae:b55a:bd1d:57fc]) by smtp.gmail.com with ESMTPSA id fs16-20020a05600c3f9000b0040b48690c49sm4625136wmb.6.2023.12.01.00.47.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 00:47:24 -0800 (PST) Message-ID: Subject: Re: [PATCH 04/12] iio: adc: ad9467: fix reset gpio handling From: Nuno =?ISO-8859-1?Q?S=E1?= To: David Lechner , nuno.sa@analog.com Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-iio@vger.kernel.org, Olivier MOYSAN , Greg Kroah-Hartman , "Rafael J. Wysocki" , Rob Herring , Frank Rowand , Jonathan Cameron , Lars-Peter Clausen , Michael Hennerich Date: Fri, 01 Dec 2023 09:47:24 +0100 In-Reply-To: References: <20231121-dev-iio-backend-v1-0-6a3d542eba35@analog.com> <20231121-dev-iio-backend-v1-4-6a3d542eba35@analog.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.48.4 (3.48.4-1.fc38) MIME-Version: 1.0 X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Fri, 01 Dec 2023 00:47:41 -0800 (PST) On Thu, 2023-11-30 at 15:41 -0600, David Lechner wrote: > On Tue, Nov 21, 2023 at 4:17=E2=80=AFAM Nuno Sa via B4 Relay > wrote: > >=20 > > From: Nuno Sa > >=20 > > The reset gpio was being requested with GPIOD_OUT_LOW which means, not > > asserted. Then it was being asserted but never de-asserted which means > > the devices was left in reset. Fix it by de-asserting the gpio. >=20 > It could be helpful to update the devicetree bindings to state the > expected active-high or active-low setting for this gpio so it is > clear which state means asserted. >=20 You could state that the chip is active low but I don't see that change tha= t important for now. Not sure if this is clear and maybe that's why your comm= ent. GPIOD_OUT_HIGH has nothing to do with active high or low. It just means, "g= et me the pin in the asserted state". > > While at it, moved the handling to it's own function and dropped > > 'reset_gpio' from the 'struct ad9467_state' as we only need it during > > probe. On top of that, refactored things so that we now request the gpi= o > > asserted (i.e in reset) and then de-assert it. > >=20 > > Fixes: ad6797120238 ("iio: adc: ad9467: add support AD9467 ADC") > > Signed-off-by: Nuno Sa > > --- > > =C2=A0drivers/iio/adc/ad9467.c | 33 ++++++++++++++++++++------------- > > =C2=A01 file changed, 20 insertions(+), 13 deletions(-) > >=20 > > diff --git a/drivers/iio/adc/ad9467.c b/drivers/iio/adc/ad9467.c > > index 39eccc28debe..368ea57be117 100644 > > --- a/drivers/iio/adc/ad9467.c > > +++ b/drivers/iio/adc/ad9467.c > > @@ -121,7 +121,6 @@ struct ad9467_state { > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 unsigned int=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0 output_mode; > >=20 > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 struct gpio_desc=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 *pwrdown_gpio; > > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 struct gpio_desc=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= *reset_gpio; > > =C2=A0}; > >=20 > > =C2=A0static int ad9467_spi_read(struct spi_device *spi, unsigned int r= eg) > > @@ -378,6 +377,23 @@ static int ad9467_preenable_setup(struct adi_axi_a= dc_conv > > *conv) > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return ad9467_outputmode_set= (st->spi, st->output_mode); > > =C2=A0} > >=20 > > +static int ad9467_reset(struct device *dev) > > +{ > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 struct gpio_desc *gpio; > > + > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 gpio =3D devm_gpiod_get_optional(= dev, "reset", GPIOD_OUT_HIGH); > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (IS_ERR(gpio)) > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 return PTR_ERR(gpio); > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (!gpio) > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 return 0; >=20 > can be done in one test instead of 2: >=20 > if (IS_ERR_OR_NULL(gpio)) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return PTR_ERR_OR_ZERO(gpio); >=20 Yep, better that way... > > + > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 fsleep(1); > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 gpiod_direction_output(gpio, 0); > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 fsleep(10); >=20 > Previous version was 10 milliseconds instead of 10 microseconds. Was > this change intentional? If yes, it should be mentioned it in the > commit message. Oh, good catch! Copy past thing with even realizing the differences in the = arguments :face_palm: - Nuno S=C3=A1 >=20