linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 00/13] gpiolib: Two new helpers and way toward fwnode
@ 2022-03-29 15:29 Andy Shevchenko
  2022-03-29 15:29 ` [PATCH v2 01/13] gpiolib: Introduce for_each_gpiochip_node() loop helper Andy Shevchenko
                   ` (12 more replies)
  0 siblings, 13 replies; 31+ messages in thread
From: Andy Shevchenko @ 2022-03-29 15:29 UTC (permalink / raw)
  To: Qianggui Song, Andy Shevchenko, Krzysztof Kozlowski,
	Fabien Dessenne, linux-gpio, linux-arm-kernel, linux-amlogic,
	linux-kernel, openbmc, linux-renesas-soc, linux-samsung-soc,
	linux-stm32
  Cc: Linus Walleij, Neil Armstrong, Kevin Hilman, Jerome Brunet,
	Martin Blumenstingl, Andrew Lunn, Gregory Clement,
	Sebastian Hesselbarth, Avi Fishman, Tomer Maimon, Tali Perry,
	Patrick Venture, Nancy Yuen, Benjamin Fair, Geert Uytterhoeven,
	Tomasz Figa, Sylwester Nawrocki, Alim Akhtar, Maxime Coquelin,
	Alexandre Torgue, Bartosz Golaszewski, Philipp Zabel

This is a spin-off of the previous work of switching GPIO library
to use fwnode instead of of_node. Here we introduce a couple of
a new macro helpers, which allows to switch some of the drivers
to use fwnode and partially fwnode APIs.

Bart, Linus, I can take it thru my tree with an immutable branch if
it's the way you prefer, otherwise please suggest on how to proceed.

Changelog v2:
- properly based, so kbuild bot may test it (LKP)
- fixed typo in the macro (Geert)
- split to two macro helpers and rename the gpiochip_count()
- tagged one of stm32 and one of meson patches (Fabien, Neil)
- unified previously standalone armada patch
- due to above rewrote the armada patch from v1 completely (Sergey)
- added a lot of a new patches
- compile tested all of them on x86

Andy Shevchenko (13):
  gpiolib: Introduce for_each_gpiochip_node() loop helper
  gpiolib: Introduce gpiochip_node_count() helper
  pinctrl: stm32: Replace custom code by gpiochip_node_count() call
  pinctrl: stm32: Switch to use for_each_gpiochip_node() helper
  pinctrl: samsung: Switch to use for_each_gpiochip_node() helper
  pinctrl: renesas: rza1: Replace custom code by gpiochip_node_count()
    call
  pinctrl: renesas: rza1: Switch to use for_each_gpiochip_node() helper
  pinctrl: npcm7xx: Switch to use for_each_gpiochip_node() helper
  pinctrl: meson: Rename REG_* to MREG_*
  pinctrl: meson: Enable COMPILE_TEST
  pinctrl: meson: Replace custom code by gpiochip_node_count() call
  pinctrl: armada-37xx: Switch to use fwnode instead of of_node
  pinctrl: armada-37xx: Reuse GPIO fwnode in
    armada_37xx_irqchip_register()

 drivers/pinctrl/meson/Kconfig               |   2 +-
 drivers/pinctrl/meson/pinctrl-meson.c       |  52 ++++----
 drivers/pinctrl/meson/pinctrl-meson.h       |  24 ++--
 drivers/pinctrl/mvebu/pinctrl-armada-37xx.c |  34 ++---
 drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c   | 141 +++++++++-----------
 drivers/pinctrl/renesas/pinctrl-rza1.c      |  39 ++----
 drivers/pinctrl/samsung/pinctrl-samsung.c   |  30 ++---
 drivers/pinctrl/samsung/pinctrl-samsung.h   |   2 +-
 drivers/pinctrl/stm32/pinctrl-stm32.c       |  80 +++++------
 include/linux/gpio/driver.h                 |  19 ++-
 10 files changed, 187 insertions(+), 236 deletions(-)

-- 
2.35.1


^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH v2 01/13] gpiolib: Introduce for_each_gpiochip_node() loop helper
  2022-03-29 15:29 [PATCH v2 00/13] gpiolib: Two new helpers and way toward fwnode Andy Shevchenko
@ 2022-03-29 15:29 ` Andy Shevchenko
  2022-03-30 10:00   ` Geert Uytterhoeven
  2022-03-29 15:29 ` [PATCH v2 02/13] gpiolib: Introduce gpiochip_node_count() helper Andy Shevchenko
                   ` (11 subsequent siblings)
  12 siblings, 1 reply; 31+ messages in thread
From: Andy Shevchenko @ 2022-03-29 15:29 UTC (permalink / raw)
  To: Qianggui Song, Andy Shevchenko, Krzysztof Kozlowski,
	Fabien Dessenne, linux-gpio, linux-arm-kernel, linux-amlogic,
	linux-kernel, openbmc, linux-renesas-soc, linux-samsung-soc,
	linux-stm32
  Cc: Linus Walleij, Neil Armstrong, Kevin Hilman, Jerome Brunet,
	Martin Blumenstingl, Andrew Lunn, Gregory Clement,
	Sebastian Hesselbarth, Avi Fishman, Tomer Maimon, Tali Perry,
	Patrick Venture, Nancy Yuen, Benjamin Fair, Geert Uytterhoeven,
	Tomasz Figa, Sylwester Nawrocki, Alim Akhtar, Maxime Coquelin,
	Alexandre Torgue, Bartosz Golaszewski, Philipp Zabel

Introduce for_each_gpiochip_node() loop helper which iterates over
the GPIO controller child nodes of a given device.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 include/linux/gpio/driver.h | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h
index be2fc9b15cf3..e6b9c17614ef 100644
--- a/include/linux/gpio/driver.h
+++ b/include/linux/gpio/driver.h
@@ -3,13 +3,14 @@
 #define __LINUX_GPIO_DRIVER_H
 
 #include <linux/device.h>
-#include <linux/types.h>
 #include <linux/irq.h>
 #include <linux/irqchip/chained_irq.h>
 #include <linux/irqdomain.h>
 #include <linux/lockdep.h>
 #include <linux/pinctrl/pinctrl.h>
 #include <linux/pinctrl/pinconf-generic.h>
+#include <linux/property.h>
+#include <linux/types.h>
 
 struct gpio_desc;
 struct seq_file;
@@ -750,4 +751,8 @@ static inline void gpiochip_unlock_as_irq(struct gpio_chip *gc,
 }
 #endif /* CONFIG_GPIOLIB */
 
