[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Thu, 12 Dec 2019 14:40:29 +0100
From: Linus Walleij <linus.walleij@...aro.org>
To: Geert Uytterhoeven <geert+renesas@...der.be>
Cc: Bartosz Golaszewski <bgolaszewski@...libre.com>,
Jonathan Corbet <corbet@....net>,
Rob Herring <robh+dt@...nel.org>,
Mark Rutland <mark.rutland@....com>,
Harish Jenny K N <harish_kandiga@...tor.com>,
Eugeniu Rosca <erosca@...adit-jv.com>,
Alexander Graf <graf@...zon.com>,
Peter Maydell <peter.maydell@...aro.org>,
Paolo Bonzini <pbonzini@...hat.com>,
Phil Reid <preid@...ctromag.com.au>,
Marc Zyngier <marc.zyngier@....com>,
Christoffer Dall <christoffer.dall@....com>,
Magnus Damm <magnus.damm@...il.com>,
"open list:GPIO SUBSYSTEM" <linux-gpio@...r.kernel.org>,
Linux Doc Mailing List <linux-doc@...r.kernel.org>,
"open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS"
<devicetree@...r.kernel.org>,
Linux-Renesas <linux-renesas-soc@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
QEMU Developers <qemu-devel@...gnu.org>
Subject: Re: [PATCH v3 3/7] gpiolib: Add support for GPIO line table lookup
On Wed, Nov 27, 2019 at 9:43 AM Geert Uytterhoeven
<geert+renesas@...der.be> wrote:
> Currently GPIOs can only be referred to by GPIO controller and offset in
> GPIO lookup tables.
>
> Add support for looking them up by line name.
>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@...der.be>
OK I see what you want to do...
> + if (p->chip_hwnum == (u16)-1) {
If you want to use this then use:
if (p->chip_hwnum == U16_MAX)
from <linux/limits.h>
> + desc = gpio_name_to_desc(p->chip_label);
> + if (desc) {
> + *flags = p->flags;
> + return desc;
> + }
> +
> + dev_warn(dev, "cannot find GPIO line %s, deferring\n",
> + p->chip_label);
> + return ERR_PTR(-EPROBE_DEFER);
> + }
> +
> chip = find_chip_by_name(p->chip_label);
>
> if (!chip) {
> diff --git a/include/linux/gpio/machine.h b/include/linux/gpio/machine.h
> index 1ebe5be05d5f81fa..84c1c097e55eefaf 100644
> --- a/include/linux/gpio/machine.h
> +++ b/include/linux/gpio/machine.h
> @@ -31,7 +31,7 @@ enum gpio_lookup_flags {
> */
> struct gpiod_lookup {
> const char *chip_label;
> - u16 chip_hwnum;
> + u16 chip_hwnum; /* if -1, chip_label is named line */
/* if U16_MAX then chip_label is the named line we are looking for */
But the member name "chip_label" is completely abused with this
setup, it should then be renamed as part of the patch set to something
like chip_label_or_line_name so it is clear what it is or
just name it "const char *key".
But I'm not entirely convinced about reusing the existing
struct gpio_lookup for this.
What about constructing a new lookup struct specifically for this?
I understand it is more work, but will that not be more
maintainable and readable?
Yours,
Linus Walleij
Powered by blists - more mailing lists