From: Drew Fustini <drew@beagleboard.org>
To: Linus Walleij <linus.walleij@linaro.org>
Cc: Andy Shevchenko <andy.shevchenko@gmail.com>,
Tony Lindgren <tony@atomide.com>,
Linux-OMAP <linux-omap@vger.kernel.org>,
"open list:GPIO SUBSYSTEM" <linux-gpio@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Jason Kridner <jkridner@beagleboard.org>,
Robert Nelson <robertcnelson@gmail.com>
Subject: Re: [PATCH] pinctrl: core: print gpio in pins debugfs file
Date: Mon, 20 Jul 2020 21:21:30 +0200 [thread overview]
Message-ID: <20200720192130.GA1964904@x1> (raw)
In-Reply-To: <CACRpkdapJj5Q3MBKrJkd3CBeJJDuuS-Cj6D=Gk67uyt4O_Oj-A@mail.gmail.com>
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/
prev parent reply other threads:[~2020-07-20 19:21 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-18 15:49 [PATCH] pinctrl: core: print gpio in pins debugfs file Drew Fustini
2020-07-18 17:24 ` Tony Lindgren
2020-07-20 14:26 ` Linus Walleij
2020-07-20 19:21 ` Drew Fustini [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200720192130.GA1964904@x1 \
--to=drew@beagleboard.org \
--cc=andy.shevchenko@gmail.com \
--cc=jkridner@beagleboard.org \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=robertcnelson@gmail.com \
--cc=tony@atomide.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).