Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp621761rdb; Thu, 30 Nov 2023 13:41:47 -0800 (PST) X-Google-Smtp-Source: AGHT+IHgMVhhBVFYHD/Eeg9oPcW27dBixCNxN9A1U1G9yx7t9o2Vfu1Y4G3nyOx93WeGQul5Mykl X-Received: by 2002:a17:903:32c8:b0:1cf:b12a:a9eb with SMTP id i8-20020a17090332c800b001cfb12aa9ebmr26026268plr.19.1701380506997; Thu, 30 Nov 2023 13:41:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701380506; cv=none; d=google.com; s=arc-20160816; b=uZF8GYU1oqSZe1WbOhnkouI9eb8dY0dhNvwQ16QlNNbrE7efOVS1BHuRkJFaCYPrmR eBl67OCwHrl7DSpyr8xPqbqpzTE3sW0hgur76dG7TcNUwLKpy84CSYHEd7ecmNqUGaIQ EWdkG1n1VGJp1qYpTtfxfUdkSj+WprxWPnyh6k/BArFDgdPaQ8e/knIFW3hatCpa0rtE qsQD+O6g8dnITBoWhuTku3ztIsOvK0FUtlR0uXiWOqImjdYiOqASr9vhzTkM+OQDUMuI zOYwQ8KEn0dVXEIkugDhOxhv7nLQEkTMcE1Js5FK4K1ADQUGBg9VJZC8c9JgVoHdYe/j mKfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=fd0YG7g3wby74JcgoZTxtodoh2Ma9koAtjIfAtnBqJI=; fh=ttWv8VCoGF50n4AB/K9MI+yMSg75NE7RBe49baFg6DU=; b=oW0hzRVQMgtkISCU6kC4wnUr823SpgXAsd4jPhKgB40Jp1hRra4azenMgV/oXz4itL 8prRZsLl4xQxWXFCG3ZF8IaPHb/kTQYJSNzLQwbKN7fIow7r7bj6T2n2jIMumvjkABJs OgWbxYl4UKz1SYSmkgzpcQTIz/YR5DnJCtzLGeptNvIey9uhkLm1jfdOK34s1mBGPVFQ /iJciVXKNvHFA5DiR6h409a4AjD6zyUi5n03BqU0tFpZT1+XgfHFadXdNWaTojkNxKO1 +odXzrQakvMIH5IFT/FJvK4m78K/AwLdgN0amUc2pnU3ZAig0AmF5L6IE4D+TyWXh7ZR v4lw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=2iOGjZfC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id jk21-20020a170903331500b001cc5ada2b94si1855285plb.366.2023.11.30.13.41.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 13:41:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=2iOGjZfC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 3CF498093D7D; Thu, 30 Nov 2023 13:41:28 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229993AbjK3VlK (ORCPT + 99 others); Thu, 30 Nov 2023 16:41:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229645AbjK3VlJ (ORCPT ); Thu, 30 Nov 2023 16:41:09 -0500 Received: from mail-lj1-x229.google.com (mail-lj1-x229.google.com [IPv6:2a00:1450:4864:20::229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7ED2A10F8 for ; Thu, 30 Nov 2023 13:41:14 -0800 (PST) Received: by mail-lj1-x229.google.com with SMTP id 38308e7fff4ca-2c9d4afb7dfso9286421fa.1 for ; Thu, 30 Nov 2023 13:41:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1701380472; x=1701985272; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=fd0YG7g3wby74JcgoZTxtodoh2Ma9koAtjIfAtnBqJI=; b=2iOGjZfCoTX61S0IzTF8HAWGZHbpH0IEYWbQivxvA/ZxP+xHIYwH0+DikksWbd5mzO AcK7xKSkEV8TZrCTG8vTH0Wd7tHM4NPxasAf4ufnqlWHc8vS+ktj5e4GXaAkYQfhY+zt xITrQcSELi2udH6Ynwvm0HZo7hvuWM9GcO4lWKdei+1+NHrgTsT7eQCGF31XOUzbxFdE 9xaGtK4JxeWWNxpPDDHEagDv/7RBYlF5TQ/4xGVHRvgufZ1OUEAYjKckeFgg/0oNKyZh Zk3mGJb7etbEBhn8vewD+Kp+g8s5loU58gUO5Bh6oreuQ/On7ERHcvPLkp7HewOpZbci GgCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701380472; x=1701985272; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fd0YG7g3wby74JcgoZTxtodoh2Ma9koAtjIfAtnBqJI=; b=Y6BAhJn0KtQrfkprqyKf3GNSGa9wCsx8s2mBIrpXUQqTOoQD/9qyei4YwJMMRse2Mi CxrrblAz5qPf76KDWYRjc7eApXolRqgAJtsi5ptLGKgghB1iYCqfvCgZg4x6Q/rPwK+D 3W39Mql9IEjraabdbGG6pKr9xhxvur8yjBqqugvEsEFEh92NziUR5JuKwxFKn6xLTUxA 48zTJCXVwHul43fNu2DRemfyZK1JcIPIw3k1THGfY2NX1WgYrypvyEPBXfdpnj628dbr POuy40LH/G08QxoJBGJyJ+RX/+zOpwM47t3y/lJc+nBvMjF5W6gkXH99tDAbgFC3/eKm 1rSg== X-Gm-Message-State: AOJu0YykHoXI4Dj3G3cbkEd3Zj08NsGlU2MzdGIfOwxWMRCIB2h7s3rx EFYOciwdXkbEjed8w5Y4vU7aHr72DrqOfkjZgd4xmQ== X-Received: by 2002:a2e:9ec1:0:b0:2c9:d872:abdf with SMTP id h1-20020a2e9ec1000000b002c9d872abdfmr87880ljk.93.1701380472434; Thu, 30 Nov 2023 13:41:12 -0800 (PST) MIME-Version: 1.0 References: <20231121-dev-iio-backend-v1-0-6a3d542eba35@analog.com> <20231121-dev-iio-backend-v1-4-6a3d542eba35@analog.com> In-Reply-To: <20231121-dev-iio-backend-v1-4-6a3d542eba35@analog.com> From: David Lechner Date: Thu, 30 Nov 2023 15:41:01 -0600 Message-ID: Subject: Re: [PATCH 04/12] iio: adc: ad9467: fix reset gpio handling To: 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, 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 agentk.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 (agentk.vger.email [0.0.0.0]); Thu, 30 Nov 2023 13:41:28 -0800 (PST) On Tue, Nov 21, 2023 at 4:17=E2=80=AFAM Nuno Sa via B4 Relay wrote: > > From: Nuno Sa > > 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. 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. > > 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 gpio > asserted (i.e in reset) and then de-assert it. > > Fixes: ad6797120238 ("iio: adc: ad9467: add support AD9467 ADC") > Signed-off-by: Nuno Sa > --- > drivers/iio/adc/ad9467.c | 33 ++++++++++++++++++++------------- > 1 file changed, 20 insertions(+), 13 deletions(-) > > 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 { > unsigned int output_mode; > > struct gpio_desc *pwrdown_gpio; > - struct gpio_desc *reset_gpio; > }; > > static int ad9467_spi_read(struct spi_device *spi, unsigned int reg) > @@ -378,6 +377,23 @@ static int ad9467_preenable_setup(struct adi_axi_adc= _conv *conv) > return ad9467_outputmode_set(st->spi, st->output_mode); > } > > +static int ad9467_reset(struct device *dev) > +{ > + struct gpio_desc *gpio; > + > + gpio =3D devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH); > + if (IS_ERR(gpio)) > + return PTR_ERR(gpio); > + if (!gpio) > + return 0; can be done in one test instead of 2: if (IS_ERR_OR_NULL(gpio)) return PTR_ERR_OR_ZERO(gpio); > + > + fsleep(1); > + gpiod_direction_output(gpio, 0); > + fsleep(10); Previous version was 10 milliseconds instead of 10 microseconds. Was this change intentional? If yes, it should be mentioned it in the commit message. > + > + return 0; > +} > + > static int ad9467_probe(struct spi_device *spi) > { > const struct ad9467_chip_info *info; > @@ -408,18 +424,9 @@ static int ad9467_probe(struct spi_device *spi) > if (IS_ERR(st->pwrdown_gpio)) > return PTR_ERR(st->pwrdown_gpio); > > - st->reset_gpio =3D devm_gpiod_get_optional(&spi->dev, "reset", > - GPIOD_OUT_LOW); > - if (IS_ERR(st->reset_gpio)) > - return PTR_ERR(st->reset_gpio); > - > - if (st->reset_gpio) { > - udelay(1); > - ret =3D gpiod_direction_output(st->reset_gpio, 1); > - if (ret) > - return ret; > - mdelay(10); > - } > + ret =3D ad9467_reset(&spi->dev); > + if (ret) > + return ret; > > conv->chip_info =3D &info->axi_adc_info; > > > -- > 2.42.1 > >