Bias resistor kernel version check
See original GitHub issueSo I learned yesterday that bias resistor settings are a recent addition to the Linux kernel (v5.5). In all my digging to get to the bottom of the ambiguous error 22s I was getting, I found out that ioctl
calls to pinctrl
should allow control of bias resistors (I have not looked into how yet).
I was going to implement kernel version checks and have my downstream software decide when to use this alternate method, but then I thought why do that when I can contribute it upstream to the library!
For the cdev class it will be pretty easy to add branching to use the alternate method if a bias setting is specified, but I wanted your input on how to do it for sysfs or if it should be done. My thought is just to add a named arg bias
to the sysfs class init function. That would maintain backwards compatibility and not break the logic that counts unnamed args to determine if the user is trying to get a sysfs or cdev instance. What are you thoughts on this?
Edit: using pinctrl
we could actually expand the sysfs class to offer all of the settings that cdev does with the exception of edge
and label
.
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (8 by maintainers)
I think it would still be best to register these checks (there will be one for line drive as well) once at the top of the class, e.g.
and then use them below with
if CdevGPIO._SUPPORTS_LINE_DRIVE: ...
.It looks like for SPI, MODE32 was added in v3.15. I can do the SPI one if you prefer, that one is a little tricky since it already tries to use mode32 opportunistically, which will probably need to get refactored with this check.
OK, looks good.
There isn’t a great native Python error for unsupported features, so I think it should return a
GPIOError
with a message similar to the other peripheries: https://github.com/vsergeev/c-periphery/blob/master/src/gpio.c#L881 . Ideally, python-periphery would have more descriptive error types that subclassGPIOError
, but that can be done in the future.Cherry-picked in 9c1a4f3 in devel. This issue should auto-close in the next release to master.