linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lorenzo Pieralisi <lpieralisi@kernel.org>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: "Shawn Guo" <shawn.guo@linaro.org>,
	"Thomas Petazzoni" <thomas.petazzoni@bootlin.com>,
	"Pali Rohár" <pali@kernel.org>,
	"Bjorn Helgaas" <bhelgaas@google.com>,
	"Rob Herring" <robh@kernel.org>,
	"Krzysztof Wilczyński" <kw@linux.com>,
	"Linus Walleij" <linus.walleij@linaro.org>,
	"Bartosz Golaszewski" <brgl@bgdev.pl>,
	linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] PCI: histb: switch to using gpiod API
Date: Fri, 11 Nov 2022 16:01:15 +0100	[thread overview]
Message-ID: <Y25juwnlU+ujvue9@lpieralisi> (raw)
In-Reply-To: <20220906204301.3736813-1-dmitry.torokhov@gmail.com>

On Tue, Sep 06, 2022 at 01:43:00PM -0700, Dmitry Torokhov wrote:
> This patch switches the driver away from legacy gpio/of_gpio API to
> gpiod API, and removes use of of_get_named_gpio_flags() which I want to
> make private to gpiolib.
> 
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

Should I pick this up ? On patch (2/2) I am not sure we reached
a consensus - please let me know.

Thanks,
Lorenzo

