linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andy Shevchenko <andy.shevchenko@gmail.com>
To: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Cc: "open list:GPIO SUBSYSTEM" <linux-gpio@vger.kernel.org>,
	Bartosz Golaszewski <bgolaszewski@baylibre.com>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	Linus Walleij <linus.walleij@linaro.org>,
	git@johnthomson.fastmail.com.au,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	neil@brown.name, opensource@vdorst.com,
	Nicholas Mc Guire <hofrat@osadl.org>
Subject: Re: [PATCH] gpio: mt7621: support gpio-line-names property
Date: Sun, 27 Jun 2021 12:31:35 +0300	[thread overview]
Message-ID: <CAHp75Vd4UPiPKy98jV_LuCE10dCrSwU06AddCq5Q0POm0graOw@mail.gmail.com> (raw)
In-Reply-To: <20210619073551.13703-1-sergio.paracuellos@gmail.com>

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

      parent reply	other threads:[~2021-06-27  9:32 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-19  7:35 [PATCH] gpio: mt7621: support gpio-line-names property Sergio Paracuellos
2021-06-25 11:53 ` Bartosz Golaszewski
2021-06-25 12:40   ` Sergio Paracuellos
2021-06-27  9:31 ` Andy Shevchenko [this message]

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=CAHp75Vd4UPiPKy98jV_LuCE10dCrSwU06AddCq5Q0POm0graOw@mail.gmail.com \
    --to=andy.shevchenko@gmail.com \
    --cc=bgolaszewski@baylibre.com \
    --cc=git@johnthomson.fastmail.com.au \
    --cc=hofrat@osadl.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matthias.bgg@gmail.com \
    --cc=neil@brown.name \
    --cc=opensource@vdorst.com \
    --cc=sergio.paracuellos@gmail.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).