gpiolib: Add comments explaining the _cansleep() WARN_ON()s
PATCH 1/1 gpiolib: Add comments explaining the _cansleep() WARN_ON()s
I've seen users getting very confused by the WARN_ON()s for can_sleep GPIOs in the atomic-safe paths, the discoverability of the non-atomic version of the API seems to be hampered by the fact that it's defined in a header file not the .c file where the warnings are.
Add a couple of comments next to the warnings to help people on their way.
--- drivers/gpio/gpiolib.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/gpio/gpiolib.c +2 -0
@@ -1560,6 +1560,7 @@ int __gpio_get_value(unsigned gpio)int value; chip =gpio_to_chip (gpio); +/* Should be using gpio_get_value_cansleep() or a different GPIO */ WARN_ON (chip->can_sleep); value = chip->get ? chip->get (chip, gpio - chip->base) :0 ;trace_gpio_value (gpio,1 , value);
@@ -1581,6 +1582,7 @@ void __gpio_set_value(unsigned gpio, int value)struct gpio_chip *chip; chip =gpio_to_chip (gpio); +/* Should be using gpio_set_value_cansleep() or a different GPIO */ WARN_ON (chip->can_sleep);trace_gpio_value (gpio,0 , value); chip->set (chip, gpio - chip->base, value);
Signature · 1 line
1.7.9.rc1
Quoted 7 lines · Mark Brown
I've seen users getting very confused by the WARN_ON()s for
can_sleepGPIOs in the atomic-safe paths, the discoverability of the non-atomic version of the API seems to be hampered by the fact that it's defined in a header file not the .c file where the warnings are.Add a couple of comments next to the warnings to help people on their way.
Good!
Quoted 2 lines
+ /* Should be using
gpio_get_value_cansleep()or a different GPIO */WARN_ON(chip->can_sleep);
Actually I cannot parse the "or a different GPIO" part.
If this means that the user may be addressing the wrong GPIO pin, then we could spell that out I presume, but maybe you are referring to something else?
Yours,
Linus Walleij
Quoted 10 lines · Linus Walleij
On Fri, Feb 17, 2012 at 7:24 PM, Mark Brown
Quoted 2 lines
+ /* Should be using
gpio_get_value_cansleep()or a different GPIO */WARN_ON(chip->can_sleep);Actually I cannot parse the "or a different GPIO" part.
If this means that the user may be addressing the wrong GPIO pin, then we could spell that out I presume, but maybe you are referring to something else?
It was intended as a hint that if you really need to be in atomic context to do whatever this isn't the GPIO for you but in retrospect it's probably not actually useful advice for most users. I'll respin.