+#define for_each_gpiochip_node(dev, child)					\
+	device_for_each_child_node(dev, child)					\
+		if (!fwnode_property_present(child, "gpio-controller")) {} else
+
 #endif /* __LINUX_GPIO_DRIVER_H */
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH v2 02/13] gpiolib: Introduce gpiochip_node_count() helper
  2022-03-29 15:29 [PATCH v2 00/13] gpiolib: Two new helpers and way toward fwnode Andy Shevchenko
  2022-03-29 15:29 ` [PATCH v2 01/13] gpiolib: Introduce for_each_gpiochip_node() loop helper Andy Shevchenko
@ 2022-03-29 15:29 ` Andy Shevchenko
  2022-03-30 10:02   ` Geert Uytterhoeven
  2022-03-29 15:29 ` [PATCH v2 03/13] pinctrl: stm32: Replace custom code by gpiochip_node_count() call Andy Shevchenko
                   ` (10 subsequent siblings)
  12 siblings, 1 reply; 31+ messages in thread
From: Andy Shevchenko @ 2022-03-29 15:29 UTC (permalink / raw)
  To: Qianggui Song, Andy Shevchenko, Krzysztof Kozlowski,
	Fabien Dessenne, linux-gpio, linux-arm-kernel, linux-amlogic,
	linux-kernel, openbmc, linux-renesas-soc, linux-samsung-soc,
	linux-stm32
  Cc: Linus Walleij, Neil Armstrong, Kevin Hilman, Jerome Brunet,
	Martin Blumenstingl, Andrew Lunn, Gregory Clement,
	Sebastian Hesselbarth, Avi Fishman, Tomer Maimon, Tali Perry,
	Patrick Venture, Nancy Yuen, Benjamin Fair, Geert Uytterhoeven,
	Tomasz Figa, Sylwester Nawrocki, Alim Akhtar, Maxime Coquelin,
	Alexandre Torgue, Bartosz Golaszewski, Philipp Zabel

The gpiochip_node_count() helper iterates over the device child nodes that
have the "gpio-controller" property set. It returns the number of such nodes
under a given device.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 include/linux/gpio/driver.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h
index e6b9c17614ef..bc2ea9f65022 100644
--- a/include/linux/gpio/driver.h
+++ b/include/linux/gpio/driver.h
@@ -755,4 +755,16 @@ static inline void gpiochip_unlock_as_irq(struct gpio_chip *gc,
 	device_for_each_child_node(dev, child)					\
 		if (!fwnode_property_present(child, "gpio-controller")) {} else
 
+static inline unsigned int gpiochip_node_count(struct device *dev)
+{
+	struct fwnode_handle *child;
+	unsigned int count;
+
+	count = 0;
+	for_each_gpiochip_node(dev, child)
+		count++;
+
+	return count;
+}
+
 #endif /* __LINUX_GPIO_DRIVER_H */
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH v2 03/13] pinctrl: stm32: Replace custom code by gpiochip_node_count() call
  2022-03-29 15:29 [PATCH v2 00/13] gpiolib: Two new helpers and way toward fwnode Andy Shevchenko
  2022-03-29 15:29 ` [PATCH v2 01/13] gpiolib: Introduce for_each_gpiochip_node() loop helper Andy Shevchenko
  2022-03-29 15:29 ` [PATCH v2 02/13] gpiolib: Introduce gpiochip_node_count() helper Andy Shevchenko
@ 2022-03-29 15:29 ` Andy Shevchenko
  2022-03-29 15:29 ` [PATCH v2 04/13] pinctrl: stm32: Switch to use for_each_gpiochip_node() helper Andy Shevchenko
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 31+ messages in thread
From: Andy Shevchenko @ 2022-03-29 15:29 UTC (permalink / raw)
  To: Qianggui Song, Andy Shevchenko, Krzysztof Kozlowski,
	Fabien Dessenne, linux-gpio, linux-arm-kernel, linux-amlogic,
	linux-kernel, openbmc, linux-renesas-soc, linux-samsung-soc,
	linux-stm32
  Cc: Linus Walleij, Neil Armstrong, Kevin Hilman, Jerome Brunet,
	Martin Blumenstingl, Andrew Lunn, Gregory Clement,
	Sebastian Hesselbarth, Avi Fishman, Tomer Maimon, Tali Perry,
	Patrick Venture, Nancy Yuen, Benjamin Fair, Geert Uytterhoeven,
	Tomasz Figa, Sylwester Nawrocki, Alim Akhtar, Maxime Coquelin,
	Alexandre Torgue, Bartosz Golaszewski, Philipp Zabel

Since we have generic function to count GPIO controller nodes
under a given device, there is no need to open code it. Replace
custom code by gpiochip_node_count() call.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Fabien Dessenne <fabien.dessenne@foss.st.com>
---
 drivers/pinctrl/stm32/pinctrl-stm32.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/pinctrl/stm32/pinctrl-stm32.c b/drivers/pinctrl/stm32/pinctrl-stm32.c
index 92348e09af28..4043a44211f0 100644
--- a/drivers/pinctrl/stm32/pinctrl-stm32.c
+++ b/drivers/pinctrl/stm32/pinctrl-stm32.c
@@ -1423,7 +1423,8 @@ int stm32_pctl_probe(struct platform_device *pdev)
 	struct device *dev = &pdev->dev;
 	struct stm32_pinctrl *pctl;
 	struct pinctrl_pin_desc *pins;
-	int i, ret, hwlock_id, banks = 0;
+	int i, ret, hwlock_id;
+	unsigned int banks;
 
 	if (!np)
 		return -EINVAL;
@@ -1513,10 +1514,7 @@ int stm32_pctl_probe(struct platform_device *pdev)
 		return PTR_ERR(pctl->pctl_dev);
 	}
 
-	for_each_available_child_of_node(np, child)
-		if (of_property_read_bool(child, "gpio-controller"))
-			banks++;
-
+	banks = gpiochip_node_count(dev);
 	if (!banks) {
 		dev_err(dev, "at least one GPIO bank is required\n");
 		return -EINVAL;
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH v2 04/13] pinctrl: stm32: Switch to use for_each_gpiochip_node() helper
  2022-03-29 15:29 [PATCH v2 00/13] gpiolib: Two new helpers and way toward fwnode Andy Shevchenko
                   ` (2 preceding siblings ...)
  2022-03-29 15:29 ` [PATCH v2 03/13] pinctrl: stm32: Replace custom code by gpiochip_node_count() call Andy Shevchenko
@ 2022-03-29 15:29 ` Andy Shevchenko
  2022-03-30 12:32   ` Fabien DESSENNE
  2022-03-29 15:29 ` [PATCH v2 05/13] pinctrl: samsung: " Andy Shevchenko
                   ` (8 subsequent siblings)
  12 siblings, 1 reply; 31+ messages in thread
From: Andy Shevchenko @ 2022-03-29 15:29 UTC (permalink / raw)
  To: Qianggui Song, Andy Shevchenko, Krzysztof Kozlowski,
	Fabien Dessenne, linux-gpio, linux-arm-kernel, linux-amlogic,
	linux-kernel, openbmc, linux-renesas-soc, linux-samsung-soc,
	linux-stm32
  Cc: Linus Walleij, Neil Armstrong, Kevin Hilman, Jerome Brunet,
	Martin Blumenstingl, Andrew Lunn, Gregory Clement,
	Sebastian Hesselbarth, Avi Fishman, Tomer Maimon, Tali Perry,
	Patrick Venture, Nancy Yuen, Benjamin Fair, Geert Uytterhoeven,
	Tomasz Figa, Sylwester Nawrocki, Alim Akhtar, Maxime Coquelin,
	Alexandre Torgue, Bartosz Golaszewski, Philipp Zabel

Switch the code to use for_each_gpiochip_node() helper.

While at it, in order to avoid additional churn in the future,
switch to fwnode APIs where it makes sense.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/pinctrl/stm32/pinctrl-stm32.c | 72 ++++++++++++---------------
 1 file changed, 33 insertions(+), 39 deletions(-)

diff --git a/drivers/pinctrl/stm32/pinctrl-stm32.c b/drivers/pinctrl/stm32/pinctrl-stm32.c
index 4043a44211f0..3e2f1e3a84be 100644
--- a/drivers/pinctrl/stm32/pinctrl-stm32.c
+++ b/drivers/pinctrl/stm32/pinctrl-stm32.c
@@ -24,6 +24,7 @@
 #include <linux/pinctrl/pinctrl.h>
 #include <linux/pinctrl/pinmux.h>
 #include <linux/platform_device.h>
+#include <linux/property.h>
 #include <linux/regmap.h>
 #include <linux/reset.h>
 #include <linux/slab.h>
@@ -1215,13 +1216,12 @@ static const struct pinconf_ops stm32_pconf_ops = {
 	.pin_config_dbg_show	= stm32_pconf_dbg_show,
 };
 
-static int stm32_gpiolib_register_bank(struct stm32_pinctrl *pctl,
-	struct device_node *np)
+static int stm32_gpiolib_register_bank(struct stm32_pinctrl *pctl, struct fwnode_handle *fwnode)
 {
 	struct stm32_gpio_bank *bank = &pctl->banks[pctl->nbanks];
 	int bank_ioport_nr;
 	struct pinctrl_gpio_range *range = &bank->range;
-	struct of_phandle_args args;
+	struct fwnode_reference_args args;
 	struct device *dev = pctl->dev;
 	struct resource res;
 	int npins = STM32_GPIO_PINS_PER_BANK;
@@ -1230,7 +1230,7 @@ static int stm32_gpiolib_register_bank(struct stm32_pinctrl *pctl,
 	if (!IS_ERR(bank->rstc))
 		reset_control_deassert(bank->rstc);
 
-	if (of_address_to_resource(np, 0, &res))
+	if (of_address_to_resource(to_of_node(fwnode), 0, &res))
 		return -ENODEV;
 
 	bank->base = devm_ioremap_resource(dev, &res);
@@ -1245,15 +1245,15 @@ static int stm32_gpiolib_register_bank(struct stm32_pinctrl *pctl,
 
 	bank->gpio_chip = stm32_gpio_template;
 
-	of_property_read_string(np, "st,bank-name", &bank->gpio_chip.label);
+	fwnode_property_read_string(fwnode, "st,bank-name", &bank->gpio_chip.label);
 
-	if (!of_parse_phandle_with_fixed_args(np, "gpio-ranges", 3, i, &args)) {
+	if (!fwnode_property_get_reference_args(fwnode, "gpio-ranges", NULL, 3, i, &args)) {
 		bank_nr = args.args[1] / STM32_GPIO_PINS_PER_BANK;
 		bank->gpio_chip.base = args.args[1];
 
 		/* get the last defined gpio line (offset + nb of pins) */
 		npins = args.args[0] + args.args[2];
-		while (!of_parse_phandle_with_fixed_args(np, "gpio-ranges", 3, ++i, &args))
+		while (!fwnode_property_get_reference_args(fwnode, "gpio-ranges", NULL, 3, ++i, &args))
 			npins = max(npins, (int)(args.args[0] + args.args[2]));
 	} else {
 		bank_nr = pctl->nbanks;
@@ -1268,20 +1268,20 @@ static int stm32_gpiolib_register_bank(struct stm32_pinctrl *pctl,
 				       &pctl->banks[bank_nr].range);
 	}
 
-	if (of_property_read_u32(np, "st,bank-ioport", &bank_ioport_nr))
+	if (fwnode_property_read_u32(fwnode, "st,bank-ioport", &bank_ioport_nr))
 		bank_ioport_nr = bank_nr;
 
 	bank->gpio_chip.base = bank_nr * STM32_GPIO_PINS_PER_BANK;
 
 	bank->gpio_chip.ngpio = npins;
-	bank->gpio_chip.of_node = np;
+	bank->gpio_chip.fwnode = fwnode;
 	bank->gpio_chip.parent = dev;
 	bank->bank_nr = bank_nr;
 	bank->bank_ioport_nr = bank_ioport_nr;
 	spin_lock_init(&bank->lock);
 
 	/* create irq hierarchical domain */
-	bank->fwnode = of_node_to_fwnode(np);
+	bank->fwnode = fwnode;
 
 	bank->domain = irq_domain_create_hierarchy(pctl->domain, 0,
 					STM32_GPIO_IRQ_LINE, bank->fwnode,
@@ -1418,7 +1418,7 @@ static int stm32_pctrl_create_pins_tab(struct stm32_pinctrl *pctl,
 int stm32_pctl_probe(struct platform_device *pdev)
 {
 	struct device_node *np = pdev->dev.of_node;
-	struct device_node *child;
+	struct fwnode_handle *child;
 	const struct of_device_id *match;
 	struct device *dev = &pdev->dev;
 	struct stm32_pinctrl *pctl;
@@ -1525,40 +1525,34 @@ int stm32_pctl_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	i = 0;
-	for_each_available_child_of_node(np, child) {
+	for_each_gpiochip_node(dev, child) {
 		struct stm32_gpio_bank *bank = &pctl->banks[i];
+		struct device_node *np = to_of_node(child);
 
-		if (of_property_read_bool(child, "gpio-controller")) {
-			bank->rstc = of_reset_control_get_exclusive(child,
-								    NULL);
-			if (PTR_ERR(bank->rstc) == -EPROBE_DEFER) {
-				of_node_put(child);
-				return -EPROBE_DEFER;
-			}
-
-			bank->clk = of_clk_get_by_name(child, NULL);
-			if (IS_ERR(bank->clk)) {
-				if (PTR_ERR(bank->clk) != -EPROBE_DEFER)
-					dev_err(dev,
-						"failed to get clk (%ld)\n",
-						PTR_ERR(bank->clk));
-				of_node_put(child);
-				return PTR_ERR(bank->clk);
-			}
-			i++;
+		bank->rstc = of_reset_control_get_exclusive(np, NULL);
+		if (PTR_ERR(bank->rstc) == -EPROBE_DEFER) {
+			fwnode_handle_put(child);
+			return -EPROBE_DEFER;
 		}
-	}
 
-	for_each_available_child_of_node(np, child) {
-		if (of_property_read_bool(child, "gpio-controller")) {
-			ret = stm32_gpiolib_register_bank(pctl, child);
-			if (ret) {
-				of_node_put(child);
-				return ret;
-			}
+		bank->clk = of_clk_get_by_name(np, NULL);
+		if (IS_ERR(bank->clk)) {
+			if (PTR_ERR(bank->clk) != -EPROBE_DEFER)
+				dev_err(dev, "failed to get clk (%ld)\n", PTR_ERR(bank->clk));
+			fwnode_handle_put(child);
+			return PTR_ERR(bank->clk);
+		}
+		i++;
+	}
 
-			pctl->nbanks++;
+	for_each_gpiochip_node(dev, child) {
+		ret = stm32_gpiolib_register_bank(pctl, child);
+		if (ret) {
+			fwnode_handle_put(child);
+			return ret;
 		}
+
+		pctl->nbanks++;
 	}
 
 	dev_info(dev, "Pinctrl STM32 initialized\n");
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH v2 05/13] pinctrl: samsung: Switch to use for_each_gpiochip_node() helper
  2022-03-29 15:29 [PATCH v2 00/13] gpiolib: Two new helpers and way toward fwnode Andy Shevchenko
                   ` (3 preceding siblings ...)
  2022-03-29 15:29 ` [PATCH v2 04/13] pinctrl: stm32: Switch to use for_each_gpiochip_node() helper Andy Shevchenko
@ 2022-03-29 15:29 ` Andy Shevchenko
  2022-03-29 15:29 ` [PATCH v2 06/13] pinctrl: renesas: rza1: Replace custom code by gpiochip_node_count() call Andy Shevchenko
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 31+ messages in thread
From: Andy Shevchenko @ 2022-03-29 15:29 UTC (permalink / raw)
  To: Qianggui Song, Andy Shevchenko, Krzysztof Kozlowski,
	Fabien Dessenne, linux-gpio, linux-arm-kernel, linux-amlogic,
	linux-kernel, openbmc, linux-renesas-soc, linux-samsung-soc,
	linux-stm32
  Cc: Linus Walleij, Neil Armstrong, Kevin Hilman, Jerome Brunet,
	Martin Blumenstingl, Andrew Lunn, Gregory Clement,
	Sebastian Hesselbarth, Avi Fishman, Tomer Maimon, Tali Perry,
	Patrick Venture, Nancy Yuen, Benjamin Fair, Geert Uytterhoeven,
	Tomasz Figa, Sylwester Nawrocki, Alim Akhtar, Maxime Coquelin,
	Alexandre Torgue, Bartosz Golaszewski, Philipp Zabel

Switch the code to use for_each_gpiochip_node() helper.

While at it, in order to avoid additional churn in the future,
switch to fwnode APIs where it makes sense.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/pinctrl/samsung/pinctrl-samsung.c | 30 +++++++++++------------
 drivers/pinctrl/samsung/pinctrl-samsung.h |  2 +-
 2 files changed, 15 insertions(+), 17 deletions(-)

diff --git a/drivers/pinctrl/samsung/pinctrl-samsung.c b/drivers/pinctrl/samsung/pinctrl-samsung.c
index 8eb423193680..8eb0aa1de595 100644
--- a/drivers/pinctrl/samsung/pinctrl-samsung.c
+++ b/drivers/pinctrl/samsung/pinctrl-samsung.c
@@ -18,6 +18,7 @@
 #include <linux/init.h>
 #include <linux/platform_device.h>
 #include <linux/io.h>
+#include <linux/property.h>
 #include <linux/slab.h>
 #include <linux/err.h>
 #include <linux/gpio/driver.h>
@@ -966,7 +967,7 @@ static int samsung_gpiolib_register(struct platform_device *pdev,
 		gc->base = bank->grange.base;
 		gc->ngpio = bank->nr_pins;
 		gc->parent = &pdev->dev;
-		gc->of_node = bank->of_node;
+		gc->fwnode = bank->fwnode;
 		gc->label = bank->name;
 
 		ret = devm_gpiochip_add_data(&pdev->dev, gc, bank);
@@ -1002,27 +1003,25 @@ samsung_pinctrl_get_soc_data_for_of_alias(struct platform_device *pdev)
 	return &(of_data->ctrl[id]);
 }
 
-static void samsung_banks_of_node_put(struct samsung_pinctrl_drv_data *d)
+static void samsung_banks_node_put(struct samsung_pinctrl_drv_data *d)
 {
 	struct samsung_pin_bank *bank;
 	unsigned int i;
 
 	bank = d->pin_banks;
 	for (i = 0; i < d->nr_banks; ++i, ++bank)
-		of_node_put(bank->of_node);
+		fwnode_handle_put(bank->fwnode);
 }
 
 /*
  * Iterate over all driver pin banks to find one matching the name of node,
  * skipping optional "-gpio" node suffix. When found, assign node to the bank.
  */
-static void samsung_banks_of_node_get(struct device *dev,
-				      struct samsung_pinctrl_drv_data *d,
-				      struct device_node *node)
+static void samsung_banks_node_get(struct device *dev, struct samsung_pinctrl_drv_data *d)
 {
 	const char *suffix = "-gpio-bank";
 	struct samsung_pin_bank *bank;
-	struct device_node *child;
+	struct fwnode_handle *child;
 	/* Pin bank names are up to 4 characters */
 	char node_name[20];
 	unsigned int i;
@@ -1038,17 +1037,17 @@ static void samsung_banks_of_node_get(struct device *dev,
 			continue;
 		}
 
-		for_each_child_of_node(node, child) {
-			if (!of_find_property(child, "gpio-controller", NULL))
-				continue;
-			if (of_node_name_eq(child, node_name))
+		for_each_gpiochip_node(dev, child) {
+			struct device_node *np = to_of_node(child);
+
+			if (of_node_name_eq(np, node_name))
 				break;
-			else if (of_node_name_eq(child, bank->name))
+			if (of_node_name_eq(np, bank->name))
 				break;
 		}
 
 		if (child)
-			bank->of_node = child;
+			bank->fwnode = child;
 		else
 			dev_warn(dev, "Missing node for bank %s - invalid DTB\n",
 				 bank->name);
@@ -1061,7 +1060,6 @@ static const struct samsung_pin_ctrl *
 samsung_pinctrl_get_soc_data(struct samsung_pinctrl_drv_data *d,
 			     struct platform_device *pdev)
 {
-	struct device_node *node = pdev->dev.of_node;
 	const struct samsung_pin_bank_data *bdata;
 	const struct samsung_pin_ctrl *ctrl;
 	struct samsung_pin_bank *bank;
@@ -1125,7 +1123,7 @@ samsung_pinctrl_get_soc_data(struct samsung_pinctrl_drv_data *d,
 	 */
 	d->virt_base = virt_base[0];
 
-	samsung_banks_of_node_get(&pdev->dev, d, node);
+	samsung_banks_node_get(&pdev->dev, d);
 
 	d->pin_base = pin_base;
 	pin_base += d->nr_pins;
@@ -1186,7 +1184,7 @@ static int samsung_pinctrl_probe(struct platform_device *pdev)
 err_unregister:
 	samsung_pinctrl_unregister(pdev, drvdata);
 err_put_banks:
-	samsung_banks_of_node_put(drvdata);
+	samsung_banks_node_put(drvdata);
 	return ret;
 }
 
diff --git a/drivers/pinctrl/samsung/pinctrl-samsung.h b/drivers/pinctrl/samsung/pinctrl-samsung.h
index 5b32d3f30fcd..fc6f5199c548 100644
--- a/drivers/pinctrl/samsung/pinctrl-samsung.h
+++ b/drivers/pinctrl/samsung/pinctrl-samsung.h
@@ -165,7 +165,7 @@ struct samsung_pin_bank {
 
 	u32		pin_base;
 	void		*soc_priv;
-	struct device_node *of_node;
+	struct fwnode_handle *fwnode;
 	struct samsung_pinctrl_drv_data *drvdata;
 	struct irq_domain *irq_domain;
 	struct gpio_chip gpio_chip;
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH v2 06/13] pinctrl: renesas: rza1: Replace custom code by gpiochip_node_count() call
  2022-03-29 15:29 [PATCH v2 00/13] gpiolib: Two new helpers and way toward fwnode Andy Shevchenko
                   ` (4 preceding siblings ...)
  2022-03-29 15:29 ` [PATCH v2 05/13] pinctrl: samsung: " Andy Shevchenko
@ 2022-03-29 15:29 ` Andy Shevchenko
  2022-03-30  9:51   ` Geert Uytterhoeven
  2022-03-29 15:29 ` [PATCH v2 07/13] pinctrl: renesas: rza1: Switch to use for_each_gpiochip_node() helper Andy Shevchenko
                   ` (6 subsequent siblings)
  12 siblings, 1 reply; 31+ messages in thread
From: Andy Shevchenko @ 2022-03-29 15:29 UTC (permalink / raw)
  To: Qianggui Song, Andy Shevchenko, Krzysztof Kozlowski,
	Fabien Dessenne, linux-gpio, linux-arm-kernel, linux-amlogic,
	linux-kernel, openbmc, linux-renesas-soc, linux-samsung-soc,
	linux-stm32
  Cc: Linus Walleij, Neil Armstrong, Kevin Hilman, Jerome Brunet,
	Martin Blumenstingl, Andrew Lunn, Gregory Clement,
	Sebastian Hesselbarth, Avi Fishman, Tomer Maimon, Tali Perry,
	Patrick Venture, Nancy Yuen, Benjamin Fair, Geert Uytterhoeven,
	Tomasz Figa, Sylwester Nawrocki, Alim Akhtar, Maxime Coquelin,
	Alexandre Torgue, Bartosz Golaszewski, Philipp Zabel

Since we have generic function to count GPIO controller nodes
under a given device, there is no need to open code it. Replace
custom code by gpiochip_node_count() call.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/pinctrl/renesas/pinctrl-rza1.c | 17 +----------------
 1 file changed, 1 insertion(+), 16 deletions(-)

diff --git a/drivers/pinctrl/renesas/pinctrl-rza1.c b/drivers/pinctrl/renesas/pinctrl-rza1.c
index 8bad121d2a4e..5075d5cebe8c 100644
--- a/drivers/pinctrl/renesas/pinctrl-rza1.c
+++ b/drivers/pinctrl/renesas/pinctrl-rza1.c
@@ -1154,21 +1154,6 @@ static const struct pinmux_ops rza1_pinmux_ops = {
  * RZ/A1 pin controller driver operations
  */
 
-static unsigned int rza1_count_gpio_chips(struct device_node *np)
-{
-	struct device_node *child;
-	unsigned int count = 0;
-
-	for_each_child_of_node(np, child) {
-		if (!of_property_read_bool(child, "gpio-controller"))
-			continue;
-
-		count++;
-	}
-
-	return count;
-}
-
 /**
  * rza1_parse_gpiochip() - parse and register a gpio chip and pin range
  *
@@ -1255,7 +1240,7 @@ static int rza1_gpio_register(struct rza1_pinctrl *rza1_pctl)
 	unsigned int i;
 	int ret;
 
-	ngpiochips = rza1_count_gpio_chips(np);
+	ngpiochips = gpiochip_node_count(rza1_pctl->dev);
 	if (ngpiochips == 0) {
 		dev_dbg(rza1_pctl->dev, "No gpiochip registered\n");
 		return 0;
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH v2 07/13] pinctrl: renesas: rza1: Switch to use for_each_gpiochip_node() helper
  2022-03-29 15:29 [PATCH v2 00/13] gpiolib: Two new helpers and way toward fwnode Andy Shevchenko
                   ` (5 preceding siblings ...)
  2022-03-29 15:29 ` [PATCH v2 06/13] pinctrl: renesas: rza1: Replace custom code by gpiochip_node_count() call Andy Shevchenko
@ 2022-03-29 15:29 ` Andy Shevchenko
  2022-03-30 10:00   ` Geert Uytterhoeven
  2022-03-29 15:29 ` [PATCH v2 08/13] pinctrl: npcm7xx: " Andy Shevchenko
                   ` (5 subsequent siblings)
  12 siblings, 1 reply; 31+ messages in thread
From: Andy Shevchenko @ 2022-03-29 15:29 UTC (permalink / raw)
  To: Qianggui Song, Andy Shevchenko, Krzysztof Kozlowski,
	Fabien Dessenne, linux-gpio, linux-arm-kernel, linux-amlogic,
	linux-kernel, openbmc, linux-renesas-soc, linux-samsung-soc,
	linux-stm32
  Cc: Linus Walleij, Neil Armstrong, Kevin Hilman, Jerome Brunet,
	Martin Blumenstingl, Andrew Lunn, Gregory Clement,
	Sebastian Hesselbarth, Avi Fishman, Tomer Maimon, Tali Perry,
	Patrick Venture, Nancy Yuen, Benjamin Fair, Geert Uytterhoeven,
	Tomasz Figa, Sylwester Nawrocki, Alim Akhtar, Maxime Coquelin,
	Alexandre Torgue, Bartosz Golaszewski, Philipp Zabel

Switch the code to use for_each_gpiochip_node() helper.

While at it, in order to avoid additional churn in the future,
switch to fwnode APIs where it makes sense.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/pinctrl/renesas/pinctrl-rza1.c | 22 +++++++++-------------
 1 file changed, 9 insertions(+), 13 deletions(-)

diff --git a/drivers/pinctrl/renesas/pinctrl-rza1.c b/drivers/pinctrl/renesas/pinctrl-rza1.c
index 5075d5cebe8c..74183f36567b 100644
--- a/drivers/pinctrl/renesas/pinctrl-rza1.c
+++ b/drivers/pinctrl/renesas/pinctrl-rza1.c
@@ -24,6 +24,7 @@
 #include <linux/pinctrl/pinconf-generic.h>
 #include <linux/pinctrl/pinctrl.h>
 #include <linux/pinctrl/pinmux.h>
+#include <linux/property.h>
 #include <linux/slab.h>
 
 #include "../core.h"
@@ -1166,17 +1167,17 @@ static const struct pinmux_ops rza1_pinmux_ops = {
  * @range: pin range to register to pinctrl core
  */
 static int rza1_parse_gpiochip(struct rza1_pinctrl *rza1_pctl,
-			       struct device_node *np,
+			       struct fwnode_handle *fwnode,
 			       struct gpio_chip *chip,
 			       struct pinctrl_gpio_range *range)
 {
 	const char *list_name = "gpio-ranges";
-	struct of_phandle_args of_args;
+	struct fwnode_reference_args of_args;
 	unsigned int gpioport;
 	u32 pinctrl_base;
 	int ret;
 
-	ret = of_parse_phandle_with_fixed_args(np, list_name, 3, 0, &of_args);
+	ret = fwnode_property_get_reference_args(fwnode, list_name, NULL, 3, 0, &of_args);
 	if (ret) {
 		dev_err(rza1_pctl->dev, "Unable to parse %s list property\n",
 			list_name);
@@ -1197,13 +1198,12 @@ static int rza1_parse_gpiochip(struct rza1_pinctrl *rza1_pctl,
 
 	*chip		= rza1_gpiochip_template;
 	chip->base	= -1;
-	chip->label	= devm_kasprintf(rza1_pctl->dev, GFP_KERNEL, "%pOFn",
-					 np);
+	chip->label	= devm_kasprintf(rza1_pctl->dev, GFP_KERNEL, "%pfw", fwnode);
 	if (!chip->label)
 		return -ENOMEM;
 
 	chip->ngpio	= of_args.args[2];
-	chip->of_node	= np;
+	chip->fwnode	= fwnode;
 	chip->parent	= rza1_pctl->dev;
 
 	range->id	= gpioport;
@@ -1232,10 +1232,9 @@ static int rza1_parse_gpiochip(struct rza1_pinctrl *rza1_pctl,
  */
 static int rza1_gpio_register(struct rza1_pinctrl *rza1_pctl)
 {
-	struct device_node *np = rza1_pctl->dev->of_node;
 	struct pinctrl_gpio_range *gpio_ranges;
 	struct gpio_chip *gpio_chips;
-	struct device_node *child;
+	struct fwnode_handle *child;
 	unsigned int ngpiochips;
 	unsigned int i;
 	int ret;
@@ -1254,14 +1253,11 @@ static int rza1_gpio_register(struct rza1_pinctrl *rza1_pctl)
 		return -ENOMEM;
 
 	i = 0;
-	for_each_child_of_node(np, child) {
-		if (!of_property_read_bool(child, "gpio-controller"))
-			continue;
-
+	for_each_gpiochip_node(rza1_pctl->dev, child) {
 		ret = rza1_parse_gpiochip(rza1_pctl, child, &gpio_chips[i],
 					  &gpio_ranges[i]);
 		if (ret) {
-			of_node_put(child);
+			fwnode_handle_put(child);
 			return ret;
 		}
 
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH v2 08/13] pinctrl: npcm7xx: Switch to use for_each_gpiochip_node() helper
  2022-03-29 15:29 [PATCH v2 00/13] gpiolib: Two new helpers and way toward fwnode Andy Shevchenko
                   ` (6 preceding siblings ...)
  2022-03-29 15:29 ` [PATCH v2 07/13] pinctrl: renesas: rza1: Switch to use for_each_gpiochip_node() helper Andy Shevchenko
@ 2022-03-29 15:29 ` Andy Shevchenko
  2022-03-29 15:29 ` [PATCH v2 09/13] pinctrl: meson: Rename REG_* to MREG_* Andy Shevchenko
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 31+ messages in thread
From: Andy Shevchenko @ 2022-03-29 15:29 UTC (permalink / raw)
  To: Qianggui Song, Andy Shevchenko, Krzysztof Kozlowski,
	Fabien Dessenne, linux-gpio, linux-arm-kernel, linux-amlogic,
	linux-kernel, openbmc, linux-renesas-soc, linux-samsung-soc,
	linux-stm32
  Cc: Linus Walleij, Neil Armstrong, Kevin Hilman, Jerome Brunet,
	Martin Blumenstingl, Andrew Lunn, Gregory Clement,
	Sebastian Hesselbarth, Avi Fishman, Tomer Maimon, Tali Perry,
	Patrick Venture, Nancy Yuen, Benjamin Fair, Geert Uytterhoeven,
	Tomasz Figa, Sylwester Nawrocki, Alim Akhtar, Maxime Coquelin,
	Alexandre Torgue, Bartosz Golaszewski, Philipp Zabel

Switch the code to use for_each_gpiochip_node() helper.

While at it, in order to avoid additional churn in the future,
do the following:
- use a temporary variable for struct device pointer to shorten a few lines
- get rid of a temporary variable for vIRQ number, assign it directly
- switch to fwnode APIs where it makes sense

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c | 141 ++++++++++------------
 1 file changed, 61 insertions(+), 80 deletions(-)

diff --git a/drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c b/drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c
index 221c33300d60..e73732e79585 100644
--- a/drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c
+++ b/drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c
@@ -1862,88 +1862,69 @@ static int npcm7xx_gpio_of(struct npcm7xx_pinctrl *pctrl)
 {
 	int ret = -ENXIO;
 	struct resource res;
-	int id = 0, irq;
-	struct device_node *np;
-	struct of_phandle_args pinspec;
-
-	for_each_available_child_of_node(pctrl->dev->of_node, np)
-		if (of_find_property(np, "gpio-controller", NULL)) {
-			ret = of_address_to_resource(np, 0, &res);
-			if (ret < 0) {
-				dev_err(pctrl->dev,
-					"Resource fail for GPIO bank %u\n", id);
-				return ret;
-			}
-
-			pctrl->gpio_bank[id].base =
-				ioremap(res.start, resource_size(&res));
-
-			irq = irq_of_parse_and_map(np, 0);
-			if (irq < 0) {
-				dev_err(pctrl->dev,
-					"No IRQ for GPIO bank %u\n", id);
-				ret = irq;
-				return ret;
-			}
-
-			ret = bgpio_init(&pctrl->gpio_bank[id].gc,
-					 pctrl->dev, 4,
-					 pctrl->gpio_bank[id].base +
-					 NPCM7XX_GP_N_DIN,
-					 pctrl->gpio_bank[id].base +
-					 NPCM7XX_GP_N_DOUT,
-					 NULL,
-					 NULL,
-					 pctrl->gpio_bank[id].base +
-					 NPCM7XX_GP_N_IEM,
-					 BGPIOF_READ_OUTPUT_REG_SET);
-			if (ret) {
-				dev_err(pctrl->dev, "bgpio_init() failed\n");
-				return ret;
-			}
-
-			ret = of_parse_phandle_with_fixed_args(np,
-							       "gpio-ranges", 3,
-							       0, &pinspec);
-			if (ret < 0) {
-				dev_err(pctrl->dev,
-					"gpio-ranges fail for GPIO bank %u\n",
-					id);
-				return ret;
-			}
-
-			pctrl->gpio_bank[id].irq = irq;
-			pctrl->gpio_bank[id].irq_chip = npcmgpio_irqchip;
-			pctrl->gpio_bank[id].gc.parent = pctrl->dev;
-			pctrl->gpio_bank[id].irqbase =
-				id * NPCM7XX_GPIO_PER_BANK;
-			pctrl->gpio_bank[id].pinctrl_id = pinspec.args[0];
-			pctrl->gpio_bank[id].gc.base = pinspec.args[1];
-			pctrl->gpio_bank[id].gc.ngpio = pinspec.args[2];
-			pctrl->gpio_bank[id].gc.owner = THIS_MODULE;
-			pctrl->gpio_bank[id].gc.label =
-				devm_kasprintf(pctrl->dev, GFP_KERNEL, "%pOF",
-					       np);
-			if (pctrl->gpio_bank[id].gc.label == NULL)
-				return -ENOMEM;
-
-			pctrl->gpio_bank[id].gc.dbg_show = npcmgpio_dbg_show;
-			pctrl->gpio_bank[id].direction_input =
-				pctrl->gpio_bank[id].gc.direction_input;
-			pctrl->gpio_bank[id].gc.direction_input =
-				npcmgpio_direction_input;
-			pctrl->gpio_bank[id].direction_output =
-				pctrl->gpio_bank[id].gc.direction_output;
-			pctrl->gpio_bank[id].gc.direction_output =
-				npcmgpio_direction_output;
-			pctrl->gpio_bank[id].request =
-				pctrl->gpio_bank[id].gc.request;
-			pctrl->gpio_bank[id].gc.request = npcmgpio_gpio_request;
-			pctrl->gpio_bank[id].gc.free = npcmgpio_gpio_free;
-			pctrl->gpio_bank[id].gc.of_node = np;
-			id++;
+	struct device *dev = pctrl->dev;
+	struct fwnode_reference_args pinspec;
+	struct fwnode_handle *child;
+	int id = 0;
+
+	for_each_gpiochip_node(dev, child) {
+		struct device_node *np = to_of_node(child);
+
+		ret = of_address_to_resource(np, 0, &res);
+		if (ret < 0) {
+			dev_err(dev, "Resource fail for GPIO bank %u\n", id);
+			return ret;
+		}
+
+		pctrl->gpio_bank[id].base = ioremap(res.start, resource_size(&res));
+
+		ret = bgpio_init(&pctrl->gpio_bank[id].gc, dev, 4,
+				 pctrl->gpio_bank[id].base + NPCM7XX_GP_N_DIN,
+				 pctrl->gpio_bank[id].base + NPCM7XX_GP_N_DOUT,
+				 NULL,
+				 NULL,
+				 pctrl->gpio_bank[id].base + NPCM7XX_GP_N_IEM,
+				 BGPIOF_READ_OUTPUT_REG_SET);
+		if (ret) {
+			dev_err(dev, "bgpio_init() failed\n");
+			return ret;
 		}
 
+		ret = fwnode_property_get_reference_args(child, "gpio-ranges", NULL, 3, 0, &pinspec);
+		if (ret < 0) {
+			dev_err(dev, "gpio-ranges fail for GPIO bank %u\n", id);
+			return ret;
+		}
+
+		ret = irq_of_parse_and_map(np, 0);
+		if (ret < 0) {
+			dev_err(dev, "No IRQ for GPIO bank %u\n", id);
+			return ret;
+		}
+		pctrl->gpio_bank[id].irq = ret;
+		pctrl->gpio_bank[id].irq_chip = npcmgpio_irqchip;
+		pctrl->gpio_bank[id].irqbase = id * NPCM7XX_GPIO_PER_BANK;
+		pctrl->gpio_bank[id].pinctrl_id = pinspec.args[0];
+		pctrl->gpio_bank[id].gc.base = pinspec.args[1];
+		pctrl->gpio_bank[id].gc.ngpio = pinspec.args[2];
+		pctrl->gpio_bank[id].gc.owner = THIS_MODULE;
+		pctrl->gpio_bank[id].gc.parent = dev;
+		pctrl->gpio_bank[id].gc.label = devm_kasprintf(dev, GFP_KERNEL, "%pfw", child);
+		if (pctrl->gpio_bank[id].gc.label == NULL)
+			return -ENOMEM;
+
+		pctrl->gpio_bank[id].gc.dbg_show = npcmgpio_dbg_show;
+		pctrl->gpio_bank[id].direction_input = pctrl->gpio_bank[id].gc.direction_input;
+		pctrl->gpio_bank[id].gc.direction_input = npcmgpio_direction_input;
+		pctrl->gpio_bank[id].direction_output = pctrl->gpio_bank[id].gc.direction_output;
+		pctrl->gpio_bank[id].gc.direction_output = npcmgpio_direction_output;
+		pctrl->gpio_bank[id].request = pctrl->gpio_bank[id].gc.request;
+		pctrl->gpio_bank[id].gc.request = npcmgpio_gpio_request;
+		pctrl->gpio_bank[id].gc.free = npcmgpio_gpio_free;
+		pctrl->gpio_bank[id].gc.fwnode = child;
+		id++;
+	}
+
 	pctrl->bank_num = id;
 	return ret;
 }
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH v2 09/13] pinctrl: meson: Rename REG_* to MREG_*
  2022-03-29 15:29 [PATCH v2 00/13] gpiolib: Two new helpers and way toward fwnode Andy Shevchenko
                   ` (7 preceding siblings ...)
  2022-03-29 15:29 ` [PATCH v2 08/13] pinctrl: npcm7xx: " Andy Shevchenko
@ 2022-03-29 15:29 ` Andy Shevchenko
  2022-03-29 16:13   ` Neil Armstrong
  2022-03-29 15:29 ` [PATCH v2 10/13] pinctrl: meson: Enable COMPILE_TEST Andy Shevchenko
                   ` (3 subsequent siblings)
  12 siblings, 1 reply; 31+ messages in thread
From: Andy Shevchenko @ 2022-03-29 15:29 UTC (permalink / raw)
  To: Qianggui Song, Andy Shevchenko, Krzysztof Kozlowski,
	Fabien Dessenne, linux-gpio, linux-arm-kernel, linux-amlogic,
	linux-kernel, openbmc, linux-renesas-soc, linux-samsung-soc,
	linux-stm32
  Cc: Linus Walleij, Neil Armstrong, Kevin Hilman, Jerome Brunet,
	Martin Blumenstingl, Andrew Lunn, Gregory Clement,
	Sebastian Hesselbarth, Avi Fishman, Tomer Maimon, Tali Perry,
	Patrick Venture, Nancy Yuen, Benjamin Fair, Geert Uytterhoeven,
	Tomasz Figa, Sylwester Nawrocki, Alim Akhtar, Maxime Coquelin,
	Alexandre Torgue, Bartosz Golaszewski, Philipp Zabel

Rename REG_* to MREG_* as a prerequisite for enabling COMPILE_TEST.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/pinctrl/meson/pinctrl-meson.c | 24 ++++++++++++------------
 drivers/pinctrl/meson/pinctrl-meson.h | 24 ++++++++++++------------
 2 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/drivers/pinctrl/meson/pinctrl-meson.c b/drivers/pinctrl/meson/pinctrl-meson.c
index 49851444a6e3..64da61ba2bb9 100644
--- a/drivers/pinctrl/meson/pinctrl-meson.c
+++ b/drivers/pinctrl/meson/pinctrl-meson.c
@@ -218,13 +218,13 @@ static int meson_pinconf_set_output(struct meson_pinctrl *pc,
 				    unsigned int pin,
 				    bool out)
 {
-	return meson_pinconf_set_gpio_bit(pc, pin, REG_DIR, !out);
+	return meson_pinconf_set_gpio_bit(pc, pin, MREG_DIR, !out);
 }
 
 static int meson_pinconf_get_output(struct meson_pinctrl *pc,
 				    unsigned int pin)
 {
-	int ret = meson_pinconf_get_gpio_bit(pc, pin, REG_DIR);
+	int ret = meson_pinconf_get_gpio_bit(pc, pin, MREG_DIR);
 
 	if (ret < 0)
 		return ret;
@@ -236,13 +236,13 @@ static int meson_pinconf_set_drive(struct meson_pinctrl *pc,
 				   unsigned int pin,
 				   bool high)
 {
-	return meson_pinconf_set_gpio_bit(pc, pin, REG_OUT, high);
+	return meson_pinconf_set_gpio_bit(pc, pin, MREG_OUT, high);
 }
 
 static int meson_pinconf_get_drive(struct meson_pinctrl *pc,
 				   unsigned int pin)
 {
-	return meson_pinconf_get_gpio_bit(pc, pin, REG_OUT);
+	return meson_pinconf_get_gpio_bit(pc, pin, MREG_OUT);
 }
 
 static int meson_pinconf_set_output_drive(struct meson_pinctrl *pc,
@@ -269,7 +269,7 @@ static int meson_pinconf_disable_bias(struct meson_pinctrl *pc,
 	if (ret)
 		return ret;
 
-	meson_calc_reg_and_bit(bank, pin, REG_PULLEN, &reg, &bit);
+	meson_calc_reg_and_bit(bank, pin, MREG_PULLEN, &reg, &bit);
 	ret = regmap_update_bits(pc->reg_pullen, reg, BIT(bit), 0);
 	if (ret)
 		return ret;
@@ -288,7 +288,7 @@ static int meson_pinconf_enable_bias(struct meson_pinctrl *pc, unsigned int pin,
 	if (ret)
 		return ret;
 
-	meson_calc_reg_and_bit(bank, pin, REG_PULL, &reg, &bit);
+	meson_calc_reg_and_bit(bank, pin, MREG_PULL, &reg, &bit);
 	if (pull_up)
 		val = BIT(bit);
 
@@ -296,7 +296,7 @@ static int meson_pinconf_enable_bias(struct meson_pinctrl *pc, unsigned int pin,
 	if (ret)
 		return ret;
 
-	meson_calc_reg_and_bit(bank, pin, REG_PULLEN, &reg, &bit);
+	meson_calc_reg_and_bit(bank, pin, MREG_PULLEN, &reg, &bit);
 	ret = regmap_update_bits(pc->reg_pullen, reg, BIT(bit),	BIT(bit));
 	if (ret)
 		return ret;
@@ -321,7 +321,7 @@ static int meson_pinconf_set_drive_strength(struct meson_pinctrl *pc,
 	if (ret)
 		return ret;
 
-	meson_calc_reg_and_bit(bank, pin, REG_DS, &reg, &bit);
+	meson_calc_reg_and_bit(bank, pin, MREG_DS, &reg, &bit);
 
 	if (drive_strength_ua <= 500) {
 		ds_val = MESON_PINCONF_DRV_500UA;
@@ -407,7 +407,7 @@ static int meson_pinconf_get_pull(struct meson_pinctrl *pc, unsigned int pin)
 	if (ret)
 		return ret;
 
-	meson_calc_reg_and_bit(bank, pin, REG_PULLEN, &reg, &bit);
+	meson_calc_reg_and_bit(bank, pin, MREG_PULLEN, &reg, &bit);
 
 	ret = regmap_read(pc->reg_pullen, reg, &val);
 	if (ret)
@@ -416,7 +416,7 @@ static int meson_pinconf_get_pull(struct meson_pinctrl *pc, unsigned int pin)
 	if (!(val & BIT(bit))) {
 		conf = PIN_CONFIG_BIAS_DISABLE;
 	} else {
-		meson_calc_reg_and_bit(bank, pin, REG_PULL, &reg, &bit);
+		meson_calc_reg_and_bit(bank, pin, MREG_PULL, &reg, &bit);
 
 		ret = regmap_read(pc->reg_pull, reg, &val);
 		if (ret)
@@ -447,7 +447,7 @@ static int meson_pinconf_get_drive_strength(struct meson_pinctrl *pc,
 	if (ret)
 		return ret;
 
-	meson_calc_reg_and_bit(bank, pin, REG_DS, &reg, &bit);
+	meson_calc_reg_and_bit(bank, pin, MREG_DS, &reg, &bit);
 
 	ret = regmap_read(pc->reg_ds, reg, &val);
 	if (ret)
@@ -595,7 +595,7 @@ static int meson_gpio_get(struct gpio_chip *chip, unsigned gpio)
 	if (ret)
 		return ret;
 
-	meson_calc_reg_and_bit(bank, gpio, REG_IN, &reg, &bit);
+	meson_calc_reg_and_bit(bank, gpio, MREG_IN, &reg, &bit);
 	regmap_read(pc->reg_gpio, reg, &val);
 
 	return !!(val & BIT(bit));
diff --git a/drivers/pinctrl/meson/pinctrl-meson.h b/drivers/pinctrl/meson/pinctrl-meson.h
index ff5372e0a475..c00d9ad27843 100644
--- a/drivers/pinctrl/meson/pinctrl-meson.h
+++ b/drivers/pinctrl/meson/pinctrl-meson.h
@@ -63,12 +63,12 @@ struct meson_reg_desc {
  * enum meson_reg_type - type of registers encoded in @meson_reg_desc
  */
 enum meson_reg_type {
-	REG_PULLEN,
-	REG_PULL,
-	REG_DIR,
-	REG_OUT,
-	REG_IN,
-	REG_DS,
+	MREG_PULLEN,
+	MREG_PULL,
+	MREG_DIR,
+	MREG_OUT,
+	MREG_IN,
+	MREG_DS,
 	NUM_REG,
 };
 
@@ -150,12 +150,12 @@ struct meson_pinctrl {
 		.irq_first	= fi,					\
 		.irq_last	= li,					\
 		.regs = {						\
-			[REG_PULLEN]	= { per, peb },			\
-			[REG_PULL]	= { pr, pb },			\
-			[REG_DIR]	= { dr, db },			\
-			[REG_OUT]	= { or, ob },			\
-			[REG_IN]	= { ir, ib },			\
-			[REG_DS]	= { dsr, dsb },			\
+			[MREG_PULLEN]	= { per, peb },			\
+			[MREG_PULL]	= { pr, pb },			\
+			[MREG_DIR]	= { dr, db },			\
+			[MREG_OUT]	= { or, ob },			\
+			[MREG_IN]	= { ir, ib },			\
+			[MREG_DS]	= { dsr, dsb },			\
 		},							\
 	 }
 
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH v2 10/13] pinctrl: meson: Enable COMPILE_TEST
  2022-03-29 15:29 [PATCH v2 00/13] gpiolib: Two new helpers and way toward fwnode Andy Shevchenko
                   ` (8 preceding siblings ...)
  2022-03-29 15:29 ` [PATCH v2 09/13] pinctrl: meson: Rename REG_* to MREG_* Andy Shevchenko
@ 2022-03-29 15:29 ` Andy Shevchenko
  2022-03-29 16:10   ` Neil Armstrong
  2022-03-29 15:29 ` [PATCH v2 11/13] pinctrl: meson: Replace custom code by gpiochip_node_count() call Andy Shevchenko
                   ` (2 subsequent siblings)
  12 siblings, 1 reply; 31+ messages in thread
From: Andy Shevchenko @ 2022-03-29 15:29 UTC (permalink / raw)
  To: Qianggui Song, Andy Shevchenko, Krzysztof Kozlowski,
	Fabien Dessenne, linux-gpio, linux-arm-kernel, linux-amlogic,
	linux-kernel, openbmc, linux-renesas-soc, linux-samsung-soc,
	linux-stm32
  Cc: Linus Walleij, Neil Armstrong, Kevin Hilman, Jerome Brunet,
	Martin Blumenstingl, Andrew Lunn, Gregory Clement,
	Sebastian Hesselbarth, Avi Fishman, Tomer Maimon, Tali Perry,
	Patrick Venture, Nancy Yuen, Benjamin Fair, Geert Uytterhoeven,
	Tomasz Figa, Sylwester Nawrocki, Alim Akhtar, Maxime Coquelin,
	Alexandre Torgue, Bartosz Golaszewski, Philipp Zabel

Enable COMPILE_TEST for a better test coverage.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/pinctrl/meson/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pinctrl/meson/Kconfig b/drivers/pinctrl/meson/Kconfig
index d1955c65b4b6..64fb9e074ac6 100644
--- a/drivers/pinctrl/meson/Kconfig
+++ b/drivers/pinctrl/meson/Kconfig
@@ -1,7 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0-only
 menuconfig PINCTRL_MESON
 	tristate "Amlogic SoC pinctrl drivers"
-	depends on ARCH_MESON
+	depends on ARCH_MESON || COMPILE_TEST
 	depends on OF
 	default y
 	select PINMUX
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH v2 11/13] pinctrl: meson: Replace custom code by gpiochip_node_count() call
  2022-03-29 15:29 [PATCH v2 00/13] gpiolib: Two new helpers and way toward fwnode Andy Shevchenko
                   ` (9 preceding siblings ...)
  2022-03-29 15:29 ` [PATCH v2 10/13] pinctrl: meson: Enable COMPILE_TEST Andy Shevchenko
@ 2022-03-29 15:29 ` Andy Shevchenko
  2022-03-29 15:29 ` [PATCH v2 12/13] pinctrl: armada-37xx: Switch to use fwnode instead of of_node Andy Shevchenko
  2022-03-29 15:29 ` [PATCH v2 13/13] pinctrl: armada-37xx: Reuse GPIO fwnode in armada_37xx_irqchip_register() Andy Shevchenko
  12 siblings, 0 replies; 31+ messages in thread
