Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp3657436rwb; Mon, 5 Sep 2022 16:17:11 -0700 (PDT) X-Google-Smtp-Source: AA6agR7oP/EhOvvTdXwCOWfA6PWfRk3A9nehXA2EusBiK4EmIpRk4duOdkHbdZAlEddXkr61iwoA X-Received: by 2002:a17:906:cc5d:b0:73f:e0cd:9e64 with SMTP id mm29-20020a170906cc5d00b0073fe0cd9e64mr32601771ejb.536.1662419831255; Mon, 05 Sep 2022 16:17:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662419831; cv=none; d=google.com; s=arc-20160816; b=ylIyCCV1SZqZIzYGQMWX4wJ+qaPwEe5tR4lHvF+ji4ky4b2INuVTH572wt6VrajRBO IG94AZWRM9jCbzfEG7b4vemIyzEsdvGzo3bj+s3exieozyM7M8gvF77Yb8PvVsaO3BgQ tYb96DHaCf8k1sDhPAkCNyUE+7WQeg8OIqBEHeELiQiGg/efAOZADsx5YDH2/1eagCPm 91wmeTKvT3sT7OlwSSBbi9ourJg0Q2Y1c//WUyWYWF4q5CS45uKMTPMPVoDC6ALTTfae c8pXWWEHyE43peUwW9vsm10gnVadBcDxHTNbx0o/zmygcojjlpkAunLAPDa6YC4ii++Y j/QA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=fPdbTBGP4hPAYzQjZaXxhuSQ6SSygH1y0WHZVZtGiu4=; b=wHR9LCXgUMJYr4oMPZ5Q//OYpN0G+uFe6653650/bS3S+N+5G/x2OR2uR+JdqIdFQg OqkvvW5t054ACRWXGuavT2kth+A/g6OUEBzAPuoVAohmXSkp1YIBkAhZxeXVRjk/IfG5 raS3FcRwAGzxvYyM3Gq/OOSWvZfJ+p74Roucof+fZZJJxr0HXU5zv3aPiOJCBqw/eT3n v4z2UwujBu2uU066yT8xclaAX3G+n687FNcfc1JvY4+oSvUQ57sHp0q+eVhICt5CW+i7 VPfcsGidG3dKCWOeV2/ebvWJ9Bwn2e/1So20n+cCOuoI2TXTDOT8bHBfppvjzj5q6qsi Erjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cRSoeEfI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m2-20020a056402430200b004478be1775esi9371509edc.341.2022.09.05.16.16.46; Mon, 05 Sep 2022 16:17:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cRSoeEfI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232667AbiIEXKb (ORCPT + 99 others); Mon, 5 Sep 2022 19:10:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232650AbiIEXKW (ORCPT ); Mon, 5 Sep 2022 19:10:22 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25E68183B3; Mon, 5 Sep 2022 16:10:16 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id D1525B815E6; Mon, 5 Sep 2022 23:10:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 323CBC433D7; Mon, 5 Sep 2022 23:10:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1662419413; bh=QhxqwrmKqk3hcDpE+kAWZJMWXWXiMx7OLmYa5+ea15I=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=cRSoeEfIVpvF6cCwlub3pnSJQf8zKCY4aEUPtHMtOkNaxfZe1+RUfK+stOROQ5pnl 7FbU956qU800+Jb6U6hwdOBoxO4x2FzlbVVVUaZEp0hQquPlSpxbMl7gPJHmGlip/q WXeDk2lh/TK49oBj/AAQP6Dst1Z5bl84IrLyRgMJAafIN0kMLxsIsEAjQNvYyihGG9 h4xRjXdkiTaHf2hIJ2Yatpca7TxPs6KBGxO+xPjerqLTUmJvu4k28lZ30772rihPEH I7n720bv3M7ihVFZNddbLANnIMiG1BrKlgvb+eKgjpWzR8KT6CpP2IYFa+iRtTPNF6 YocV+oaaQMIFA== Received: by pali.im (Postfix) id 400A37D7; Tue, 6 Sep 2022 01:10:10 +0200 (CEST) Date: Tue, 6 Sep 2022 01:10:10 +0200 From: Pali =?utf-8?B?Um9ow6Fy?= To: Dmitry Torokhov Cc: Thierry Reding , Mark Brown , Matti Vaittinen , Lorenzo Pieralisi , Claudiu Beznea , Liam Girdwood , Wim Van Sebroeck , Greg Kroah-Hartman , Guenter Roeck , Miquel Raynal , Linus Walleij , Felipe Balbi , Alexandre Belloni , Krzysztof =?utf-8?Q?Wilczy=C5=84ski?= , Vignesh Raghavendra , Daniel Vetter , Thomas Petazzoni , Alexandre Torgue , Marc Zyngier , Richard Weinberger , David Airlie , Nicolas Ferre , Alyssa Rosenzweig , Bartosz Golaszewski , Jonathan Hunter , Rob Herring , Maxime Coquelin , Bjorn Helgaas , linux-watchdog@vger.kernel.org, linux-usb@vger.kernel.org, linux-gpio@vger.kernel.org, linux-pci@vger.kernel.org, linux-tegra@vger.kernel.org, linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v1 06/11] PCI: aardvark: switch to using devm_gpiod_get_optional() Message-ID: <20220905231010.ojl4i4ph27qtebiy@pali> References: <20220903-gpiod_get_from_of_node-remove-v1-0-b29adfb27a6c@gmail.com> <20220903-gpiod_get_from_of_node-remove-v1-6-b29adfb27a6c@gmail.com> <20220905070046.46nlhczkck2ufr4x@pali> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: NeoMutt/20180716 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Monday 05 September 2022 15:54:53 Dmitry Torokhov wrote: > On Mon, Sep 05, 2022 at 09:00:46AM +0200, Pali Rohár wrote: > > On Sunday 04 September 2022 23:30:58 Dmitry Torokhov wrote: > > > I would like to stop exporting OF-specific devm_gpiod_get_from_of_node() > > > so that gpiolib can be cleaned a bit, so let's switch to the generic > > > device property API. > > > > > > I believe that the only reason the driver, instead of the standard > > > devm_gpiod_get_optional(), used devm_gpiod_get_from_of_node() is > > > because it wanted to set up a pretty consumer name for the GPIO, > > > > IIRC consumer name is not used at all. > > > > The reason was to specify full name of DTS property, for easier > > identification of the code. DTS property is "reset-gpios" but API > > specify only "reset". > > I see. Do you want me to reset the patch with updated desctiption as to > the reason devm_gpiod_get_from_of_node() was used? I think it is fine. So add my: Acked-by: Pali Rohár Anyway as another improvement for future I would suggest some API function with _optional_ logic, so it could be used for more PCIe controller drivers (e.g. also tegra) without need to reimplement -ENOENT handling. It is really strange if for acquiring same PERST# line via GPIO ("reset-gpios" DT property) are used more API functions in different PCIe drivers. > > > > > and we now have a special API for that. > > > > > > Signed-off-by: Dmitry Torokhov > > > > > > diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c > > > index 4834198cc86b..4a8a4a8522cb 100644 > > > --- a/drivers/pci/controller/pci-aardvark.c > > > +++ b/drivers/pci/controller/pci-aardvark.c > > > @@ -1856,20 +1856,19 @@ static int advk_pcie_probe(struct platform_device *pdev) > > > return ret; > > > } > > > > > > - pcie->reset_gpio = devm_gpiod_get_from_of_node(dev, dev->of_node, > > > - "reset-gpios", 0, > > > - GPIOD_OUT_LOW, > > > - "pcie1-reset"); > > > + pcie->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW); > > > ret = PTR_ERR_OR_ZERO(pcie->reset_gpio); > > > if (ret) { > > > - if (ret == -ENOENT) { > > > - pcie->reset_gpio = NULL; > > > - } else { > > > - if (ret != -EPROBE_DEFER) > > > - dev_err(dev, "Failed to get reset-gpio: %i\n", > > > - ret); > > > - return ret; > > > - } > > > + if (ret != -EPROBE_DEFER) > > > + dev_err(dev, "Failed to get reset-gpio: %i\n", > > > + ret); > > > + return ret; > > > + } > > > + > > > + ret = gpiod_set_consumer_name(pcie->reset_gpio, "pcie1-reset"); > > > + if (ret) { > > > + dev_err(dev, "Failed to set reset gpio name: %d\n", ret); > > > + return ret; > > > } > > > > > > ret = of_pci_get_max_link_speed(dev->of_node); > > > > > > -- > > > b4 0.10.0-dev-fc921 > > Thanks. > > -- > Dmitry