> ---
>  drivers/pci/controller/dwc/pcie-histb.c | 39 ++++++++++++-------------
>  1 file changed, 19 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/pci/controller/dwc/pcie-histb.c b/drivers/pci/controller/dwc/pcie-histb.c
> index e2b80f10030d..43c27812dd6d 100644
> --- a/drivers/pci/controller/dwc/pcie-histb.c
> +++ b/drivers/pci/controller/dwc/pcie-histb.c
> @@ -10,11 +10,11 @@
>  
>  #include <linux/clk.h>
>  #include <linux/delay.h>
> +#include <linux/gpio/consumer.h>
>  #include <linux/interrupt.h>
>  #include <linux/kernel.h>
>  #include <linux/module.h>
>  #include <linux/of.h>
> -#include <linux/of_gpio.h>
>  #include <linux/pci.h>
>  #include <linux/phy/phy.h>
>  #include <linux/platform_device.h>
> @@ -60,7 +60,7 @@ struct histb_pcie {
>  	struct reset_control *sys_reset;
>  	struct reset_control *bus_reset;
>  	void __iomem *ctrl;
> -	int reset_gpio;
> +	struct gpio_desc *reset_gpio;
>  	struct regulator *vpcie;
>  };
>  
> @@ -212,8 +212,8 @@ static void histb_pcie_host_disable(struct histb_pcie *hipcie)
>  	clk_disable_unprepare(hipcie->sys_clk);
>  	clk_disable_unprepare(hipcie->bus_clk);
>  
> -	if (gpio_is_valid(hipcie->reset_gpio))
> -		gpio_set_value_cansleep(hipcie->reset_gpio, 0);
> +	if (hipcie->reset_gpio)
> +		gpiod_set_value_cansleep(hipcie->reset_gpio, 1);
>  
>  	if (hipcie->vpcie)
>  		regulator_disable(hipcie->vpcie);
> @@ -235,8 +235,8 @@ static int histb_pcie_host_enable(struct dw_pcie_rp *pp)
>  		}
>  	}
>  
> -	if (gpio_is_valid(hipcie->reset_gpio))
> -		gpio_set_value_cansleep(hipcie->reset_gpio, 1);
> +	if (hipcie->reset_gpio)
> +		gpiod_set_value_cansleep(hipcie->reset_gpio, 0);
>  
>  	ret = clk_prepare_enable(hipcie->bus_clk);
>  	if (ret) {
> @@ -298,10 +298,7 @@ static int histb_pcie_probe(struct platform_device *pdev)
>  	struct histb_pcie *hipcie;
>  	struct dw_pcie *pci;
>  	struct dw_pcie_rp *pp;
> -	struct device_node *np = pdev->dev.of_node;
>  	struct device *dev = &pdev->dev;
> -	enum of_gpio_flags of_flags;
> -	unsigned long flag = GPIOF_DIR_OUT;
>  	int ret;
>  
>  	hipcie = devm_kzalloc(dev, sizeof(*hipcie), GFP_KERNEL);
> @@ -336,17 +333,19 @@ static int histb_pcie_probe(struct platform_device *pdev)
>  		hipcie->vpcie = NULL;
>  	}
>  
> -	hipcie->reset_gpio = of_get_named_gpio_flags(np,
> -				"reset-gpios", 0, &of_flags);
> -	if (of_flags & OF_GPIO_ACTIVE_LOW)
> -		flag |= GPIOF_ACTIVE_LOW;
> -	if (gpio_is_valid(hipcie->reset_gpio)) {
> -		ret = devm_gpio_request_one(dev, hipcie->reset_gpio,
> -				flag, "PCIe device power control");
> -		if (ret) {
> -			dev_err(dev, "unable to request gpio\n");
> -			return ret;
> -		}
> +	hipcie->reset_gpio = devm_gpiod_get_optional(dev, "reset",
> +						     GPIOD_OUT_HIGH);
> +	ret = PTR_ERR_OR_ZERO(hipcie->reset_gpio);
> +	if (ret) {
> +		dev_err(dev, "unable to request reset gpio: %d\n", ret);
> +		return ret;
> +	}
> +
> +	ret = gpiod_set_consumer_name(hipcie->reset_gpio,
> +				      "PCIe device power control");
> +	if (ret) {
> +		dev_err(dev, "unable to set reset gpio name: %d\n", ret);
> +		return ret;
>  	}
>  
>  	hipcie->aux_clk = devm_clk_get(dev, "aux");
> -- 
> 2.37.2.789.g6183377224-goog
> 

  parent reply	other threads:[~2022-11-11 15:05 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-06 20:43 [PATCH 1/2] PCI: histb: switch to using gpiod API Dmitry Torokhov
2022-09-06 20:43 ` [PATCH 2/2] PCI: mvebu: " Dmitry Torokhov
2022-09-06 21:16   ` Pali Rohár
2022-09-06 21:26     ` Dmitry Torokhov
2022-09-06 21:40       ` Dmitry Torokhov
2022-09-06 21:42         ` Pali Rohár
2022-09-06 21:41       ` Pali Rohár
2022-09-06 21:52         ` Dmitry Torokhov
2022-09-06 22:09           ` Pali Rohár
2022-09-06 22:41             ` Dmitry Torokhov
2022-09-11 12:58               ` Pali Rohár
2022-09-14 10:35               ` Linus Walleij
2022-09-14 12:10                 ` Bartosz Golaszewski
2022-09-14 12:48                   ` Linus Walleij
2022-09-14 13:00                   ` Kent Gibson
2022-09-14 13:36                     ` Linus Walleij
2022-09-15  2:23                   ` Kent Gibson
2022-09-15  8:51                     ` Linus Walleij
2022-09-15  9:30                       ` Kent Gibson
2022-09-16  7:22                         ` Bartosz Golaszewski
2022-09-18 14:37                           ` Linus Walleij
2022-09-18 23:58                           ` Kent Gibson
2022-09-08  8:42     ` Linus Walleij
2022-09-07  4:11   ` kernel test robot
2022-09-09 20:10   ` kernel test robot
2022-09-06 21:08 ` [PATCH 1/2] PCI: histb: " Pali Rohár
2022-09-06 21:41   ` Dmitry Torokhov
2022-09-06 21:46     ` Pali Rohár
2022-09-08  8:37 ` Linus Walleij
2022-11-11 15:01 ` Lorenzo Pieralisi [this message]
2022-11-11 15:20   ` Dmitry Torokhov
2022-11-14 10:58 ` (subset) " Lorenzo Pieralisi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y25juwnlU+ujvue9@lpieralisi \
    --to=lpieralisi@kernel.org \
    --cc=bhelgaas@google.com \
    --cc=brgl@bgdev.pl \
    --cc=dmitry.torokhov@gmail.com \
    --cc=kw@linux.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=pali@kernel.org \
    --cc=robh@kernel.org \
    --cc=shawn.guo@linaro.org \
    --cc=thomas.petazzoni@bootlin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).