linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Gregory Fong <gregory.0xf0@gmail.com>
To: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Cc: linux-gpio@vger.kernel.org,
	Linus Walleij <linus.walleij@linaro.org>,
	Bartosz Golaszewski <bgolaszewski@baylibre.com>,
	f.fainelli@gmail.com, matthias.bgg@gmail.com,
	opensource@vdorst.com, andy.shevchenko@gmail.com,
	git@johnthomson.fastmail.com.au, neil@brown.name,
	hofrat@osadl.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 1/3] gpiolib: convert 'devprop_gpiochip_set_names' to support multiple gpiochip banks per device
Date: Tue, 27 Jul 2021 16:15:06 -0700	[thread overview]
Message-ID: <CADtm3G5vMnFzxZV2hijZ3daVOgJ=0MnMJmkLyxe0+bNew5g_TA@mail.gmail.com> (raw)
In-Reply-To: <20210727152026.31019-2-sergio.paracuellos@gmail.com>

On Tue, Jul 27, 2021 at 8:20 AM Sergio Paracuellos
<sergio.paracuellos@gmail.com> wrote:
>
> The default gpiolib-of implementation does not work with the multiple
> gpiochip banks per device structure used for example by the gpio-mt7621
> and gpio-brcmstb drivers. To fix these kind of situations driver code
> is forced to fill the names to avoid the gpiolib code to set names
> repeated along the banks. Instead of continue with that antipattern
> fix the gpiolib core function to get expected behaviour for every
> single situation adding a field 'offset' in the gpiochip structure.
> Doing in this way, we can assume this offset will be zero for normal
> driver code where only one gpiochip bank per device is used but
> can be set explicitly in those drivers that really need more than
> one gpiochip.
>
> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>

One minor comment below, then this looks great:
Reviewed-by: Gregory Fong <gregory.0xf0@gmail.com>

> Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
> ---
>  drivers/gpio/gpiolib.c      | 32 +++++++++++++++++++++++++++-----
>  include/linux/gpio/driver.h |  4 ++++
>  2 files changed, 31 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
> index 27c07108496d..84ed4b73fa3e 100644
> --- a/drivers/gpio/gpiolib.c
> +++ b/drivers/gpio/gpiolib.c
> @@ -382,10 +382,18 @@ static int devprop_gpiochip_set_names(struct gpio_chip *chip)
>         if (count < 0)
>                 return 0;
>
> -       if (count > gdev->ngpio) {
> -               dev_warn(&gdev->dev, "gpio-line-names is length %d but should be at most length %d",
> -                        count, gdev->ngpio);
> -               count = gdev->ngpio;
> +       /*
> +        * When offset is set in the driver side we assume the driver internally
> +        * is using more than one gpiochip per the same device. We have to stop
> +        * setting friendly names if the specified ones with 'gpio-line-names'
> +        * are less than the offset in the device itself. This means all the
> +        * lines are not present for every single pin within all the internal
> +        * gpiochips.
> +        */
> +       if (count <= chip->offset) {
> +               dev_warn(&gdev->dev, "gpio-line-names too short (length %d) cannot map names for the gpiochip at offset %u\n",

nit: there should be some punctuation after "(length %d)", otherwise
with parentheticals removed it reads as

"gpio-line-names too short cannot map names ..."

but we need to provide a space between these thoughts for clarity.  A
comma should be ok:

"gpio-line-names too short (length %d), cannot map names ..."

Best regards,
Gregory

  reply	other threads:[~2021-07-27 23:15 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-27 15:20 [PATCH v3 0/3] gpiolib: convert 'devprop_gpiochip_set_names' to support multiple gpiochip banks per device Sergio Paracuellos
2021-07-27 15:20 ` [PATCH v3 1/3] " Sergio Paracuellos
2021-07-27 23:15   ` Gregory Fong [this message]
2021-07-28  4:05     ` Sergio Paracuellos
2021-07-27 15:20 ` [PATCH v3 2/3] gpio: mt7621: support gpio-line-names property Sergio Paracuellos
2021-07-27 15:20 ` [PATCH v3 3/3] gpio: brcmstb: remove custom 'brcmstb_gpio_set_names' Sergio Paracuellos

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='CADtm3G5vMnFzxZV2hijZ3daVOgJ=0MnMJmkLyxe0+bNew5g_TA@mail.gmail.com' \
    --to=gregory.0xf0@gmail.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=bgolaszewski@baylibre.com \
    --cc=f.fainelli@gmail.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).