Ryan Mallon wrote:
If we strip my patch back to just introducing gpio_request_cansleep, which would be used in any driver where all of the calls are gpio_(set/get)_cansleep, and make gpio_request only allow non-sleeping gpios then incorrect use of gpios would be caught at request time and returned to the caller as an error.
It seems like a good idea to catch these at request time. There is support in the API for this already (gpio_cansleep), but driver writers are not steered towards checking and thinking in these ways by the current API or documentation. Perhaps a documentation change with some cut and paste boilerplate would be enough, but I think some API enforcement/encouragement would be helpful.
I think this agrees with you, Ryan:
gpio_request_cansleep would be the same as current gpio_request
gpio_request changes to error if this is a sleepy gpio.
Imagine a situation where GPIOs are being assigned and passed around between drivers in some dynamic way, or some way unpredictable to the driver writer. In development only non-sleeping GPIOs have been seen and everything is fine. One day someone feeds it a GPIO on an I2C expander and the driver crashes. If gpio_request had this built-in check the driver could gracefuly fail to load instead with an appropriate error message.