From: Bjorn Helgaas <helgaas@kernel.org>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: "Bjorn Helgaas" <bhelgaas@google.com>,
"Thomas Petazzoni" <thomas.petazzoni@bootlin.com>,
"Lorenzo Pieralisi" <lpieralisi@kernel.org>,
"Pali Rohár" <pali@kernel.org>, "Rob Herring" <robh@kernel.org>,
"Krzysztof Wilczyński" <kw@linux.com>,
linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] PCI: mvebu: switch to using gpiod API
Date: Wed, 7 Dec 2022 16:08:50 -0600 [thread overview]
Message-ID: <20221207220850.GA1479029@bhelgaas> (raw)
In-Reply-To: <Y5EAft42YiT66mVj@google.com>
On Wed, Dec 07, 2022 at 01:07:10PM -0800, 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>
Applied to pci/ctrl/mvebu for v6.2, thanks, Dmitry!
> ---
>
> v3:
> - add #include <linux/irqchip/chained_irq.h> to avoid compile errors.
> This was previously included indirectly via linux/of_gpio.h ->
> linux/gpio/driver.h
>
> v2:
> - free port->reset_name when reset GPIO is not found (Pali)
> - remove stray tab (Pali)
>
> This is the last user of of_get_named_gpio_flags() in the "next" tree.
>
> Thanks!
>
> drivers/pci/controller/pci-mvebu.c | 51 ++++++++++--------------------
> 1 file changed, 17 insertions(+), 34 deletions(-)
>
> diff --git a/drivers/pci/controller/pci-mvebu.c b/drivers/pci/controller/pci-mvebu.c
> index 73db99035c2b..600964ba174c 100644
> --- a/drivers/pci/controller/pci-mvebu.c
> +++ b/drivers/pci/controller/pci-mvebu.c
> @@ -11,15 +11,15 @@
> #include <linux/bitfield.h>
> #include <linux/clk.h>
> #include <linux/delay.h>
> -#include <linux/gpio.h>
> +#include <linux/gpio/consumer.h>
> #include <linux/init.h>
> #include <linux/irqdomain.h>
> +#include <linux/irqchip/chained_irq.h>
> #include <linux/mbus.h>
> #include <linux/slab.h>
> #include <linux/platform_device.h>
> #include <linux/of_address.h>
> #include <linux/of_irq.h>
> -#include <linux/of_gpio.h>
> #include <linux/of_pci.h>
> #include <linux/of_platform.h>
>
> @@ -1262,9 +1262,8 @@ static int mvebu_pcie_parse_port(struct mvebu_pcie *pcie,
> struct mvebu_pcie_port *port, struct device_node *child)
> {
> struct device *dev = &pcie->pdev->dev;
> - enum of_gpio_flags flags;
> u32 slot_power_limit;
> - int reset_gpio, ret;
> + int ret;
> u32 num_lanes;
>
> port->pcie = pcie;
> @@ -1328,40 +1327,24 @@ static int mvebu_pcie_parse_port(struct mvebu_pcie *pcie,
> port->name, child);
> }
>
> - reset_gpio = of_get_named_gpio_flags(child, "reset-gpios", 0, &flags);
> - if (reset_gpio == -EPROBE_DEFER) {
> - ret = reset_gpio;
> + port->reset_name = devm_kasprintf(dev, GFP_KERNEL, "%s-reset",
> + port->name);
> + if (!port->reset_name) {
> + ret = -ENOMEM;
> goto err;
> }
>
> - if (gpio_is_valid(reset_gpio)) {
> - unsigned long gpio_flags;
> -
> - port->reset_name = devm_kasprintf(dev, GFP_KERNEL, "%s-reset",
> - port->name);
> - if (!port->reset_name) {
> - ret = -ENOMEM;
> + port->reset_gpio = devm_fwnode_gpiod_get(dev, of_fwnode_handle(child),
> + "reset", GPIOD_OUT_HIGH,
> + port->name);
> + ret = PTR_ERR_OR_ZERO(port->reset_gpio);
> + if (ret) {
> + if (ret != -ENOENT)
> goto err;
> - }
> -
> - if (flags & OF_GPIO_ACTIVE_LOW) {
> - dev_info(dev, "%pOF: reset gpio is active low\n",
> - child);
> - gpio_flags = GPIOF_ACTIVE_LOW |
> - GPIOF_OUT_INIT_LOW;
> - } else {
> - gpio_flags = GPIOF_OUT_INIT_HIGH;
> - }
> -
> - ret = devm_gpio_request_one(dev, reset_gpio, gpio_flags,
> - port->reset_name);
> - if (ret) {
> - if (ret == -EPROBE_DEFER)
> - goto err;
> - goto skip;
> - }
> -
> - port->reset_gpio = gpio_to_desc(reset_gpio);
> + /* reset gpio is optional */
> + port->reset_gpio = NULL;
> + devm_kfree(dev, port->reset_name);
> + port->reset_name = NULL;
> }
>
> slot_power_limit = of_pci_get_slot_power_limit(child,
> --
> 2.39.0.rc0.267.gcb52ba06e7-goog
>
>
> --
> Dmitry
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
prev parent reply other threads:[~2022-12-07 22:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-07 21:07 [PATCH v3] PCI: mvebu: switch to using gpiod API Dmitry Torokhov
2022-12-07 22:08 ` Bjorn Helgaas [this message]
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=20221207220850.GA1479029@bhelgaas \
--to=helgaas@kernel.org \
--cc=bhelgaas@google.com \
--cc=dmitry.torokhov@gmail.com \
--cc=kw@linux.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lpieralisi@kernel.org \
--cc=pali@kernel.org \
--cc=robh@kernel.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).