Skip to content

Commit

Permalink
gpio_free might sleep, generic part
Browse files Browse the repository at this point in the history
According to the documentation gpio_free should only be called from task
context only.  To make this more explicit add a might sleep to all
implementations.

This is the generic part which changes gpiolib and the fallback
implementation only.

Signed-off-by: Uwe Kleine-König <ukleinek@informatik.uni-freiburg.de>
Cc: David Brownell <david-b@pacbell.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Uwe Kleine-König authored and Linus Torvalds committed Oct 16, 2008
1 parent c557fa3 commit 3d599d1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/gpio/gpiolib.c
Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,8 @@ void gpio_free(unsigned gpio)
unsigned long flags;
struct gpio_desc *desc;

might_sleep();

if (!gpio_is_valid(gpio)) {
WARN_ON(extra_checks);
return;
Expand Down
3 changes: 3 additions & 0 deletions include/linux/gpio.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#else

#include <linux/kernel.h>
#include <linux/types.h>
#include <linux/errno.h>

Expand All @@ -32,6 +33,8 @@ static inline int gpio_request(unsigned gpio, const char *label)

static inline void gpio_free(unsigned gpio)
{
might_sleep();

/* GPIO can never have been requested */
WARN_ON(1);
}
Expand Down

0 comments on commit 3d599d1

Please sign in to comment.