lkml.org 
[lkml]   [2020]   [Jul]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] pinctrl: core: print gpio in pins debugfs file
On Mon, Jul 20, 2020 at 04:26:21PM +0200, Linus Walleij wrote:
> 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 <drew@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?

Yes, good point.

> > + }
> > +
> > + 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

I've just posted a v2 [0] which makes sure the gpio information is only
if CONFIG_GPIOLIB.

I had a hard time finding line offset so I printed the line name
instead. I would appreciate it if you could point me in the right place
to get the offset as that is cleaner in the 'pins' output.

thanks,
drew

[0] https://lore.kernel.org/linux-omap/20200720191740.1974132-1-drew@beagleboard.org/

\
 
 \ /
  Last update: 2020-07-20 21:22    [W:0.062 / U:0.036 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site