lkml.org 
[lkml]   [2020]   [Jul]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    From
    Date
    SubjectRe: [PATCH] pinctrl: core: print gpio in pins debugfs file
    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?

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

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