Re: Replacing global GPIO numbers in sysfs with hardware offsets

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Linus,

On Fri, 28 Feb 2025 at 09:56, Linus Walleij <linus.walleij@xxxxxxxxxx> wrote:
> On Fri, Feb 28, 2025 at 9:50 AM Geert Uytterhoeven <geert@xxxxxxxxxxxxxx> wrote:
> > > /sys/bus/gpio/gpiochip0
> > > /sys/bus/gpio/gpiochip0/gpio0
> > > /sys/bus/gpio/gpiochip0/gpio0/userspace
> > > /sys/bus/gpio/gpiochip0/gpio0/value
> > > /sys/bus/gpio/gpiochip0/gpio1
> > > /sys/bus/gpio/gpiochip0/gpio1/userspace
> > > /sys/bus/gpio/gpiochip0/gpio1/value
> > >
> > > Take a GPIO, shake it, give it back to the kernel:
> > > echo 1 > /sys/bus/gpio/gpiochip0/gpio1/userspace
> > > echo 0 > /sys/bus/gpio/gpiochip0/gpio1/value
> > > sleep 1
> > > echo 1 > /sys/bus/gpio/gpiochip0/gpio1/value
> > > echo 0 > /sys/bus/gpio/gpiochip0/gpio1/userspace
> > >
> > > So we can always "see" this GPIO line, instead of
> > > exporting/unexporting there is a knob to assign/unassign
> > > it to userspace.
> >
> > Why would you want to always "see" all GPIO lines?
> > What is the use case for that? What am I missing?
>
> Because in the current ABI the user has to implicitly
> know how many GPIOs there is on a gpiochip in order
> to know which lines can be requested, and that's not
> good.

Doesn't the ngpio virtual file tell you that?

> You know you can probably request gpio 0 but can
> you request GPIO 104?

I guess most people who play/mess/... with GPIOs directly know by
heart how many GPIOs there are on their gpiochips (at least I do ;-)

> Also sysfs is explicitly for topology and this is topology,
> by the book.
>
> > If it is recommended not to use this interface, I think all GPIOs
> > should be invisible by default.  Hence I still prefer the (un)export
> > interface.
>
> I think the whole point of the thread is that this so-called
> sysfs v2 is supposed to be recommendable because users
> want something like this.

Let's keep it simple, and similar/identical to the existing API?

Is there anything in Documentation/ABI/obsolete/sysfs-gpio
we can drop? edge?

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds





[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux