[v2] PCI: mvebu: switch to using gpiod API
Commit Message
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>
---
v2:
- free port->reset_name when reset GPIO is not found (Pali)
- remove stray tab (Pali)
I know Pali mentioned that there are pending changes to pci-mvebu, but I
do not see any movement there, so I wonder if we could get this one
applied so we can continue cleaning up gpiolib code.
Thanks!
drivers/pci/controller/pci-mvebu.c | 50 ++++++++++--------------------
1 file changed, 16 insertions(+), 34 deletions(-)
Comments
Hi Dmitry,
I love your patch! Yet something to improve:
[auto build test ERROR on helgaas-pci/next]
[also build test ERROR on helgaas-pci/for-linus linus/master v6.1-rc5 next-20221114]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Dmitry-Torokhov/PCI-mvebu-switch-to-using-gpiod-API/20221115-035019
base: https://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git next
patch link: https://lore.kernel.org/r/Y3KbhIi4ZsSO7%2BCl%40google.com
patch subject: [PATCH v2] PCI: mvebu: switch to using gpiod API
config: arm-defconfig
compiler: arm-linux-gnueabi-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/ee8de8ec5155d29f3f8e129dfaedd23b87b11a13
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Dmitry-Torokhov/PCI-mvebu-switch-to-using-gpiod-API/20221115-035019
git checkout ee8de8ec5155d29f3f8e129dfaedd23b87b11a13
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=arm SHELL=/bin/bash
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
All errors (new ones prefixed by >>):
drivers/pci/controller/pci-mvebu.c: In function 'mvebu_pcie_irq_handler':
>> drivers/pci/controller/pci-mvebu.c:1101:9: error: implicit declaration of function 'chained_irq_enter'; did you mean 'ct_irq_enter'? [-Werror=implicit-function-declaration]
1101 | chained_irq_enter(chip, desc);
| ^~~~~~~~~~~~~~~~~
| ct_irq_enter
>> drivers/pci/controller/pci-mvebu.c:1116:9: error: implicit declaration of function 'chained_irq_exit'; did you mean 'ct_irq_exit'? [-Werror=implicit-function-declaration]
1116 | chained_irq_exit(chip, desc);
| ^~~~~~~~~~~~~~~~
| ct_irq_exit
cc1: some warnings being treated as errors
vim +1101 drivers/pci/controller/pci-mvebu.c
ec075262648f39 Pali Rohár 2022-02-22 1092
ec075262648f39 Pali Rohár 2022-02-22 1093 static void mvebu_pcie_irq_handler(struct irq_desc *desc)
ec075262648f39 Pali Rohár 2022-02-22 1094 {
ec075262648f39 Pali Rohár 2022-02-22 1095 struct mvebu_pcie_port *port = irq_desc_get_handler_data(desc);
ec075262648f39 Pali Rohár 2022-02-22 1096 struct irq_chip *chip = irq_desc_get_chip(desc);
ec075262648f39 Pali Rohár 2022-02-22 1097 struct device *dev = &port->pcie->pdev->dev;
ec075262648f39 Pali Rohár 2022-02-22 1098 u32 cause, unmask, status;
ec075262648f39 Pali Rohár 2022-02-22 1099 int i;
ec075262648f39 Pali Rohár 2022-02-22 1100
ec075262648f39 Pali Rohár 2022-02-22 @1101 chained_irq_enter(chip, desc);
ec075262648f39 Pali Rohár 2022-02-22 1102
ec075262648f39 Pali Rohár 2022-02-22 1103 cause = mvebu_readl(port, PCIE_INT_CAUSE_OFF);
ec075262648f39 Pali Rohár 2022-02-22 1104 unmask = mvebu_readl(port, PCIE_INT_UNMASK_OFF);
ec075262648f39 Pali Rohár 2022-02-22 1105 status = cause & unmask;
ec075262648f39 Pali Rohár 2022-02-22 1106
ec075262648f39 Pali Rohár 2022-02-22 1107 /* Process legacy INTx interrupts */
ec075262648f39 Pali Rohár 2022-02-22 1108 for (i = 0; i < PCI_NUM_INTX; i++) {
ec075262648f39 Pali Rohár 2022-02-22 1109 if (!(status & PCIE_INT_INTX(i)))
ec075262648f39 Pali Rohár 2022-02-22 1110 continue;
ec075262648f39 Pali Rohár 2022-02-22 1111
ec075262648f39 Pali Rohár 2022-02-22 1112 if (generic_handle_domain_irq(port->intx_irq_domain, i) == -EINVAL)
ec075262648f39 Pali Rohár 2022-02-22 1113 dev_err_ratelimited(dev, "unexpected INT%c IRQ\n", (char)i+'A');
ec075262648f39 Pali Rohár 2022-02-22 1114 }
ec075262648f39 Pali Rohár 2022-02-22 1115
ec075262648f39 Pali Rohár 2022-02-22 @1116 chained_irq_exit(chip, desc);
ec075262648f39 Pali Rohár 2022-02-22 1117 }
ec075262648f39 Pali Rohár 2022-02-22 1118
Hi Dmitry,
I love your patch! Yet something to improve:
[auto build test ERROR on helgaas-pci/next]
[also build test ERROR on helgaas-pci/for-linus linus/master v6.1-rc5 next-20221115]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Dmitry-Torokhov/PCI-mvebu-switch-to-using-gpiod-API/20221115-035019
base: https://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git next
patch link: https://lore.kernel.org/r/Y3KbhIi4ZsSO7%2BCl%40google.com
patch subject: [PATCH v2] PCI: mvebu: switch to using gpiod API
config: arm-multi_v5_defconfig
compiler: clang version 16.0.0 (https://github.com/llvm/llvm-project 463da45892e2d2a262277b91b96f5f8c05dc25d0)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install arm cross compiling tool for clang build
# apt-get install binutils-arm-linux-gnueabi
# https://github.com/intel-lab-lkp/linux/commit/ee8de8ec5155d29f3f8e129dfaedd23b87b11a13
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Dmitry-Torokhov/PCI-mvebu-switch-to-using-gpiod-API/20221115-035019
git checkout ee8de8ec5155d29f3f8e129dfaedd23b87b11a13
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=arm SHELL=/bin/bash
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
All errors (new ones prefixed by >>):
>> drivers/pci/controller/pci-mvebu.c:1101:2: error: call to undeclared function 'chained_irq_enter'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
chained_irq_enter(chip, desc);
^
>> drivers/pci/controller/pci-mvebu.c:1116:2: error: call to undeclared function 'chained_irq_exit'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
chained_irq_exit(chip, desc);
^
2 errors generated.
vim +/chained_irq_enter +1101 drivers/pci/controller/pci-mvebu.c
ec075262648f396 Pali Rohár 2022-02-22 1092
ec075262648f396 Pali Rohár 2022-02-22 1093 static void mvebu_pcie_irq_handler(struct irq_desc *desc)
ec075262648f396 Pali Rohár 2022-02-22 1094 {
ec075262648f396 Pali Rohár 2022-02-22 1095 struct mvebu_pcie_port *port = irq_desc_get_handler_data(desc);
ec075262648f396 Pali Rohár 2022-02-22 1096 struct irq_chip *chip = irq_desc_get_chip(desc);
ec075262648f396 Pali Rohár 2022-02-22 1097 struct device *dev = &port->pcie->pdev->dev;
ec075262648f396 Pali Rohár 2022-02-22 1098 u32 cause, unmask, status;
ec075262648f396 Pali Rohár 2022-02-22 1099 int i;
ec075262648f396 Pali Rohár 2022-02-22 1100
ec075262648f396 Pali Rohár 2022-02-22 @1101 chained_irq_enter(chip, desc);
ec075262648f396 Pali Rohár 2022-02-22 1102
ec075262648f396 Pali Rohár 2022-02-22 1103 cause = mvebu_readl(port, PCIE_INT_CAUSE_OFF);
ec075262648f396 Pali Rohár 2022-02-22 1104 unmask = mvebu_readl(port, PCIE_INT_UNMASK_OFF);
ec075262648f396 Pali Rohár 2022-02-22 1105 status = cause & unmask;
ec075262648f396 Pali Rohár 2022-02-22 1106
ec075262648f396 Pali Rohár 2022-02-22 1107 /* Process legacy INTx interrupts */
ec075262648f396 Pali Rohár 2022-02-22 1108 for (i = 0; i < PCI_NUM_INTX; i++) {
ec075262648f396 Pali Rohár 2022-02-22 1109 if (!(status & PCIE_INT_INTX(i)))
ec075262648f396 Pali Rohár 2022-02-22 1110 continue;
ec075262648f396 Pali Rohár 2022-02-22 1111
ec075262648f396 Pali Rohár 2022-02-22 1112 if (generic_handle_domain_irq(port->intx_irq_domain, i) == -EINVAL)
ec075262648f396 Pali Rohár 2022-02-22 1113 dev_err_ratelimited(dev, "unexpected INT%c IRQ\n", (char)i+'A');
ec075262648f396 Pali Rohár 2022-02-22 1114 }
ec075262648f396 Pali Rohár 2022-02-22 1115
ec075262648f396 Pali Rohár 2022-02-22 @1116 chained_irq_exit(chip, desc);
ec075262648f396 Pali Rohár 2022-02-22 1117 }
ec075262648f396 Pali Rohár 2022-02-22 1118
@@ -11,7 +11,7 @@
#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/mbus.h>
@@ -19,7 +19,6 @@
#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 +1261,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 +1326,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,