[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v3 3/7] gpiolib: Add support for GPIO line table lookup
From: |
Ulrich Hecht |
Subject: |
Re: [PATCH v3 3/7] gpiolib: Add support for GPIO line table lookup |
Date: |
Thu, 28 Nov 2019 04:39:14 +0100 (CET) |
> On November 27, 2019 at 9:42 AM Geert Uytterhoeven <address@hidden> 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 <address@hidden>
> ---
> If this is rejected, the GPIO Aggregator documentation and code must be
> updated.
>
> v3:
> - New.
> ---
> drivers/gpio/gpiolib.c | 12 ++++++++++++
> include/linux/gpio/machine.h | 2 +-
> 2 files changed, 13 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
> index d24a3d79dcfe69ad..cb608512ad6bbded 100644
> --- a/drivers/gpio/gpiolib.c
> +++ b/drivers/gpio/gpiolib.c
> @@ -4475,6 +4475,18 @@ static struct gpio_desc *gpiod_find(struct device
> *dev, const char *con_id,
> if (p->con_id && (!con_id || strcmp(p->con_id, con_id)))
> continue;
>
> + if (p->chip_hwnum == (u16)-1) {
> + 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 */
The magic number "-1" might deserve a #define.
> const char *con_id;
> unsigned int idx;
> unsigned long flags;
> --
> 2.17.1
>
With or without #define,
Reviewed-by: Ulrich Hecht <address@hidden>
CU
Uli
- [PATCH v3 0/7] gpio: Add GPIO Aggregator/Repeater, Geert Uytterhoeven, 2019/11/27
- [PATCH v3 7/7] MAINTAINERS: Add GPIO Aggregator/Repeater section, Geert Uytterhoeven, 2019/11/27
- [PATCH v3 3/7] gpiolib: Add support for GPIO line table lookup, Geert Uytterhoeven, 2019/11/27
- Re: [PATCH v3 3/7] gpiolib: Add support for GPIO line table lookup,
Ulrich Hecht <=
- [PATCH v3 4/7] dt-bindings: gpio: Add gpio-repeater bindings, Geert Uytterhoeven, 2019/11/27
- [PATCH v3 1/7] gpiolib: Add GPIOCHIP_NAME definition, Geert Uytterhoeven, 2019/11/27
- [PATCH v3 2/7] gpiolib: Add support for gpiochipN-based table lookup, Geert Uytterhoeven, 2019/11/27
- [PATCH v3 6/7] docs: gpio: Add GPIO Aggregator/Repeater documentation, Geert Uytterhoeven, 2019/11/27
- [PATCH v3 5/7] gpio: Add GPIO Aggregator/Repeater driver, Geert Uytterhoeven, 2019/11/27