From: Andy Shevchenko @ 2022-03-29 15:29 UTC (permalink / raw)
  To: Qianggui Song, Andy Shevchenko, Krzysztof Kozlowski,
	Fabien Dessenne, linux-gpio, linux-arm-kernel, linux-amlogic,
	linux-kernel, openbmc, linux-renesas-soc, linux-samsung-soc,
	linux-stm32
  Cc: Linus Walleij, Neil Armstrong, Kevin Hilman, Jerome Brunet,
	Martin Blumenstingl, Andrew Lunn, Gregory Clement,
	Sebastian Hesselbarth, Avi Fishman, Tomer Maimon, Tali Perry,
	Patrick Venture, Nancy Yuen, Benjamin Fair, Geert Uytterhoeven,
	Tomasz Figa, Sylwester Nawrocki, Alim Akhtar, Maxime Coquelin,
	Alexandre Torgue, Bartosz Golaszewski, Philipp Zabel

Since we have generic function to count GPIO controller nodes
under a given device, there is no need to open code it. Replace
custom code by gpiochip_node_count() call.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Neil Armstrong <narmstrong@baylibre.com>
---
 drivers/pinctrl/meson/pinctrl-meson.c | 28 ++++++++++++---------------
 1 file changed, 12 insertions(+), 16 deletions(-)

