lkml.org 
[lkml]   [2021]   [Jun]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH] gpio: mt7621: support gpio-line-names property
On Sat, Jun 19, 2021 at 1:02 PM Sergio Paracuellos
<sergio.paracuellos@gmail.com> wrote:
>
> The default handling of the gpio-line-names property by the
> gpiolib-of implementation does not work with the multiple
> gpiochip banks per device structure used by the gpio-mt7621
> driver.
>
> This commit adds driver level support for the device tree
> property so that GPIO lines can be assigned friendly names.

...

> +static void
> +mediatek_gpio_set_names(struct device *dev, struct mtk_gc *rg)
> +{
> + struct device_node *np = dev->of_node;
> + const char **names;
> + int nstrings, base;
> + unsigned int i;
> +
> + names = devm_kcalloc(dev, MTK_BANK_WIDTH, sizeof(*names),
> + GFP_KERNEL);
> + if (!names)
> + return;
> +
> + base = rg->bank * MTK_BANK_WIDTH;
> + nstrings = of_property_count_strings(np, "gpio-line-names");
> + if (nstrings <= base)
> + goto assign_names;
> +
> + for (i = 0; i < MTK_BANK_WIDTH; i++) {
> + const char *name;
> + int ret;
> +
> + ret = of_property_read_string_index(np, "gpio-line-names",
> + base + i, &name);
> + if (ret) {
> + if (ret != -ENODATA)
> + dev_err(dev, "unable to name line %d: %d\n",
> + base + i, ret);
> + break;
> + }
> +
> + if (*name)
> + names[i] = name;
> + }
> +
> +assign_names:
> + rg->chip.names = names;
> +}

Any idea why it's not a duplicate of
https://elixir.bootlin.com/linux/v5.13-rc7/C/ident/devprop_gpiochip_set_names,
and why the latter is not called in your case?

--
With Best Regards,
Andy Shevchenko

\
 
 \ /
  Last update: 2021-06-27 11:33    [W:0.039 / U:0.032 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site