Hi Drew,

thanks for this patch, we're going the right direction here
and creating things that are generically useful.

On Sat, Jul 18, 2020 at 5:53 PM Drew Fustini <d...@beagleboard.org> wrote:

> pin 103 (PIN103) GPIO-113 44e1099c 00000027 pinctrl-single
> pin 104 (PIN104) GPIO-114 44e109a0 0000002c pinctrl-single
(...)

Uh oh, that is the global GPIO number that we want to get
rid of.

> +               gpio_num = 0;
> +               list_for_each_entry(range, &pctldev->gpio_ranges, node) {
> +                       if ((pin >= range->pin_base) &&
> +                           (pin < (range->pin_base + range->npins)))
> +                               gpio_num = range->base + (pin - 
> range->pin_base);

There should be a break; here should it not?

> +               }
> +
> +               if (gpio_num > 0)
> +                       seq_printf(s, "GPIO-%u ", gpio_num);

Can we print the gpio_chip name and offset instead?
I want to discourage the world from thinking about these
global GPIO numbers.

You can fetch the gpio_chip for the range pretty easily
with

struct gpio_chip *chip = gpio_to_chip(gpio_num);

Also notice that this code needs to be
#ifdef CONFIG_GPIOLIB somehow
(maybe IS_ENABLED() works) because there
are pin controllers in use without gpiolib believe it
or not.

Yours,
Linus Walleij

Reply via email to