All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexandre Courbot <gnurou@gmail.com>
To: Michael Heimpold <mhei@heimpold.de>
Cc: "linux-gpio@vger.kernel.org" <linux-gpio@vger.kernel.org>
Subject: Re: Question about gpio sysfs interface
Date: Mon, 7 Apr 2014 16:58:22 +0900	[thread overview]
Message-ID: <CAAVeFuKyixV8CPp3i+ftuqgtF-sWc5TVRy1gRg6Xg+pQBsF6-w@mail.gmail.com> (raw)
In-Reply-To: <1420047.Pa7NFNg2Xt@kerker>

On Mon, Apr 7, 2014 at 3:56 AM, Michael Heimpold <mhei@heimpold.de> wrote:
> Hi,
>
> I have a question regarding user-space gpio support with sysfs.
>
> Documentation/gpio/sysfs.txt states
>> GPIO signals have paths like /sys/class/gpio/gpio42/ (for GPIO #42)
>> and have the following read/write attributes:
>>
>>    /sys/class/gpio/gpioN/
>>
>>       "direction" ... reads as either "in" or "out". This value may
>>               normally be written. ...
>>
>>               Note that this attribute *will not exist* if the kernel
>>               doesn't support changing the direction of a GPIO, or
>>               it was exported by kernel code that didn't explicitly
>>               allow userspace to reconfigure this GPIO's direction.
>
> Imagine for example a generic user-space tool which enumerates
> all available GPIOs to the user and sorts by input and output GPIOs.
> How would such a tool classify an exported GPIO when kernel
> doesn't export the 'direction' file via sysfs? Or in other words: how
> can userspace detect the state (in vs. out) of a GPIO when 'direction'
> is not exported?

Wouldn't the "value" field be read-only for a "in" GPIO and read-write
for an "out" one?

Other than that, I also don't see any drawback to having "direction"
always exported and made read-only if direction cannot be changed.

Alex.

  reply	other threads:[~2014-04-07  7:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-06 18:56 Question about gpio sysfs interface Michael Heimpold
2014-04-07  7:58 ` Alexandre Courbot [this message]
2014-04-07 19:55   ` Michael Heimpold

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=CAAVeFuKyixV8CPp3i+ftuqgtF-sWc5TVRy1gRg6Xg+pQBsF6-w@mail.gmail.com \
    --to=gnurou@gmail.com \
    --cc=linux-gpio@vger.kernel.org \
    --cc=mhei@heimpold.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.