From: Kent Gibson <warthog618@gmail.com>
To: Riz <mdrizwan827@gmail.com>
Cc: Andy Shevchenko <andy.shevchenko@gmail.com>, linux-gpio@vger.kernel.org
Subject: Re: Regarding export of GPIOs
Date: Fri, 27 Aug 2021 10:21:40 +0800 [thread overview]
Message-ID: <20210827022140.GA8509@sol> (raw)
In-Reply-To: <CAHp75Vct=K1Nh+UDS9tZgvgF1ju_c8417wzfHg9YCA2ay0jtCA@mail.gmail.com>
On Fri, Aug 20, 2021 at 05:04:03PM +0300, Andy Shevchenko wrote:
> On Fri, Aug 20, 2021 at 6:27 AM Riz <mdrizwan827@gmail.com> wrote:
> >
> > Hello,
> > I have some basic questions around the exporting of a GPIO.
> >
> > 1. Regarding gpio-hog mechanism:
> > The gpio-hog mechanism would help us to initialise a GPIO to either
> > high/low & in/out during bootup.
> > This is fine.
> >
> > So my question is, if we hog a GPIO, does it also gets exported to the
> > userspace by default?
> >
> >
> > 2. With the older sysfs interface, we would be using "echo x >
> > /sys/class/gpio/export" to export the gpiox to userspace.
> >
> > I wanted to know what would be the right way to do this with the newer
> > interface?
> >
> > 3. To check if a GPIO is being exported or not, we would see the
> > /sys/class/gpio with the sysfs interface.
> >
> > With the newer character device interface, what would be the right way
> > to check what GPIOs are exported to userspace?
> >
> > Looking forward to hearing from you
>
> https://stackoverflow.com/questions/68856801/regarding-gpio-export ?
>
> I think I pretty much answered there.
>
Continuing that thread and in response to your comment:
> I agree with you. Even I looked into the kernel code, it sets the right
> direction of the hogged GPIO. I suspect this could be some issue with
> gpioinfo tool. I hog a GPIO as below
>
> pX { gpio-hog; gpios = < X 0 >; output-high; };
>
> The gpinfo reveals following info about the GPIO:
>
> line 13: "p.X" "some_name" input active-high [used]
>
> It shows it as [used] but the direction still says input
>
I doubt that gpioinfo is the problem - it merely reports the flags
returned by the kernel and is known to correctly decode the flags for
lines requested using the GPIO API.
You could confirm that by comparing the output of lsgpio or the
libgpiod equivalent tools in my Go library[1].
You could also use strace to decode the GPIO ioctls with:
strace --trace=ioctl gpioinfo
That requires strace 5.11 or later.
If any of those demonstrate that the output flag is not being set then
the problem would appear to lie on the kernel side.
Cheers,
Kent.
[1] https://github.com/warthog618/gpiod
next prev parent reply other threads:[~2021-08-27 2:21 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-20 3:25 Regarding export of GPIOs Riz
2021-08-20 14:04 ` Andy Shevchenko
2021-08-27 2:21 ` Kent Gibson [this message]
2021-08-31 15:05 ` Riz
2021-08-31 15:08 ` Riz
2021-09-01 6:28 ` Kent Gibson
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=20210827022140.GA8509@sol \
--to=warthog618@gmail.com \
--cc=andy.shevchenko@gmail.com \
--cc=linux-gpio@vger.kernel.org \
--cc=mdrizwan827@gmail.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).