lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Mon, 20 Jul 2020 21:21:30 +0200
From:   Drew Fustini <drew@...gleboard.org>
To:     Linus Walleij <linus.walleij@...aro.org>
Cc:     Andy Shevchenko <andy.shevchenko@...il.com>,
        Tony Lindgren <tony@...mide.com>,
        Linux-OMAP <linux-omap@...r.kernel.org>,
        "open list:GPIO SUBSYSTEM" <linux-gpio@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        Jason Kridner <jkridner@...gleboard.org>,
        Robert Nelson <robertcnelson@...il.com>
Subject: Re: [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@...gleboard.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/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