waveform80 / rpi-lgpio

A compatibility shim for lgpio emulating the RPi.GPIO API
https://rpi-lgpio.readthedocs.io/
Other
9 stars 5 forks source link

Refine gpiochip discovery #10

Closed waveform80 closed 3 months ago

waveform80 commented 4 months ago

Upstream, there are plans to change the user's GPIO chip device to gpiochip0 by default (and allow some customization generally). This a Good Thing (tm) but will necessarily break the lazy method by which rpi-lgpio (and, for that matter, gpiozero) derive the gpiochip device.

To preserve compatibility with any kernels still using gpiochip4, but also to account for customization in the future, we should do something a bit more intelligent here (the following is a refinement of my vague thoughts from 2AM on the other bug):

That should be simple (and quick) enough for now. If we need something more complex, the search case can be iterated on (if, for example, there are multiple GPIO devices with the requisite driver), but let's not go down that road unless we have to.

Marking as a bug because, although this doesn't break yet, it's evidently going to once this change lands in the upstream kernel.