diff --git a/drivers/pinctrl/meson/pinctrl-meson.c b/drivers/pinctrl/meson/pinctrl-meson.c
index 64da61ba2bb9..c7df4de77b07 100644
--- a/drivers/pinctrl/meson/pinctrl-meson.c
+++ b/drivers/pinctrl/meson/pinctrl-meson.c
@@ -49,6 +49,7 @@
 #include <linux/pinctrl/pinctrl.h>
 #include <linux/pinctrl/pinmux.h>
 #include <linux/platform_device.h>
+#include <linux/property.h>
 #include <linux/regmap.h>
 #include <linux/seq_file.h>
 
@@ -662,27 +663,22 @@ static struct regmap *meson_map_resource(struct meson_pinctrl *pc,
 	return devm_regmap_init_mmio(pc->dev, base, &meson_regmap_config);
 }
 
-static int meson_pinctrl_parse_dt(struct meson_pinctrl *pc,
-				  struct device_node *node)
+static int meson_pinctrl_parse_dt(struct meson_pinctrl *pc)
 {
-	struct device_node *np, *gpio_np = NULL;
+	struct device_node *gpio_np;
+	unsigned int chips;
 
-	for_each_child_of_node(node, np) {
-		if (!of_find_property(np, "gpio-controller", NULL))
-			continue;
-		if (gpio_np) {
-			dev_err(pc->dev, "multiple gpio nodes\n");
-			of_node_put(np);
-			return -EINVAL;
-		}
-		gpio_np = np;
-	}
-
-	if (!gpio_np) {
+	chips = gpiochip_node_count(pc->dev);
+	if (!chips) {
 		dev_err(pc->dev, "no gpio node found\n");
 		return -EINVAL;
 	}
+	if (chips > 1) {
+		dev_err(pc->dev, "multiple gpio nodes\n");
+		return -EINVAL;
+	}
 
+	gpio_np = to_of_node(device_get_named_child_node(pc->dev, "gpio-controller"));
 	pc->of_node = gpio_np;
 
 	pc->reg_mux = meson_map_resource(pc, gpio_np, "mux");
@@ -751,7 +747,7 @@ int meson_pinctrl_probe(struct platform_device *pdev)
 	pc->dev = dev;
 	pc->data = (struct meson_pinctrl_data *) of_device_get_match_data(dev);
 
-	ret = meson_pinctrl_parse_dt(pc, dev->of_node);
+	ret = meson_pinctrl_parse_dt(pc);
 	if (ret)
 		return ret;
 
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH v2 12/13] pinctrl: armada-37xx: Switch to use fwnode instead of of_node
  2022-03-29 15:29 [PATCH v2 00/13] gpiolib: Two new helpers and way toward fwnode Andy Shevchenko
                   ` (10 preceding siblings ...)
  2022-03-29 15:29 ` [PATCH v2 11/13] pinctrl: meson: Replace custom code by gpiochip_node_count() call Andy Shevchenko
@ 2022-03-29 15:29 ` Andy Shevchenko
  2022-03-29 15:29 ` [PATCH v2 13/13] pinctrl: armada-37xx: Reuse GPIO fwnode in armada_37xx_irqchip_register() Andy Shevchenko
  12 siblings, 0 replies; 31+ messages in thread
From: Andy Shevchenko @ 2022-03-29 15:29 UTC (permalink / raw)
  To: Qianggui Song, Andy Shevchenko, Krzysztof Kozlowski,
	Fabien Dessenne, linux-gpio, linux-arm-kernel, linux-amlogic,
	linux-kernel, openbmc, linux-renesas-soc, linux-samsung-soc,
	linux-stm32
  Cc: Linus Walleij, Neil Armstrong, Kevin Hilman, Jerome Brunet,
	Martin Blumenstingl, Andrew Lunn, Gregory Clement,
	Sebastian Hesselbarth, Avi Fishman, Tomer Maimon, Tali Perry,
	Patrick Venture, Nancy Yuen, Benjamin Fair, Geert Uytterhoeven,
	Tomasz Figa, Sylwester Nawrocki, Alim Akhtar, Maxime Coquelin,
	Alexandre Torgue, Bartosz Golaszewski, Philipp Zabel

GPIO library now accepts fwnode as a firmware node,
so switch the driver to use it.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/pinctrl/mvebu/pinctrl-armada-37xx.c | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)

