From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Qianggui Song <qianggui.song@amlogic.com>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Geert Uytterhoeven <geert+renesas@glider.be>,
Krzysztof Kozlowski <krzk@kernel.org>,
Marc Zyngier <maz@kernel.org>,
Fabien Dessenne <fabien.dessenne@foss.st.com>,
Linus Walleij <linus.walleij@linaro.org>,
linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org,
openbmc@lists.ozlabs.org, linux-renesas-soc@vger.kernel.org,
linux-samsung-soc@vger.kernel.org,
linux-stm32@st-md-mailman.stormreply.com
Cc: Neil Armstrong <narmstrong@baylibre.com>,
Kevin Hilman <khilman@baylibre.com>,
Jerome Brunet <jbrunet@baylibre.com>,
Martin Blumenstingl <martin.blumenstingl@googlemail.com>,
Andrew Lunn <andrew@lunn.ch>,
Gregory Clement <gregory.clement@bootlin.com>,
Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>,
Avi Fishman <avifishman70@gmail.com>,
Tomer Maimon <tmaimon77@gmail.com>,
Tali Perry <tali.perry1@gmail.com>,
Patrick Venture <venture@google.com>,
Nancy Yuen <yuenn@google.com>,
Benjamin Fair <benjaminfair@google.com>,
Tomasz Figa <tomasz.figa@gmail.com>,
Sylwester Nawrocki <s.nawrocki@samsung.com>,
Alim Akhtar <alim.akhtar@samsung.com>,
Maxime Coquelin <mcoquelin.stm32@gmail.com>,
Alexandre Torgue <alexandre.torgue@foss.st.com>,
Bartosz Golaszewski <brgl@bgdev.pl>,
Philipp Zabel <p.zabel@pengutronix.de>
Subject: [PATCH v4 07/13] pinctrl: renesas: rza1: Switch to use for_each_gpiochip_node() helper
Date: Fri, 1 Apr 2022 13:35:58 +0300 [thread overview]
Message-ID: <20220401103604.8705-8-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <20220401103604.8705-1-andriy.shevchenko@linux.intel.com>
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: Geert Uytterhoeven <geert+renesas@glider.be>
Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
drivers/pinctrl/renesas/pinctrl-rza1.c | 30 +++++++++++---------------
1 file changed, 13 insertions(+), 17 deletions(-)
diff --git a/drivers/pinctrl/renesas/pinctrl-rza1.c b/drivers/pinctrl/renesas/pinctrl-rza1.c
index acc00b1a955d..529c0fc4ec06 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"
@@ -1161,22 +1162,22 @@ static const struct pinmux_ops rza1_pinmux_ops = {
* defined by gpio device tree binding documentation.
*
* @rza1_pctl: RZ/A1 pin controller device
- * @np: of gpio-controller node
+ * @fwnode: gpio-controller firmware node
* @chip: gpio chip to register to gpiolib
* @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 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, &args);
if (ret) {
dev_err(rza1_pctl->dev, "Unable to parse %s list property\n",
list_name);
@@ -1187,7 +1188,7 @@ static int rza1_parse_gpiochip(struct rza1_pinctrl *rza1_pctl,
* Find out on which port this gpio-chip maps to by inspecting the
* second argument of the "gpio-ranges" property.
*/
- pinctrl_base = of_args.args[1];
+ pinctrl_base = args.args[1];
gpioport = RZA1_PIN_ID_TO_PORT(pinctrl_base);
if (gpioport >= RZA1_NPORTS) {
dev_err(rza1_pctl->dev,
@@ -1197,19 +1198,18 @@ 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->ngpio = args.args[2];
+ chip->label = devm_kasprintf(rza1_pctl->dev, GFP_KERNEL, "%pfwP", 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;
range->name = chip->label;
range->pin_base = range->base = pinctrl_base;
- range->npins = of_args.args[2];
+ range->npins = args.args[2];
range->gc = chip;
ret = devm_gpiochip_add_data(rza1_pctl->dev, chip,
@@ -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
next prev parent reply other threads:[~2022-04-01 10:36 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-01 10:35 [PATCH v4 00/13] gpiolib: Two new helpers and way toward fwnode Andy Shevchenko
2022-04-01 10:35 ` [PATCH v4 01/13] gpiolib: Introduce for_each_gpiochip_node() loop helper Andy Shevchenko
2022-04-05 12:12 ` Bartosz Golaszewski
2022-04-01 10:35 ` [PATCH v4 02/13] gpiolib: Introduce gpiochip_node_count() helper Andy Shevchenko
2022-04-05 12:13 ` Bartosz Golaszewski
2022-04-01 10:35 ` [PATCH v4 03/13] pinctrl: stm32: Replace custom code by gpiochip_node_count() call Andy Shevchenko
2022-04-01 10:35 ` [PATCH v4 04/13] pinctrl: stm32: Switch to use for_each_gpiochip_node() helper Andy Shevchenko
2022-04-01 10:35 ` [PATCH v4 05/13] pinctrl: samsung: " Andy Shevchenko
2022-04-08 15:22 ` Krzysztof Kozlowski
2022-04-08 15:39 ` Andy Shevchenko
2022-04-09 13:33 ` Krzysztof Kozlowski
2022-04-11 11:56 ` Andy Shevchenko
2022-04-11 12:03 ` Krzysztof Kozlowski
2022-04-11 12:21 ` Krzysztof Kozlowski
2022-04-11 13:13 ` Andy Shevchenko
2022-04-01 10:35 ` [PATCH v4 06/13] pinctrl: renesas: rza1: Replace custom code by gpiochip_node_count() call Andy Shevchenko
2022-04-01 10:35 ` Andy Shevchenko [this message]
2022-04-01 10:35 ` [PATCH v4 08/13] pinctrl: npcm7xx: Switch to use for_each_gpiochip_node() helper Andy Shevchenko
2022-04-01 10:36 ` [PATCH v4 09/13] pinctrl: meson: Rename REG_* to MESON_REG_* Andy Shevchenko
2022-04-11 9:04 ` Geert Uytterhoeven
2022-04-11 10:19 ` Andy Shevchenko
2022-04-11 11:41 ` Andy Shevchenko
2022-04-01 10:36 ` [PATCH v4 10/13] pinctrl: meson: Enable COMPILE_TEST Andy Shevchenko
2022-04-01 10:36 ` [PATCH v4 11/13] pinctrl: meson: Replace custom code by gpiochip_node_count() call Andy Shevchenko
[not found] ` <CGME20220414063849eucas1p126e41b53ff0d342f5c48408994b704e9@eucas1p1.samsung.com>
2022-04-14 6:38 ` Marek Szyprowski
2022-04-14 13:51 ` Andy Shevchenko
2022-04-14 15:32 ` Martin Blumenstingl
2022-04-14 16:06 ` Andy Shevchenko
2022-04-14 18:28 ` Andy Shevchenko
2022-04-14 18:33 ` Andy Shevchenko
2022-04-01 10:36 ` [PATCH v4 12/13] pinctrl: armada-37xx: Switch to use fwnode instead of of_node Andy Shevchenko
2022-04-01 10:36 ` [PATCH v4 13/13] pinctrl: armada-37xx: Reuse GPIO fwnode in armada_37xx_irqchip_register() Andy Shevchenko
2022-04-11 11:59 ` [PATCH v4 00/13] gpiolib: Two new helpers and way toward fwnode Andy Shevchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220401103604.8705-8-andriy.shevchenko@linux.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=alexandre.torgue@foss.st.com \
--cc=alim.akhtar@samsung.com \
--cc=andrew@lunn.ch \
--cc=avifishman70@gmail.com \
--cc=benjaminfair@google.com \
--cc=brgl@bgdev.pl \
--cc=fabien.dessenne@foss.st.com \
--cc=geert+renesas@glider.be \
--cc=gregory.clement@bootlin.com \
--cc=jbrunet@baylibre.com \
--cc=khilman@baylibre.com \
--cc=krzk@kernel.org \
--cc=linus.walleij@linaro.org \
--cc=linux-amlogic@lists.infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=linux-samsung-soc@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=martin.blumenstingl@googlemail.com \
--cc=maz@kernel.org \
--cc=mcoquelin.stm32@gmail.com \
--cc=narmstrong@baylibre.com \
--cc=openbmc@lists.ozlabs.org \
--cc=p.zabel@pengutronix.de \
--cc=qianggui.song@amlogic.com \
--cc=s.nawrocki@samsung.com \
--cc=sebastian.hesselbarth@gmail.com \
--cc=tali.perry1@gmail.com \
--cc=tmaimon77@gmail.com \
--cc=tomasz.figa@gmail.com \
--cc=venture@google.com \
--cc=yuenn@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).