[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <4d17866a-d9a4-a3d7-189a-781d18dbea00@axentia.se>
Date: Tue, 7 Dec 2021 00:32:03 +0100
From: Peter Rosin <peda@...ntia.se>
To: "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Cc: Ludovic Desroches <ludovic.desroches@...rochip.com>,
Linus Walleij <linus.walleij@...aro.org>,
Nicolas Ferre <nicolas.ferre@...rochip.com>,
Alexandre Belloni <alexandre.belloni@...tlin.com>,
"linux-arm-kernel@...ts.infradead.org"
<linux-arm-kernel@...ts.infradead.org>,
"linux-gpio@...r.kernel.org" <linux-gpio@...r.kernel.org>
Subject: [PATCH] pinctrl: at91: allow use of of gpio-line-names property
If no line name is given (by not having a gpio-line-names property,
or by having empty "" strings for some lines), fall back to the
existing pioC12-style line name scheme.
It is useful to be able to explicitly name lines from the schematics
or its function, rather than having the MCU names forced upon every
user.
Signed-off-by: Peter Rosin <peda@...ntia.se>
---
drivers/pinctrl/pinctrl-at91.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
I don't know if it's sane to fall back to the pioC12-style on empty
strings, or if someone adding a gpio-line-names property should be
responsible for filling in those names "by hand". I generally don't
care what "unused" pins are named, so either is fine by me...
Cheers,
Peter
diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c
index 6022496bb6a9..4f108d07e6ad 100644
--- a/drivers/pinctrl/pinctrl-at91.c
+++ b/drivers/pinctrl/pinctrl-at91.c
@@ -1821,7 +1821,7 @@ static int at91_gpio_probe(struct platform_device *pdev)
int irq, i;
int alias_idx = of_alias_get_id(np, "gpio");
uint32_t ngpio;
- char **names;
+ const char **names;
BUG_ON(alias_idx >= ARRAY_SIZE(gpio_chips));
if (gpio_chips[alias_idx]) {
@@ -1890,8 +1890,15 @@ static int at91_gpio_probe(struct platform_device *pdev)
goto clk_enable_err;
}
- for (i = 0; i < chip->ngpio; i++)
- names[i] = kasprintf(GFP_KERNEL, "pio%c%d", alias_idx + 'A', i);
+ if (of_property_read_string_array(np, "gpio-line-names",
+ names, chip->ngpio) != chip->ngpio)
+ memset(names, 0, chip->ngpio * sizeof(char *));
+
+ for (i = 0; i < chip->ngpio; i++) {
+ if (!names[i] || !names[i][0])
+ names[i] = kasprintf(GFP_KERNEL,
+ "pio%c%d", alias_idx + 'A', i);
+ }
chip->names = (const char *const *)names;
--
2.20.1
Powered by blists - more mailing lists