From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Subject: Re: [PATCH 3/4] of/gpio: Support gpio-line-names property
Date: Wed, 27 Nov 2019 12:31:37 +0100 [thread overview]
Message-ID: <153bbae3-b43b-558e-900f-462f2c60b2f8@pengutronix.de> (raw)
In-Reply-To: <20191127111613.24173-4-s.hauer@pengutronix.de>
Hello Sascha,
On 11/27/19 12:16 PM, Sascha Hauer wrote:
> GPIOs can be given names with the gpio-line-names device tree property.
> This patch adds support for it.
>
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> ---
> drivers/gpio/gpiolib.c | 16 +++++++++++++++-
> 1 file changed, 15 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
> index 057cea43cc..9764ddf0f0 100644
> --- a/drivers/gpio/gpiolib.c
> +++ b/drivers/gpio/gpiolib.c
> @@ -428,11 +428,25 @@ static int of_hog_gpio(struct device_node *np, struct gpio_chip *chip,
> static int of_gpiochip_scan_hogs(struct gpio_chip *chip)
> {
> struct device_node *np;
> - int ret, i;
> + int ret, i, count;
>
> if (!IS_ENABLED(CONFIG_OFDEVICE) || !chip->dev->device_node)
> return 0;
>
> + count = of_property_count_strings(chip->dev->device_node, "gpio-line-names");
> +
> + if (count > 0) {
> + const char **arr = xzalloc(count * sizeof(char *));
> +
> + of_property_read_string_array(chip->dev->device_node,
> + "gpio-line-names", arr, count);
> +
> + for (i = 0; i < chip->ngpio && i < count; i++)
> + gpio_desc[chip->base + i].name = xstrdup(arr[i]);
There's no need to duplicate memory here. You could just directly point into the
unflattened DTB. You could reuse of_gpiochip_set_names from my patch
sent yesterday.
> +
> + free(arr);
> + }
> +
> for_each_available_child_of_node(chip->dev->device_node, np) {
> if (!of_property_read_bool(np, "gpio-hog"))
> continue;
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | https://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2019-11-27 11:31 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-27 11:16 [PATCH 0/4] support for gpio-line-names Sascha Hauer
2019-11-27 11:16 ` [PATCH 1/4] of: Add of_property_read_string_array() Sascha Hauer
2019-11-27 11:16 ` [PATCH 2/4] gpio: Introduce GPIO names Sascha Hauer
2019-11-27 11:16 ` [PATCH 3/4] of/gpio: Support gpio-line-names property Sascha Hauer
2019-11-27 11:31 ` Ahmad Fatoum [this message]
2019-11-27 12:32 ` Sascha Hauer
2019-11-27 12:35 ` Ahmad Fatoum
2019-11-27 13:38 ` Sascha Hauer
2019-11-27 11:16 ` [PATCH 4/4] ARM: Layerscape: TQMLS1046a: Add gpio-line-names Sascha Hauer
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=153bbae3-b43b-558e-900f-462f2c60b2f8@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
/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