On Mon, Aug 28, 2023 at 4:21 PM Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx> wrote: > Much to my dismay, I've learnt that my script above doesn't work when the same device > registers multiple GPIO controllers. On my i.MX system with some PCA953x GPIO expanders, > it works ok, but on a STM32MP, were the pinctrl device registers all GPIO chips, the glob > will expand to more than once device. > > So my question is: What better way is there to get a legacy GPIO index from within > a shell script (or an alternative way to request a sysfs GPIO by label)? Don't know if it answers your question, but when there are several GPIO chips of the same device/driver the way to determine topology ("which device is which") is to use the topology in sysfs, i.e. the directory path, where each device will have some unique bus ID (such as the USB instance number, the device tree address etc). > P.S: I know that most GPIO fiddling should've kernel driver consumers instead. That's under > way too. Thanks! :) > [1]: I appreciate links to any WIP/planned systemd-gpiod or similar patches anyway. While new > projects should do more fine grained control of GPIOs, migration of most users will > likely benefit benefit from a single global consumer. I think Bartosz was working at a GPIO daemon for central management at one point, but in a controlled embedded system, I think other (custom) solutions for a central entity are possible. Yours, Linus Walleij