diff --git a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
index 3e10a44e2669..4a2fa10f94f8 100644
--- a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
+++ b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
@@ -21,6 +21,7 @@
 #include <linux/pinctrl/pinctrl.h>
 #include <linux/pinctrl/pinmux.h>
 #include <linux/platform_device.h>
+#include <linux/property.h>
 #include <linux/regmap.h>
 #include <linux/slab.h>
 #include <linux/string_helpers.h>
@@ -787,18 +788,13 @@ static int armada_37xx_gpiochip_register(struct platform_device *pdev,
 					struct armada_37xx_pinctrl *info)
 {
 	struct device *dev = &pdev->dev;
-	struct device_node *np;
+	struct fwnode_handle *fwnode;
 	struct gpio_chip *gc;
-	int ret = -ENODEV;
+	int ret;
 
-	for_each_child_of_node(dev->of_node, np) {
-		if (of_find_property(np, "gpio-controller", NULL)) {
-			ret = 0;
-			break;
-		}
-	}
-	if (ret)
-		return ret;
+	fwnode = device_get_named_child_node(dev, "gpio-controller");
+	if (!fwnode)
+		return -ENODEV;
 
 	info->gpio_chip = armada_37xx_gpiolib_chip;
 
@@ -806,7 +802,7 @@ static int armada_37xx_gpiochip_register(struct platform_device *pdev,
 	gc->ngpio = info->data->nr_pins;
 	gc->parent = dev;
 	gc->base = -1;
-	gc->of_node = np;
+	gc->fwnode = fwnode;
 	gc->label = info->data->name;
 
 	ret = armada_37xx_irqchip_register(pdev, info);
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH v2 13/13] pinctrl: armada-37xx: Reuse GPIO fwnode in armada_37xx_irqchip_register()
  2022-03-29 15:29 [PATCH v2 00/13] gpiolib: Two new helpers and way toward fwnode Andy Shevchenko
                   ` (11 preceding siblings ...)
  2022-03-29 15:29 ` [PATCH v2 12/13] pinctrl: armada-37xx: Switch to use fwnode instead of of_node Andy Shevchenko
@ 2022-03-29 15:29 ` Andy Shevchenko
  12 siblings, 0 replies; 31+ messages in thread
From: Andy Shevchenko @ 2022-03-29 15:29 UTC (permalink / raw)
  To: Qianggui Song, Andy Shevchenko, Krzysztof Kozlowski,
	Fabien Dessenne, linux-gpio, linux-arm-kernel, linux-amlogic,
	linux-kernel, openbmc, linux-renesas-soc, linux-samsung-soc,
	linux-stm32
  Cc: Linus Walleij, Neil Armstrong, Kevin Hilman, Jerome Brunet,
	Martin Blumenstingl, Andrew Lunn, Gregory Clement,
	Sebastian Hesselbarth, Avi Fishman, Tomer Maimon, Tali Perry,
	Patrick Venture, Nancy Yuen, Benjamin Fair, Geert Uytterhoeven,
	Tomasz Figa, Sylwester Nawrocki, Alim Akhtar, Maxime Coquelin,
	Alexandre Torgue, Bartosz Golaszewski, Philipp Zabel

Since we have fwnode of the first found GPIO controller assigned to the
struct gpio_chip, we may reuse it in the armada_37xx_irqchip_register().

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/pinctrl/mvebu/pinctrl-armada-37xx.c | 16 +++-------------
 1 file changed, 3 insertions(+), 13 deletions(-)

diff --git a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
index 4a2fa10f94f8..54f473f4afed 100644
--- a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
+++ b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
@@ -727,23 +727,13 @@ static int armada_37xx_irqchip_register(struct platform_device *pdev,
 	struct gpio_chip *gc = &info->gpio_chip;
 	struct irq_chip *irqchip = &info->irq_chip;
 	struct gpio_irq_chip *girq = &gc->irq;
+	struct device_node *np = to_of_node(gc->fwnode);
 	struct device *dev = &pdev->dev;
-	struct device_node *np;
-	int ret = -ENODEV, i, nr_irq_parent;
-
-	/* Check if we have at least one gpio-controller child node */
-	for_each_child_of_node(dev->of_node, np) {
-		if (of_property_read_bool(np, "gpio-controller")) {
-			ret = 0;
-			break;
-		}
-	}
-	if (ret)
-		return dev_err_probe(dev, ret, "no gpio-controller child node\n");
+	unsigned int i, nr_irq_parent;
 
-	nr_irq_parent = of_irq_count(np);
 	spin_lock_init(&info->irq_lock);
 
+	nr_irq_parent = of_irq_count(np);
 	if (!nr_irq_parent) {
 		dev_err(dev, "invalid or no IRQ\n");
 		return 0;
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* Re: [PATCH v2 10/13] pinctrl: meson: Enable COMPILE_TEST
  2022-03-29 15:29 ` [PATCH v2 10/13] pinctrl: meson: Enable COMPILE_TEST Andy Shevchenko
@ 2022-03-29 16:10   ` Neil Armstrong
  0 siblings, 0 replies; 31+ messages in thread
From: Neil Armstrong @ 2022-03-29 16:10 UTC (permalink / raw)
  To: Andy Shevchenko, Qianggui Song, Krzysztof Kozlowski,
	Fabien Dessenne, linux-gpio, linux-arm-kernel, linux-amlogic,
	linux-kernel, openbmc, linux-renesas-soc, linux-samsung-soc,
	linux-stm32
  Cc: Linus Walleij, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
	Andrew Lunn, Gregory Clement, Sebastian Hesselbarth, Avi Fishman,
	Tomer Maimon, Tali Perry, Patrick Venture, Nancy Yuen,
	Benjamin Fair, Geert Uytterhoeven, Tomasz Figa,
	Sylwester Nawrocki, Alim Akhtar, Maxime Coquelin,
	Alexandre Torgue, Bartosz Golaszewski, Philipp Zabel

On 29/03/2022 17:29, Andy Shevchenko wrote:
> Enable COMPILE_TEST for a better test coverage.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>   drivers/pinctrl/meson/Kconfig | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/pinctrl/meson/Kconfig b/drivers/pinctrl/meson/Kconfig
> index d1955c65b4b6..64fb9e074ac6 100644
> --- a/drivers/pinctrl/meson/Kconfig
> +++ b/drivers/pinctrl/meson/Kconfig
> @@ -1,7 +1,7 @@
>   # SPDX-License-Identifier: GPL-2.0-only
>   menuconfig PINCTRL_MESON
>   	tristate "Amlogic SoC pinctrl drivers"
> -	depends on ARCH_MESON
> +	depends on ARCH_MESON || COMPILE_TEST
>   	depends on OF
>   	default y
>   	select PINMUX

Reviewed-by: Neil Armstrong <narmstrong@baylibre.com>

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH v2 09/13] pinctrl: meson: Rename REG_* to MREG_*
  2022-03-29 15:29 ` [PATCH v2 09/13] pinctrl: meson: Rename REG_* to MREG_* Andy Shevchenko
@ 2022-03-29 16:13   ` Neil Armstrong
  2022-03-29 16:42     ` Andy Shevchenko
  0 siblings, 1 reply; 31+ messages in thread
From: Neil Armstrong @ 2022-03-29 16:13 UTC (permalink / raw)
  To: Andy Shevchenko, Qianggui Song, Krzysztof Kozlowski,
	Fabien Dessenne, linux-gpio, linux-arm-kernel, linux-amlogic,
	linux-kernel, openbmc, linux-renesas-soc, linux-samsung-soc,
	linux-stm32
  Cc: Linus Walleij, Kevin Hilman, Jerome Brunet, Martin Blumenstingl,
	Andrew Lunn, Gregory Clement, Sebastian Hesselbarth, Avi Fishman,
	Tomer Maimon, Tali Perry, Patrick Venture, Nancy Yuen,
	Benjamin Fair, Geert Uytterhoeven, Tomasz Figa,
	Sylwester Nawrocki, Alim Akhtar, Maxime Coquelin,
	Alexandre Torgue, Bartosz Golaszewski, Philipp Zabel

On 29/03/2022 17:29, Andy Shevchenko wrote:
> Rename REG_* to MREG_* as a prerequisite for enabling COMPILE_TEST.

What error do you hit ?

MREG_ is rather ugly, something like PINCONF_REG_ or more simpler MESON_REG_ would be more appropriate.

Neil

> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>   drivers/pinctrl/meson/pinctrl-meson.c | 24 ++++++++++++------------
>   drivers/pinctrl/meson/pinctrl-meson.h | 24 ++++++++++++------------
>   2 files changed, 24 insertions(+), 24 deletions(-)
> 
> diff --git a/drivers/pinctrl/meson/pinctrl-meson.c b/drivers/pinctrl/meson/pinctrl-meson.c
> index 49851444a6e3..64da61ba2bb9 100644
> --- a/drivers/pinctrl/meson/pinctrl-meson.c
> +++ b/drivers/pinctrl/meson/pinctrl-meson.c
> @@ -218,13 +218,13 @@ static int meson_pinconf_set_output(struct meson_pinctrl *pc,
>   				    unsigned int pin,
>   				    bool out)
>   {
> -	return meson_pinconf_set_gpio_bit(pc, pin, REG_DIR, !out);
> +	return meson_pinconf_set_gpio_bit(pc, pin, MREG_DIR, !out);
>   }
>   
>   static int meson_pinconf_get_output(struct meson_pinctrl *pc,
>   				    unsigned int pin)
>   {
> -	int ret = meson_pinconf_get_gpio_bit(pc, pin, REG_DIR);
> +	int ret = meson_pinconf_get_gpio_bit(pc, pin, MREG_DIR);
>   
>   	if (ret < 0)
>   		return ret;
> @@ -236,13 +236,13 @@ static int meson_pinconf_set_drive(struct meson_pinctrl *pc,
>   				   unsigned int pin,
>   				   bool high)
>   {
> -	return meson_pinconf_set_gpio_bit(pc, pin, REG_OUT, high);
> +	return meson_pinconf_set_gpio_bit(pc, pin, MREG_OUT, high);
>   }
>   
>   static int meson_pinconf_get_drive(struct meson_pinctrl *pc,
>   				   unsigned int pin)
>   {
> -	return meson_pinconf_get_gpio_bit(pc, pin, REG_OUT);
> +	return meson_pinconf_get_gpio_bit(pc, pin, MREG_OUT);
>   }
>   
>   static int meson_pinconf_set_output_drive(struct meson_pinctrl *pc,
> @@ -269,7 +269,7 @@ static int meson_pinconf_disable_bias(struct meson_pinctrl *pc,
>   	if (ret)
>   		return ret;
>   
> -	meson_calc_reg_and_bit(bank, pin, REG_PULLEN, &reg, &bit);
> +	meson_calc_reg_and_bit(bank, pin, MREG_PULLEN, &reg, &bit);
>   	ret = regmap_update_bits(pc->reg_pullen, reg, BIT(bit), 0);
>   	if (ret)
>   		return ret;
> @@ -288,7 +288,7 @@ static int meson_pinconf_enable_bias(struct meson_pinctrl *pc, unsigned int pin,
>   	if (ret)
>   		return ret;
>   
> -	meson_calc_reg_and_bit(bank, pin, REG_PULL, &reg, &bit);
> +	meson_calc_reg_and_bit(bank, pin, MREG_PULL, &reg, &bit);
>   	if (pull_up)
>   		val = BIT(bit);
>   
> @@ -296,7 +296,7 @@ static int meson_pinconf_enable_bias(struct meson_pinctrl *pc, unsigned int pin,
>   	if (ret)
>   		return ret;
>   
> -	meson_calc_reg_and_bit(bank, pin, REG_PULLEN, &reg, &bit);
> +	meson_calc_reg_and_bit(bank, pin, MREG_PULLEN, &reg, &bit);
>   	ret = regmap_update_bits(pc->reg_pullen, reg, BIT(bit),	BIT(bit));
>   	if (ret)
>   		return ret;
> @@ -321,7 +321,7 @@ static int meson_pinconf_set_drive_strength(struct meson_pinctrl *pc,
>   	if (ret)
>   		return ret;
>   
> -	meson_calc_reg_and_bit(bank, pin, REG_DS, &reg, &bit);
> +	meson_calc_reg_and_bit(bank, pin, MREG_DS, &reg, &bit);
>   
>   	if (drive_strength_ua <= 500) {
>   		ds_val = MESON_PINCONF_DRV_500UA;
> @@ -407,7 +407,7 @@ static int meson_pinconf_get_pull(struct meson_pinctrl *pc, unsigned int pin)
>   	if (ret)
>   		return ret;
>   
> -	meson_calc_reg_and_bit(bank, pin, REG_PULLEN, &reg, &bit);
> +	meson_calc_reg_and_bit(bank, pin, MREG_PULLEN, &reg, &bit);
>   
>   	ret = regmap_read(pc->reg_pullen, reg, &val);
>   	if (ret)
> @@ -416,7 +416,7 @@ static int meson_pinconf_get_pull(struct meson_pinctrl *pc, unsigned int pin)
>   	if (!(val & BIT(bit))) {
>   		conf = PIN_CONFIG_BIAS_DISABLE;
>   	} else {
> -		meson_calc_reg_and_bit(bank, pin, REG_PULL, &reg, &bit);
> +		meson_calc_reg_and_bit(bank, pin, MREG_PULL, &reg, &bit);
>   
>   		ret = regmap_read(pc->reg_pull, reg, &val);
>   		if (ret)
> @@ -447,7 +447,7 @@ static int meson_pinconf_get_drive_strength(struct meson_pinctrl *pc,
>   	if (ret)
>   		return ret;
>   
> -	meson_calc_reg_and_bit(bank, pin, REG_DS, &reg, &bit);
> +	meson_calc_reg_and_bit(bank, pin, MREG_DS, &reg, &bit);
>   
>   	ret = regmap_read(pc->reg_ds, reg, &val);
>   	if (ret)
> @@ -595,7 +595,7 @@ static int meson_gpio_get(struct gpio_chip *chip, unsigned gpio)
>   	if (ret)
>   		return ret;
>   
> -	meson_calc_reg_and_bit(bank, gpio, REG_IN, &reg, &bit);
> +	meson_calc_reg_and_bit(bank, gpio, MREG_IN, &reg, &bit);
>   	regmap_read(pc->reg_gpio, reg, &val);
>   
>   	return !!(val & BIT(bit));
> diff --git a/drivers/pinctrl/meson/pinctrl-meson.h b/drivers/pinctrl/meson/pinctrl-meson.h
> index ff5372e0a475..c00d9ad27843 100644
> --- a/drivers/pinctrl/meson/pinctrl-meson.h
> +++ b/drivers/pinctrl/meson/pinctrl-meson.h
> @@ -63,12 +63,12 @@ struct meson_reg_desc {
>    * enum meson_reg_type - type of registers encoded in @meson_reg_desc
>    */
>   enum meson_reg_type {
> -	REG_PULLEN,
> -	REG_PULL,
> -	REG_DIR,
> -	REG_OUT,
> -	REG_IN,
> -	REG_DS,
> +	MREG_PULLEN,
> +	MREG_PULL,
> +	MREG_DIR,
> +	MREG_OUT,
> +	MREG_IN,
> +	MREG_DS,
>   	NUM_REG,
>   };
>   
> @@ -150,12 +150,12 @@ struct meson_pinctrl {
>   		.irq_first	= fi,					\
>   		.irq_last	= li,					\
>   		.regs = {						\
> -			[REG_PULLEN]	= { per, peb },			\
> -			[REG_PULL]	= { pr, pb },			\
> -			[REG_DIR]	= { dr, db },			\
> -			[REG_OUT]	= { or, ob },			\
> -			[REG_IN]	= { ir, ib },			\
> -			[REG_DS]	= { dsr, dsb },			\
> +			[MREG_PULLEN]	= { per, peb },			\
> +			[MREG_PULL]	= { pr, pb },			\
> +			[MREG_DIR]	= { dr, db },			\
> +			[MREG_OUT]	= { or, ob },			\
> +			[MREG_IN]	= { ir, ib },			\
> +			[MREG_DS]	= { dsr, dsb },			\
>   		},							\
>   	 }
>   


^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH v2 09/13] pinctrl: meson: Rename REG_* to MREG_*
  2022-03-29 16:13   ` Neil Armstrong
@ 2022-03-29 16:42     ` Andy Shevchenko
  2022-03-30  8:54       ` Geert Uytterhoeven
  0 siblings, 1 reply; 31+ messages in thread
From: Andy Shevchenko @ 2022-03-29 16:42 UTC (permalink / raw)
  To: Neil Armstrong
  Cc: Qianggui Song, Krzysztof Kozlowski, Fabien Dessenne, linux-gpio,
	linux-arm-kernel, linux-amlogic, linux-kernel, openbmc,
	linux-renesas-soc, linux-samsung-soc, linux-stm32, Linus Walleij,
	Kevin Hilman, Jerome Brunet, Martin Blumenstingl, Andrew Lunn,
	Gregory Clement, Sebastian Hesselbarth, Avi Fishman,
	Tomer Maimon, Tali Perry, Patrick Venture, Nancy Yuen,
	Benjamin Fair, Geert Uytterhoeven, Tomasz Figa,
	Sylwester Nawrocki, Alim Akhtar, Maxime Coquelin,
	Alexandre Torgue, Bartosz Golaszewski, Philipp Zabel

On Tue, Mar 29, 2022 at 06:13:19PM +0200, Neil Armstrong wrote:
> On 29/03/2022 17:29, Andy Shevchenko wrote:
> > Rename REG_* to * as a prerequisite for enabling COMPILE_TEST.
> 
> What error do you hit ?

arch/x86/include/asm/arch_hweight.h:9:17: error: expected identifier before string constant
9 | #define REG_OUT "a"
  |                 ^~~
drivers/pinctrl/meson/pinctrl-meson.h:69:9: note: in expansion of macro ‘REG_OUT’
69 |         REG_OUT,

And some more.

> MREG_ is rather ugly, something like PINCONF_REG_ or more simpler MESON_REG_ would be more appropriate.

Fine with me.

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH v2 09/13] pinctrl: meson: Rename REG_* to MREG_*
  2022-03-29 16:42     ` Andy Shevchenko
@ 2022-03-30  8:54       ` Geert Uytterhoeven
  2022-03-30  9:09         ` Neil Armstrong
  0 siblings, 1 reply; 31+ messages in thread
From: Geert Uytterhoeven @ 2022-03-30  8:54 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Neil Armstrong, Qianggui Song, Krzysztof Kozlowski,
	Fabien Dessenne, open list:GPIO SUBSYSTEM, Linux ARM,
	open list:ARM/Amlogic Meson...,
	Linux Kernel Mailing List, openbmc, Linux-Renesas,
	linux-samsung-soc, linux-stm32, Linus Walleij, Kevin Hilman,
	Jerome Brunet, Martin Blumenstingl, Andrew Lunn, Gregory Clement,
	Sebastian Hesselbarth, Avi Fishman, Tomer Maimon, Tali Perry,
	Patrick Venture, Nancy Yuen, Benjamin Fair, Geert Uytterhoeven,
	Tomasz Figa, Sylwester Nawrocki, Alim Akhtar, Maxime Coquelin,
	Alexandre Torgue, Bartosz Golaszewski, Philipp Zabel

Hi Andy,

On Tue, Mar 29, 2022 at 6:47 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
> On Tue, Mar 29, 2022 at 06:13:19PM +0200, Neil Armstrong wrote:
> > On 29/03/2022 17:29, Andy Shevchenko wrote:
> > > Rename REG_* to * as a prerequisite for enabling COMPILE_TEST.
> >
> > What error do you hit ?
>
> arch/x86/include/asm/arch_hweight.h:9:17: error: expected identifier before string constant
> 9 | #define REG_OUT "a"
>   |                 ^~~

Perhaps REG_{OUT,IN} in arch/x86/include/asm/arch_hweight.h should be
renamed instead, as this is a generic header file that can be included
anywhere, while the REG_{OUT,IN} definitions are only used locally,
in the header file?

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH v2 09/13] pinctrl: meson: Rename REG_* to MREG_*
  2022-03-30  8:54       ` Geert Uytterhoeven
@ 2022-03-30  9:09         ` Neil Armstrong
  2022-03-30  9:18           ` Andy Shevchenko
  0 siblings, 1 reply; 31+ messages in thread
From: Neil Armstrong @ 2022-03-30  9:09 UTC (permalink / raw)
  To: Geert Uytterhoeven, Andy Shevchenko
  Cc: Qianggui Song, Krzysztof Kozlowski, Fabien Dessenne,
	open list:GPIO SUBSYSTEM, Linux ARM,
	open list:ARM/Amlogic Meson...,
	Linux Kernel Mailing List, openbmc, Linux-Renesas,
	linux-samsung-soc, linux-stm32, Linus Walleij, Kevin Hilman,
	Jerome Brunet, Martin Blumenstingl, Andrew Lunn, Gregory Clement,
	Sebastian Hesselbarth, Avi Fishman, Tomer Maimon, Tali Perry,
	Patrick Venture, Nancy Yuen, Benjamin Fair, Geert Uytterhoeven,
	Tomasz Figa, Sylwester Nawrocki, Alim Akhtar, Maxime Coquelin,
	Alexandre Torgue, Bartosz Golaszewski, Philipp Zabel

On 30/03/2022 10:54, Geert Uytterhoeven wrote:
> Hi Andy,
> 
> On Tue, Mar 29, 2022 at 6:47 PM Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
>> On Tue, Mar 29, 2022 at 06:13:19PM +0200, Neil Armstrong wrote:
>>> On 29/03/2022 17:29, Andy Shevchenko wrote:
>>>> Rename REG_* to * as a prerequisite for enabling COMPILE_TEST.
>>>
>>> What error do you hit ?
>>
>> arch/x86/include/asm/arch_hweight.h:9:17: error: expected identifier before string constant
>> 9 | #define REG_OUT "a"
>>    |                 ^~~
> 
> Perhaps REG_{OUT,IN} in arch/x86/include/asm/arch_hweight.h should be
> renamed instead, as this is a generic header file that can be included
> anywhere, while the REG_{OUT,IN} definitions are only used locally,
> in the header file?

Even better, those REG_OUT/REG_IN should be undefined at the end of the header since only
used in the headers inline functions:
==============><==================================
diff --git a/arch/x86/include/asm/arch_hweight.h b/arch/x86/include/asm/arch_hweight.h
index ba88edd0d58b..139a4b0a2a14 100644
--- a/arch/x86/include/asm/arch_hweight.h
+++ b/arch/x86/include/asm/arch_hweight.h
@@ -52,4 +52,7 @@ static __always_inline unsigned long __arch_hweight64(__u64 w)
  }
  #endif /* CONFIG_X86_32 */

+#undef REG_IN
+#undef REG_OUT
+
  #endif
==============><==================================

Neil

> 
> Gr{oetje,eeting}s,
> 
>                          Geert
> 
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
> 
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like that.
>                                  -- Linus Torvalds


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* Re: [PATCH v2 09/13] pinctrl: meson: Rename REG_* to MREG_*
  2022-03-30  9:09         ` Neil Armstrong
@ 2022-03-30  9:18           ` Andy Shevchenko
  2022-03-30 15:22             ` Neil Armstrong
  0 siblings, 1 reply; 31+ messages in thread
From: Andy Shevchenko @ 2022-03-30  9:18 UTC (permalink / raw)
  To: Neil Armstrong
  Cc: Geert Uytterhoeven, Qianggui Song, Krzysztof Kozlowski,
	Fabien Dessenne, open list:GPIO SUBSYSTEM, Linux ARM,
	open list:ARM/Amlogic Meson...,
	Linux Kernel Mailing List, openbmc, Linux-Renesas,
	linux-samsung-soc, linux-stm32, Linus Walleij, Kevin Hilman,
	Jerome Brunet, Martin Blumenstingl, Andrew Lunn, Gregory Clement,
	Sebastian Hesselbarth, Avi Fishman, Tomer Maimon, Tali Perry,
	Patrick Venture, Nancy Yuen, Benjamin Fair, Geert Uytterhoeven,
	Tomasz Figa, Sylwester Nawrocki, Alim Akhtar, Maxime Coquelin,
	Alexandre Torgue, Bartosz Golaszewski, Philipp Zabel

On Wed, Mar 30, 2022 at 11:09:11AM +0200, Neil Armstrong wrote:
> On 30/03/2022 10:54, Geert Uytterhoeven wrote:
> > On Tue, Mar 29, 2022 at 6:47 PM Andy Shevchenko
> > <andriy.shevchenko@linux.intel.com> wrote:
> > > On Tue, Mar 29, 2022 at 06:13:19PM +0200, Neil Armstrong wrote:
> > > > On 29/03/2022 17:29, Andy Shevchenko wrote:

...

> > > > What error do you hit ?
> > > 
> > > arch/x86/include/asm/arch_hweight.h:9:17: error: expected identifier before string constant
> > > 9 | #define REG_OUT "a"
> > >    |                 ^~~
> > 
> > Perhaps REG_{OUT,IN} in arch/x86/include/asm/arch_hweight.h should be
> > renamed instead, as this is a generic header file that can be included
> > anywhere, while the REG_{OUT,IN} definitions are only used locally,
> > in the header file?
> 
> Even better, those REG_OUT/REG_IN should be undefined at the end of the header since only
> used in the headers inline functions:
> ==============><==================================
> diff --git a/arch/x86/include/asm/arch_hweight.h b/arch/x86/include/asm/arch_hweight.h
> index ba88edd0d58b..139a4b0a2a14 100644
> --- a/arch/x86/include/asm/arch_hweight.h
> +++ b/arch/x86/include/asm/arch_hweight.h
> @@ -52,4 +52,7 @@ static __always_inline unsigned long __arch_hweight64(__u64 w)
>  }
>  #endif /* CONFIG_X86_32 */
> 
> +#undef REG_IN
> +#undef REG_OUT
> +
>  #endif
> ==============><==================================

Can you submit a formal patch, please?


And I think it would be good to have my patch as well, so we do not depend on
the fate of the other one.

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH v2 06/13] pinctrl: renesas: rza1: Replace custom code by gpiochip_node_count() call
  2022-03-29 15:29 ` [PATCH v2 06/13] pinctrl: renesas: rza1: Replace custom code by gpiochip_node_count() call Andy Shevchenko
@ 2022-03-30  9:51   ` Geert Uytterhoeven
  0 siblings, 0 replies; 31+ messages in thread
From: Geert Uytterhoeven @ 2022-03-30  9:51 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Qianggui Song, Krzysztof Kozlowski, Fabien Dessenne,
	open list:GPIO SUBSYSTEM, Linux ARM,
	open list:ARM/Amlogic Meson...,
	Linux Kernel Mailing List, openbmc, Linux-Renesas,
	linux-samsung-soc, linux-stm32, Linus Walleij, Neil Armstrong,
	Kevin Hilman, Jerome Brunet, Martin Blumenstingl, Andrew Lunn,
	Gregory Clement, Sebastian Hesselbarth, Avi Fishman,
	Tomer Maimon, Tali Perry, Patrick Venture, Nancy Yuen,
	Benjamin Fair, Geert Uytterhoeven, Tomasz Figa,
	Sylwester Nawrocki, Alim Akhtar, Maxime Coquelin,
	Alexandre Torgue, Bartosz Golaszewski, Philipp Zabel

On Tue, Mar 29, 2022 at 5:29 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
> Since we have generic function to count GPIO controller nodes
> under a given device, there is no need to open code it. Replace
> custom code by gpiochip_node_count() call.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Geert Uytterhoeven <geert+renesas@glider.be>

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH v2 07/13] pinctrl: renesas: rza1: Switch to use for_each_gpiochip_node() helper
  2022-03-29 15:29 ` [PATCH v2 07/13] pinctrl: renesas: rza1: Switch to use for_each_gpiochip_node() helper Andy Shevchenko
@ 2022-03-30 10:00   ` Geert Uytterhoeven
  2022-03-30 12:16     ` Andy Shevchenko
  0 siblings, 1 reply; 31+ messages in thread
From: Geert Uytterhoeven @ 2022-03-30 10:00 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Qianggui Song, Krzysztof Kozlowski, Fabien Dessenne,
	open list:GPIO SUBSYSTEM, Linux ARM,
	open list:ARM/Amlogic Meson...,
	Linux Kernel Mailing List, openbmc, Linux-Renesas,
	linux-samsung-soc, linux-stm32, Linus Walleij, Neil Armstrong,
	Kevin Hilman, Jerome Brunet, Martin Blumenstingl, Andrew Lunn,
	Gregory Clement, Sebastian Hesselbarth, Avi Fishman,
	Tomer Maimon, Tali Perry, Patrick Venture, Nancy Yuen,
	Benjamin Fair, Geert Uytterhoeven, Tomasz Figa,
	Sylwester Nawrocki, Alim Akhtar, Maxime Coquelin,
	Alexandre Torgue, Bartosz Golaszewski, Philipp Zabel

Hi Andy,

On Tue, Mar 29, 2022 at 5:29 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
> Switch the code to use for_each_gpiochip_node() helper.
>
> While at it, in order to avoid additional churn in the future,
> switch to fwnode APIs where it makes sense.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Thanks for your patch!

> --- a/drivers/pinctrl/renesas/pinctrl-rza1.c
> +++ b/drivers/pinctrl/renesas/pinctrl-rza1.c

> @@ -1166,17 +1167,17 @@ static const struct pinmux_ops rza1_pinmux_ops = {
>   * @range: pin range to register to pinctrl core
>   */
>  static int rza1_parse_gpiochip(struct rza1_pinctrl *rza1_pctl,
> -                              struct device_node *np,
> +                              struct fwnode_handle *fwnode,
>                                struct gpio_chip *chip,
>                                struct pinctrl_gpio_range *range)
>  {
>         const char *list_name = "gpio-ranges";
> -       struct of_phandle_args of_args;
> +       struct fwnode_reference_args of_args;

fw_args?

>         unsigned int gpioport;
>         u32 pinctrl_base;
>         int ret;
>
> -       ret = of_parse_phandle_with_fixed_args(np, list_name, 3, 0, &of_args);
> +       ret = fwnode_property_get_reference_args(fwnode, list_name, NULL, 3, 0, &of_args);
>         if (ret) {
>                 dev_err(rza1_pctl->dev, "Unable to parse %s list property\n",
>                         list_name);
> @@ -1197,13 +1198,12 @@ static int rza1_parse_gpiochip(struct rza1_pinctrl *rza1_pctl,
>
>         *chip           = rza1_gpiochip_template;
>         chip->base      = -1;
> -       chip->label     = devm_kasprintf(rza1_pctl->dev, GFP_KERNEL, "%pOFn",
> -                                        np);
> +       chip->label     = devm_kasprintf(rza1_pctl->dev, GFP_KERNEL, "%pfw", fwnode);

This changes the label from e.g. "/soc/pinctrl@fcfe3000/gpio-11" to "gpio-11".

%pfwP?

>         if (!chip->label)
>                 return -ENOMEM;
>
>         chip->ngpio     = of_args.args[2];
> -       chip->of_node   = np;
> +       chip->fwnode    = fwnode;
>         chip->parent    = rza1_pctl->dev;
>
>         range->id       = gpioport;

With the above fixed:
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Geert Uytterhoeven <geert+renesas@glider.be>

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH v2 01/13] gpiolib: Introduce for_each_gpiochip_node() loop helper
  2022-03-29 15:29 ` [PATCH v2 01/13] gpiolib: Introduce for_each_gpiochip_node() loop helper Andy Shevchenko
@ 2022-03-30 10:00   ` Geert Uytterhoeven
  0 siblings, 0 replies; 31+ messages in thread
From: Geert Uytterhoeven @ 2022-03-30 10:00 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Qianggui Song, Krzysztof Kozlowski, Fabien Dessenne,
	open list:GPIO SUBSYSTEM, Linux ARM,
	open list:ARM/Amlogic Meson...,
	Linux Kernel Mailing List, openbmc, Linux-Renesas,
	linux-samsung-soc, linux-stm32, Linus Walleij, Neil Armstrong,
	Kevin Hilman, Jerome Brunet, Martin Blumenstingl, Andrew Lunn,
	Gregory Clement, Sebastian Hesselbarth, Avi Fishman,
	Tomer Maimon, Tali Perry, Patrick Venture, Nancy Yuen,
	Benjamin Fair, Geert Uytterhoeven, Tomasz Figa,
	Sylwester Nawrocki, Alim Akhtar, Maxime Coquelin,
	Alexandre Torgue, Bartosz Golaszewski, Philipp Zabel

On Tue, Mar 29, 2022 at 5:29 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
> Introduce for_each_gpiochip_node() loop helper which iterates over
> the GPIO controller child nodes of a given device.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH v2 02/13] gpiolib: Introduce gpiochip_node_count() helper
  2022-03-29 15:29 ` [PATCH v2 02/13] gpiolib: Introduce gpiochip_node_count() helper Andy Shevchenko
@ 2022-03-30 10:02   ` Geert Uytterhoeven
  2022-03-30 11:35     ` Andy Shevchenko
  0 siblings, 1 reply; 31+ messages in thread
From: Geert Uytterhoeven @ 2022-03-30 10:02 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Qianggui Song, Krzysztof Kozlowski, Fabien Dessenne,
	open list:GPIO SUBSYSTEM, Linux ARM,
	open list:ARM/Amlogic Meson...,
	Linux Kernel Mailing List, openbmc, Linux-Renesas,
	linux-samsung-soc, linux-stm32, Linus Walleij, Neil Armstrong,
	Kevin Hilman, Jerome Brunet, Martin Blumenstingl, Andrew Lunn,
	Gregory Clement, Sebastian Hesselbarth, Avi Fishman,
	Tomer Maimon, Tali Perry, Patrick Venture, Nancy Yuen,
	Benjamin Fair, Geert Uytterhoeven, Tomasz Figa,
	Sylwester Nawrocki, Alim Akhtar, Maxime Coquelin,
	Alexandre Torgue, Bartosz Golaszewski, Philipp Zabel

Hi Andy,

On Tue, Mar 29, 2022 at 5:29 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
> The gpiochip_node_count() helper iterates over the device child nodes that
> have the "gpio-controller" property set. It returns the number of such nodes
> under a given device.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Thanks for your patch!

> --- a/include/linux/gpio/driver.h
> +++ b/include/linux/gpio/driver.h
> @@ -755,4 +755,16 @@ static inline void gpiochip_unlock_as_irq(struct gpio_chip *gc,
>         device_for_each_child_node(dev, child)                                  \
>                 if (!fwnode_property_present(child, "gpio-controller")) {} else
>
> +static inline unsigned int gpiochip_node_count(struct device *dev)
> +{
> +       struct fwnode_handle *child;
> +       unsigned int count;

Preinitialize to zero?

> +
> +       count = 0;
> +       for_each_gpiochip_node(dev, child)
> +               count++;
> +
> +       return count;
> +}
> +
>  #endif /* __LINUX_GPIO_DRIVER_H */

Regardless:
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH v2 02/13] gpiolib: Introduce gpiochip_node_count() helper
  2022-03-30 10:02   ` Geert Uytterhoeven
@ 2022-03-30 11:35     ` Andy Shevchenko
  0 siblings, 0 replies; 31+ messages in thread
From: Andy Shevchenko @ 2022-03-30 11:35 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Qianggui Song, Krzysztof Kozlowski, Fabien Dessenne,
	open list:GPIO SUBSYSTEM, Linux ARM,
	open list:ARM/Amlogic Meson...,
	Linux Kernel Mailing List, openbmc, Linux-Renesas,
	linux-samsung-soc, linux-stm32, Linus Walleij, Neil Armstrong,
	Kevin Hilman, Jerome Brunet, Martin Blumenstingl, Andrew Lunn,
	Gregory Clement, Sebastian Hesselbarth, Avi Fishman,
	Tomer Maimon, Tali Perry, Patrick Venture, Nancy Yuen,
	Benjamin Fair, Geert Uytterhoeven, Tomasz Figa,
	Sylwester Nawrocki, Alim Akhtar, Maxime Coquelin,
	Alexandre Torgue, Bartosz Golaszewski, Philipp Zabel

On Wed, Mar 30, 2022 at 12:02:07PM +0200, Geert Uytterhoeven wrote:
> On Tue, Mar 29, 2022 at 5:29 PM Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:

...

> > +       unsigned int count;
> 
> Preinitialize to zero?

Whatever for what consensus will be achieved. Initially I have that way,
then I changed.

> > +       count = 0;
> > +       for_each_gpiochip_node(dev, child)
> > +               count++;
> 
> Regardless:
> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
> Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>

Thanks!

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH v2 07/13] pinctrl: renesas: rza1: Switch to use for_each_gpiochip_node() helper
  2022-03-30 10:00   ` Geert Uytterhoeven
@ 2022-03-30 12:16     ` Andy Shevchenko
  2022-03-30 12:21       ` Geert Uytterhoeven
  0 siblings, 1 reply; 31+ messages in thread
From: Andy Shevchenko @ 2022-03-30 12:16 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Qianggui Song, Krzysztof Kozlowski, Fabien Dessenne,
	open list:GPIO SUBSYSTEM, Linux ARM,
	open list:ARM/Amlogic Meson...,
	Linux Kernel Mailing List, openbmc, Linux-Renesas,
	linux-samsung-soc, linux-stm32, Linus Walleij, Neil Armstrong,
	Kevin Hilman, Jerome Brunet, Martin Blumenstingl, Andrew Lunn,
	Gregory Clement, Sebastian Hesselbarth, Avi Fishman,
	Tomer Maimon, Tali Perry, Patrick Venture, Nancy Yuen,
	Benjamin Fair, Geert Uytterhoeven, Tomasz Figa,
	Sylwester Nawrocki, Alim Akhtar, Maxime Coquelin,
	Alexandre Torgue, Bartosz Golaszewski, Philipp Zabel

On Wed, Mar 30, 2022 at 12:00:27PM +0200, Geert Uytterhoeven wrote:
> On Tue, Mar 29, 2022 at 5:29 PM Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:

...

> > +       struct fwnode_reference_args of_args;
> 
> fw_args?

Perhaps just args as other drivers do?

...

> > -       chip->label     = devm_kasprintf(rza1_pctl->dev, GFP_KERNEL, "%pOFn",
> > -                                        np);
> > +       chip->label     = devm_kasprintf(rza1_pctl->dev, GFP_KERNEL, "%pfw", fwnode);
> 
> This changes the label from e.g. "/soc/pinctrl@fcfe3000/gpio-11" to "gpio-11".

Hmm... It seems other way around, i.e. it changes from the name to full name.

> %pfwP?

But conclusion here is correct. Good catch!

...

> With the above fixed:
> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
> Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>
> Acked-by: Geert Uytterhoeven <geert+renesas@glider.be>

Thanks for review and testing!

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH v2 07/13] pinctrl: renesas: rza1: Switch to use for_each_gpiochip_node() helper
  2022-03-30 12:16     ` Andy Shevchenko
@ 2022-03-30 12:21       ` Geert Uytterhoeven
  0 siblings, 0 replies; 31+ messages in thread
From: Geert Uytterhoeven @ 2022-03-30 12:21 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Qianggui Song, Krzysztof Kozlowski, Fabien Dessenne,
	open list:GPIO SUBSYSTEM, Linux ARM,
	open list:ARM/Amlogic Meson...,
	Linux Kernel Mailing List, openbmc, Linux-Renesas,
	linux-samsung-soc, linux-stm32, Linus Walleij, Neil Armstrong,
	Kevin Hilman, Jerome Brunet, Martin Blumenstingl, Andrew Lunn,
	Gregory Clement, Sebastian Hesselbarth, Avi Fishman,
	Tomer Maimon, Tali Perry, Patrick Venture, Nancy Yuen,
	Benjamin Fair, Geert Uytterhoeven, Tomasz Figa,
	Sylwester Nawrocki, Alim Akhtar, Maxime Coquelin,
	Alexandre Torgue, Bartosz Golaszewski, Philipp Zabel

Hi Andy,

On Wed, Mar 30, 2022 at 2:17 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
> On Wed, Mar 30, 2022 at 12:00:27PM +0200, Geert Uytterhoeven wrote:
> > On Tue, Mar 29, 2022 at 5:29 PM Andy Shevchenko
> > <andriy.shevchenko@linux.intel.com> wrote:
>
> ...
>
> > > +       struct fwnode_reference_args of_args;
> >
> > fw_args?
>
> Perhaps just args as other drivers do?

Fine for me.

> > > -       chip->label     = devm_kasprintf(rza1_pctl->dev, GFP_KERNEL, "%pOFn",
> > > -                                        np);
> > > +       chip->label     = devm_kasprintf(rza1_pctl->dev, GFP_KERNEL, "%pfw", fwnode);
> >
> > This changes the label from e.g. "/soc/pinctrl@fcfe3000/gpio-11" to "gpio-11".
>
> Hmm... It seems other way around, i.e. it changes from the name to full name.

Oops, sorry about that.
(I accidentally included the change from testing "%pfwP" ;-)

>
> > %pfwP?
>
> But conclusion here is correct. Good catch!

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH v2 04/13] pinctrl: stm32: Switch to use for_each_gpiochip_node() helper
  2022-03-29 15:29 ` [PATCH v2 04/13] pinctrl: stm32: Switch to use for_each_gpiochip_node() helper Andy Shevchenko
@ 2022-03-30 12:32   ` Fabien DESSENNE
  2022-03-30 13:01     ` Andy Shevchenko
  0 siblings, 1 reply; 31+ messages in thread
From: Fabien DESSENNE @ 2022-03-30 12:32 UTC (permalink / raw)
  To: Andy Shevchenko, Qianggui Song, Krzysztof Kozlowski, linux-gpio,
	linux-arm-kernel, linux-amlogic, linux-kernel, openbmc,
	linux-renesas-soc, linux-samsung-soc, linux-stm32
  Cc: Linus Walleij, Neil Armstrong, Kevin Hilman, Jerome Brunet,
	Martin Blumenstingl, Andrew Lunn, Gregory Clement,
	Sebastian Hesselbarth, Avi Fishman, Tomer Maimon, Tali Perry,
	Patrick Venture, Nancy Yuen, Benjamin Fair, Geert Uytterhoeven,
	Tomasz Figa, Sylwester Nawrocki, Alim Akhtar, Maxime Coquelin,
	Alexandre Torgue, Bartosz Golaszewski, Philipp Zabel

Hi Andy


Thank you for the patch.

Fabien

On 29/03/2022 17:29, Andy Shevchenko wrote:
> Switch the code to use for_each_gpiochip_node() helper.
> 
> While at it, in order to avoid additional churn in the future,
> switch to fwnode APIs where it makes sense.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Fabien Dessenne <fabien.dessenne@foss.st.com>

> ---
>   drivers/pinctrl/stm32/pinctrl-stm32.c | 72 ++++++++++++---------------
>   1 file changed, 33 insertions(+), 39 deletions(-)
> 
> diff --git a/drivers/pinctrl/stm32/pinctrl-stm32.c b/drivers/pinctrl/stm32/pinctrl-stm32.c
> index 4043a44211f0..3e2f1e3a84be 100644
> --- a/drivers/pinctrl/stm32/pinctrl-stm32.c
> +++ b/drivers/pinctrl/stm32/pinctrl-stm32.c
> @@ -24,6 +24,7 @@
>   #include <linux/pinctrl/pinctrl.h>
>   #include <linux/pinctrl/pinmux.h>
>   #include <linux/platform_device.h>
> +#include <linux/property.h>
>   #include <linux/regmap.h>
>   #include <linux/reset.h>
>   #include <linux/slab.h>
> @@ -1215,13 +1216,12 @@ static const struct pinconf_ops stm32_pconf_ops = {
>   	.pin_config_dbg_show	= stm32_pconf_dbg_show,
>   };
>   
> -static int stm32_gpiolib_register_bank(struct stm32_pinctrl *pctl,
> -	struct device_node *np)
> +static int stm32_gpiolib_register_bank(struct stm32_pinctrl *pctl, struct fwnode_handle *fwnode)
>   {
>   	struct stm32_gpio_bank *bank = &pctl->banks[pctl->nbanks];
>   	int bank_ioport_nr;
>   	struct pinctrl_gpio_range *range = &bank->range;
> -	struct of_phandle_args args;
> +	struct fwnode_reference_args args;
>   	struct device *dev = pctl->dev;
>   	struct resource res;
>   	int npins = STM32_GPIO_PINS_PER_BANK;
> @@ -1230,7 +1230,7 @@ static int stm32_gpiolib_register_bank(struct stm32_pinctrl *pctl,
>   	if (!IS_ERR(bank->rstc))
>   		reset_control_deassert(bank->rstc);
>   
> -	if (of_address_to_resource(np, 0, &res))
> +	if (of_address_to_resource(to_of_node(fwnode), 0, &res))
>   		return -ENODEV;
>   
>   	bank->base = devm_ioremap_resource(dev, &res);
> @@ -1245,15 +1245,15 @@ static int stm32_gpiolib_register_bank(struct stm32_pinctrl *pctl,
>   
>   	bank->gpio_chip = stm32_gpio_template;
>   
> -	of_property_read_string(np, "st,bank-name", &bank->gpio_chip.label);
> +	fwnode_property_read_string(fwnode, "st,bank-name", &bank->gpio_chip.label);
>   
> -	if (!of_parse_phandle_with_fixed_args(np, "gpio-ranges", 3, i, &args)) {
> +	if (!fwnode_property_get_reference_args(fwnode, "gpio-ranges", NULL, 3, i, &args)) {
>   		bank_nr = args.args[1] / STM32_GPIO_PINS_PER_BANK;
>   		bank->gpio_chip.base = args.args[1];
>   
>   		/* get the last defined gpio line (offset + nb of pins) */
>   		npins = args.args[0] + args.args[2];
> -		while (!of_parse_phandle_with_fixed_args(np, "gpio-ranges", 3, ++i, &args))
> +		while (!fwnode_property_get_reference_args(fwnode, "gpio-ranges", NULL, 3, ++i, &args))
>   			npins = max(npins, (int)(args.args[0] + args.args[2]));
>   	} else {
>   		bank_nr = pctl->nbanks;
> @@ -1268,20 +1268,20 @@ static int stm32_gpiolib_register_bank(struct stm32_pinctrl *pctl,
>   				       &pctl->banks[bank_nr].range);
>   	}
>   
> -	if (of_property_read_u32(np, "st,bank-ioport", &bank_ioport_nr))
> +	if (fwnode_property_read_u32(fwnode, "st,bank-ioport", &bank_ioport_nr))
>   		bank_ioport_nr = bank_nr;
>   
>   	bank->gpio_chip.base = bank_nr * STM32_GPIO_PINS_PER_BANK;
>   
>   	bank->gpio_chip.ngpio = npins;
> -	bank->gpio_chip.of_node = np;
> +	bank->gpio_chip.fwnode = fwnode;
>   	bank->gpio_chip.parent = dev;
>   	bank->bank_nr = bank_nr;
>   	bank->bank_ioport_nr = bank_ioport_nr;
>   	spin_lock_init(&bank->lock);
>   
>   	/* create irq hierarchical domain */
> -	bank->fwnode = of_node_to_fwnode(np);
> +	bank->fwnode = fwnode;
>   
>   	bank->domain = irq_domain_create_hierarchy(pctl->domain, 0,
>   					STM32_GPIO_IRQ_LINE, bank->fwnode,
> @@ -1418,7 +1418,7 @@ static int stm32_pctrl_create_pins_tab(struct stm32_pinctrl *pctl,
>   int stm32_pctl_probe(struct platform_device *pdev)
>   {
>   	struct device_node *np = pdev->dev.of_node;
> -	struct device_node *child;
> +	struct fwnode_handle *child;
>   	const struct of_device_id *match;
>   	struct device *dev = &pdev->dev;
>   	struct stm32_pinctrl *pctl;
> @@ -1525,40 +1525,34 @@ int stm32_pctl_probe(struct platform_device *pdev)
>   		return -ENOMEM;
>   
>   	i = 0;
> -	for_each_available_child_of_node(np, child) {
> +	for_each_gpiochip_node(dev, child) {
>   		struct stm32_gpio_bank *bank = &pctl->banks[i];
> +		struct device_node *np = to_of_node(child);
>   
> -		if (of_property_read_bool(child, "gpio-controller")) {
> -			bank->rstc = of_reset_control_get_exclusive(child,
> -								    NULL);
> -			if (PTR_ERR(bank->rstc) == -EPROBE_DEFER) {
> -				of_node_put(child);
> -				return -EPROBE_DEFER;
> -			}
> -
> -			bank->clk = of_clk_get_by_name(child, NULL);
> -			if (IS_ERR(bank->clk)) {
> -				if (PTR_ERR(bank->clk) != -EPROBE_DEFER)
> -					dev_err(dev,
> -						"failed to get clk (%ld)\n",
> -						PTR_ERR(bank->clk));
> -				of_node_put(child);
> -				return PTR_ERR(bank->clk);
> -			}
> -			i++;
> +		bank->rstc = of_reset_control_get_exclusive(np, NULL);
> +		if (PTR_ERR(bank->rstc) == -EPROBE_DEFER) {
> +			fwnode_handle_put(child);
> +			return -EPROBE_DEFER;
>   		}
> -	}
>   
> -	for_each_available_child_of_node(np, child) {
> -		if (of_property_read_bool(child, "gpio-controller")) {
> -			ret = stm32_gpiolib_register_bank(pctl, child);
> -			if (ret) {
> -				of_node_put(child);
> -				return ret;
> -			}
> +		bank->clk = of_clk_get_by_name(np, NULL);
> +		if (IS_ERR(bank->clk)) {
> +			if (PTR_ERR(bank->clk) != -EPROBE_DEFER)
> +				dev_err(dev, "failed to get clk (%ld)\n", PTR_ERR(bank->clk));
> +			fwnode_handle_put(child);
> +			return PTR_ERR(bank->clk);
> +		}
> +		i++;
> +	}
>   
> -			pctl->nbanks++;
> +	for_each_gpiochip_node(dev, child) {
> +		ret = stm32_gpiolib_register_bank(pctl, child);
> +		if (ret) {
> +			fwnode_handle_put(child);
> +			return ret;
>   		}
> +
> +		pctl->nbanks++;
>   	}
>   
>   	dev_info(dev, "Pinctrl STM32 initialized\n");

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH v2 04/13] pinctrl: stm32: Switch to use for_each_gpiochip_node() helper
  2022-03-30 12:32   ` Fabien DESSENNE
@ 2022-03-30 13:01     ` Andy Shevchenko
  0 siblings, 0 replies; 31+ messages in thread
From: Andy Shevchenko @ 2022-03-30 13:01 UTC (permalink / raw)
  To: Fabien DESSENNE
  Cc: Qianggui Song, Krzysztof Kozlowski, linux-gpio, linux-arm-kernel,
	linux-amlogic, linux-kernel, openbmc, linux-renesas-soc,
	linux-samsung-soc, linux-stm32, Linus Walleij, Neil Armstrong,
	Kevin Hilman, Jerome Brunet, Martin Blumenstingl, Andrew Lunn,
	Gregory Clement, Sebastian Hesselbarth, Avi Fishman,
	Tomer Maimon, Tali Perry, Patrick Venture, Nancy Yuen,
	Benjamin Fair, Geert Uytterhoeven, Tomasz Figa,
	Sylwester Nawrocki, Alim Akhtar, Maxime Coquelin,
	Alexandre Torgue, Bartosz Golaszewski, Philipp Zabel

On Wed, Mar 30, 2022 at 02:32:36PM +0200, Fabien DESSENNE wrote:
> Hi Andy
> 
> 
> Thank you for the patch.
> 
> Fabien
> 
> On 29/03/2022 17:29, Andy Shevchenko wrote:
> > Switch the code to use for_each_gpiochip_node() helper.
> > 
> > While at it, in order to avoid additional churn in the future,
> > switch to fwnode APIs where it makes sense.
> > 
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Reviewed-by: Fabien Dessenne <fabien.dessenne@foss.st.com>

Thank you for the prompt review!

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH v2 09/13] pinctrl: meson: Rename REG_* to MREG_*
  2022-03-30  9:18           ` Andy Shevchenko
@ 2022-03-30 15:22             ` Neil Armstrong
  2022-03-30 15:51               ` Andy Shevchenko
  0 siblings, 1 reply; 31+ messages in thread
From: Neil Armstrong @ 2022-03-30 15:22 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Geert Uytterhoeven, Qianggui Song, Krzysztof Kozlowski,
	Fabien Dessenne, open list:GPIO SUBSYSTEM, Linux ARM,
	open list:ARM/Amlogic Meson...,
	Linux Kernel Mailing List, openbmc, Linux-Renesas,
	linux-samsung-soc, linux-stm32, Linus Walleij, Kevin Hilman,
	Jerome Brunet, Martin Blumenstingl, Andrew Lunn, Gregory Clement,
	Sebastian Hesselbarth, Avi Fishman, Tomer Maimon, Tali Perry,
	Patrick Venture, Nancy Yuen, Benjamin Fair, Geert Uytterhoeven,
	Tomasz Figa, Sylwester Nawrocki, Alim Akhtar, Maxime Coquelin,
	Alexandre Torgue, Bartosz Golaszewski, Philipp Zabel

On 30/03/2022 11:18, Andy Shevchenko wrote:
> On Wed, Mar 30, 2022 at 11:09:11AM +0200, Neil Armstrong wrote:
>> On 30/03/2022 10:54, Geert Uytterhoeven wrote:
>>> On Tue, Mar 29, 2022 at 6:47 PM Andy Shevchenko
>>> <andriy.shevchenko@linux.intel.com> wrote:
>>>> On Tue, Mar 29, 2022 at 06:13:19PM +0200, Neil Armstrong wrote:
>>>>> On 29/03/2022 17:29, Andy Shevchenko wrote:
> 
> ...
> 
>>>>> What error do you hit ?
>>>>
>>>> arch/x86/include/asm/arch_hweight.h:9:17: error: expected identifier before string constant
>>>> 9 | #define REG_OUT "a"
>>>>     |                 ^~~
>>>
>>> Perhaps REG_{OUT,IN} in arch/x86/include/asm/arch_hweight.h should be
>>> renamed instead, as this is a generic header file that can be included
>>> anywhere, while the REG_{OUT,IN} definitions are only used locally,
>>> in the header file?
>>
>> Even better, those REG_OUT/REG_IN should be undefined at the end of the header since only
>> used in the headers inline functions:
>> ==============><==================================
>> diff --git a/arch/x86/include/asm/arch_hweight.h b/arch/x86/include/asm/arch_hweight.h
>> index ba88edd0d58b..139a4b0a2a14 100644
>> --- a/arch/x86/include/asm/arch_hweight.h
>> +++ b/arch/x86/include/asm/arch_hweight.h
>> @@ -52,4 +52,7 @@ static __always_inline unsigned long __arch_hweight64(__u64 w)
>>   }
>>   #endif /* CONFIG_X86_32 */
>>
>> +#undef REG_IN
>> +#undef REG_OUT
>> +
>>   #endif
>> ==============><==================================
> 
> Can you submit a formal patch, please?

I'll submit it separately

> 
> 
> And I think it would be good to have my patch as well, so we do not depend on
> the fate of the other one.
> 

Yes sure

Thanks,
Neil

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH v2 09/13] pinctrl: meson: Rename REG_* to MREG_*
  2022-03-30 15:22             ` Neil Armstrong
@ 2022-03-30 15:51               ` Andy Shevchenko
  0 siblings, 0 replies; 31+ messages in thread
From: Andy Shevchenko @ 2022-03-30 15:51 UTC (permalink / raw)
  To: Neil Armstrong
  Cc: Geert Uytterhoeven, Qianggui Song, Krzysztof Kozlowski,
	Fabien Dessenne, open list:GPIO SUBSYSTEM, Linux ARM,
	open list:ARM/Amlogic Meson...,
	Linux Kernel Mailing List, openbmc, Linux-Renesas,
	linux-samsung-soc, linux-stm32, Linus Walleij, Kevin Hilman,
	Jerome Brunet, Martin Blumenstingl, Andrew Lunn, Gregory Clement,
	Sebastian Hesselbarth, Avi Fishman, Tomer Maimon, Tali Perry,
	Patrick Venture, Nancy Yuen, Benjamin Fair, Geert Uytterhoeven,
	Tomasz Figa, Sylwester Nawrocki, Alim Akhtar, Maxime Coquelin,
	Alexandre Torgue, Bartosz Golaszewski, Philipp Zabel

On Wed, Mar 30, 2022 at 05:22:56PM +0200, Neil Armstrong wrote:
> On 30/03/2022 11:18, Andy Shevchenko wrote:

...

> > > > > > What error do you hit ?
> > > > > 
> > > > > arch/x86/include/asm/arch_hweight.h:9:17: error: expected identifier before string constant
> > > > > 9 | #define REG_OUT "a"
> > > > >     |                 ^~~
> > > > 
> > > > Perhaps REG_{OUT,IN} in arch/x86/include/asm/arch_hweight.h should be
> > > > renamed instead, as this is a generic header file that can be included
> > > > anywhere, while the REG_{OUT,IN} definitions are only used locally,
> > > > in the header file?
> > > 
> > > Even better, those REG_OUT/REG_IN should be undefined at the end of the header since only
> > > used in the headers inline functions:
> > > ==============><==================================
> > > diff --git a/arch/x86/include/asm/arch_hweight.h b/arch/x86/include/asm/arch_hweight.h
> > > index ba88edd0d58b..139a4b0a2a14 100644
> > > --- a/arch/x86/include/asm/arch_hweight.h
> > > +++ b/arch/x86/include/asm/arch_hweight.h
> > > @@ -52,4 +52,7 @@ static __always_inline unsigned long __arch_hweight64(__u64 w)
> > >   }
> > >   #endif /* CONFIG_X86_32 */
> > > 
> > > +#undef REG_IN
> > > +#undef REG_OUT
> > > +
> > >   #endif
> > > ==============><==================================
> > 
> > Can you submit a formal patch, please?
> 
> I'll submit it separately

Sure!

> > And I think it would be good to have my patch as well, so we do not depend on
> > the fate of the other one.
> 
> Yes sure

Thanks for acknowledging and review!

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 31+ messages in thread

end of thread, other threads:[~2022-03-30 15:52 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-29 15:29 [PATCH v2 00/13] gpiolib: Two new helpers and way toward fwnode Andy Shevchenko
2022-03-29 15:29 ` [PATCH v2 01/13] gpiolib: Introduce for_each_gpiochip_node() loop helper Andy Shevchenko
2022-03-30 10:00   ` Geert Uytterhoeven
2022-03-29 15:29 ` [PATCH v2 02/13] gpiolib: Introduce gpiochip_node_count() helper Andy Shevchenko
2022-03-30 10:02   ` Geert Uytterhoeven
2022-03-30 11:35     ` Andy Shevchenko
2022-03-29 15:29 ` [PATCH v2 03/13] pinctrl: stm32: Replace custom code by gpiochip_node_count() call Andy Shevchenko
2022-03-29 15:29 ` [PATCH v2 04/13] pinctrl: stm32: Switch to use for_each_gpiochip_node() helper Andy Shevchenko
2022-03-30 12:32   ` Fabien DESSENNE
2022-03-30 13:01     ` Andy Shevchenko
2022-03-29 15:29 ` [PATCH v2 05/13] pinctrl: samsung: " Andy Shevchenko
2022-03-29 15:29 ` [PATCH v2 06/13] pinctrl: renesas: rza1: Replace custom code by gpiochip_node_count() call Andy Shevchenko
2022-03-30  9:51   ` Geert Uytterhoeven
2022-03-29 15:29 ` [PATCH v2 07/13] pinctrl: renesas: rza1: Switch to use for_each_gpiochip_node() helper Andy Shevchenko
2022-03-30 10:00   ` Geert Uytterhoeven
2022-03-30 12:16     ` Andy Shevchenko
2022-03-30 12:21       ` Geert Uytterhoeven
2022-03-29 15:29 ` [PATCH v2 08/13] pinctrl: npcm7xx: " Andy Shevchenko
2022-03-29 15:29 ` [PATCH v2 09/13] pinctrl: meson: Rename REG_* to MREG_* Andy Shevchenko
2022-03-29 16:13   ` Neil Armstrong
2022-03-29 16:42     ` Andy Shevchenko
2022-03-30  8:54       ` Geert Uytterhoeven
2022-03-30  9:09         ` Neil Armstrong
2022-03-30  9:18           ` Andy Shevchenko
2022-03-30 15:22             ` Neil Armstrong
2022-03-30 15:51               ` Andy Shevchenko
2022-03-29 15:29 ` [PATCH v2 10/13] pinctrl: meson: Enable COMPILE_TEST Andy Shevchenko
2022-03-29 16:10   ` Neil Armstrong
2022-03-29 15:29 ` [PATCH v2 11/13] pinctrl: meson: Replace custom code by gpiochip_node_count() call Andy Shevchenko
2022-03-29 15:29 ` [PATCH v2 12/13] pinctrl: armada-37xx: Switch to use fwnode instead of of_node Andy Shevchenko
2022-03-29 15:29 ` [PATCH v2 13/13] pinctrl: armada-37xx: Reuse GPIO fwnode in armada_37xx_irqchip_register() Andy Shevchenko

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).