Re: [PATCH 0/2] USB: serial: gpio line-name fix and FT232R CBUS gpio support

From: Linus Walleij
Date: Wed Oct 10 2018 - 05:36:43 EST

On Fri, Oct 5, 2018 at 3:40 PM Johan Hovold <johan@xxxxxxxxxx> wrote:
> On Mon, Oct 01, 2018 at 11:43:55AM +0200, Linus Walleij wrote:

> > The idea is to make it possible for userspace to look up a GPIO
> > on a chip by name, so if the gpiochip has a unique name,
> > and the line name is unique on that chip it should be good
> > enough.
> I haven't really had time do dig into this again, but is this also an
> issue with the chardev interface?
> I thought this was one of the things
> you wanted to get right with the new interface, so hopefully that's
> already taken care of.

It is always possible to use /dev/gpiochipN and offet M on
that gpiochip to pick a unique line. That is a unique offset
on a unique chip. The gpiochip also has a "label" which may
be something user-readable such as part numer, but the unique
string is its name such as "gpiochip0".

For symbolic look-up though, like a file has to have a unique
path, the name of the line should be unique.

It is allowed to have unnamed lines though, so it is only a
hint. While I would like all drivers to uniquely name their
lines in DT or ACPI, or using the .names array in the gpio_chip
struct, it cannot be enforced because of legacy support,
so many old systems had no names specified, and
the DT and ACPI properties to name lines were introduced
after the chardev actually.

All I enforce is that if names are added, they should be

What we *could* do is conjure a unique name per line if
the hardware description doesn't provice one... like
"line0", "line1", "line2"... "lineN" on the chip.

Should we add a patch like that? The only side effect
I can see if that maybe the footprint increase is not so

I had it in mind but it slipped of my radar. It would make
all lines always have unique names.

> If the flat name space is only an issue with the legacy interface we
> might get away with simply not using the line names in sysfs when a new
> chip flag is set (unless we can resue .can_sleep, but there seems to be
> some i2c devices already using line names).

Hm. So you mean it is bad that the exporting GPIOs in the old
sysfs brings out the line name in sysfs if the line is named.

I just want the sysfs to die, but yeah what you say makes
sense. I don't know if it's such a big issue, my focus has been
on making the chardev more appetizing and the sysfs
uncomfortably oldschool amongst users. This would make it
even more uncomfortable.

But I don't know if the old sysfs users actually use the line
names much?

Linus Walleij