LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Linus Walleij <linus.walleij@linaro.org>
To: Doug Berger <opendmb@gmail.com>
Cc: Gregory Fong <gregory.0xf0@gmail.com>,
Bartosz Golaszewski <bgolaszewski@baylibre.com>,
Florian Fainelli <f.fainelli@gmail.com>,
bcm-kernel-feedback-list <bcm-kernel-feedback-list@broadcom.com>,
"open list:GPIO SUBSYSTEM" <linux-gpio@vger.kernel.org>,
Linux ARM <linux-arm-kernel@lists.infradead.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH V2] gpio: brcmstb: support gpio-line-names property
Date: Wed, 11 Mar 2020 16:32:29 +0100 [thread overview]
Message-ID: <CACRpkdZ1p3_U_yth-rCEKdPsuFNFnxsE3kTeP7krf-xHuSGkFw@mail.gmail.com> (raw)
In-Reply-To: <1583780521-45702-1-git-send-email-opendmb@gmail.com>
On Mon, Mar 9, 2020 at 8:02 PM Doug Berger <opendmb@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-brcmstb
> driver.
>
> This commit adds driver level support for the device tree
> property so that GPIO lines can be assigned friendly names.
>
> Signed-off-by: Doug Berger <opendmb@gmail.com>
> +static void brcmstb_gpio_set_names(struct device *dev,
> + struct brcmstb_gpio_bank *bank)
> +{
> + struct device_node *np = dev->of_node;
> + const char **names;
> + int nstrings, base;
I don't understand why that thing is named "base".
> + unsigned int i;
> +
> + base = bank->id * MAX_GPIO_PER_BANK;
That would be ngpios or something.
But you alread have what you need in bank->gc.ngpio, right?
So why calculate it?
> + nstrings = of_property_count_strings(np, "gpio-line-names");
> + if (nstrings <= base)
> + /* Line names not present */
> + return;
> +
> + names = devm_kcalloc(dev, MAX_GPIO_PER_BANK, sizeof(*names),
> + GFP_KERNEL);
> + if (!names)
> + return;
> +
> + /*
> + * Make sure to not index beyond the end of the number of descriptors
> + * of the GPIO device.
> + */
> + for (i = 0; i < 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;
> + }
> +
> + bank->gc.names = names;
> +}
Why can't you just make the function
devprop_gpiochip_set_names() public, (line in <linux/gpio/driver.h>)
and convert your np to a fwnode and call that &bank->gc ?
Yours,
Linus Walleij
next prev parent reply other threads:[~2020-03-11 15:32 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-09 19:02 Doug Berger
2020-03-09 20:01 ` Gregory Fong
2020-03-11 12:44 ` Bartosz Golaszewski
2020-03-11 19:02 ` Doug Berger
2020-03-12 8:22 ` Bartosz Golaszewski
2020-03-11 15:32 ` Linus Walleij [this message]
2020-03-11 18:38 ` Doug Berger
2020-03-11 20:59 ` Florian Fainelli
2020-03-25 23:01 ` Linus Walleij
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=CACRpkdZ1p3_U_yth-rCEKdPsuFNFnxsE3kTeP7krf-xHuSGkFw@mail.gmail.com \
--to=linus.walleij@linaro.org \
--cc=bcm-kernel-feedback-list@broadcom.com \
--cc=bgolaszewski@baylibre.com \
--cc=f.fainelli@gmail.com \
--cc=gregory.0xf0@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=opendmb@gmail.com \
--subject='Re: [PATCH V2] gpio: brcmstb: support gpio-line-names property' \
/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
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).