[PATCH] gpio_free might sleep, generic part

From: Uwe Kleine-KÃnig
Date: Mon Sep 15 2008 - 16:03:07 EST

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

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

Signed-off-by: Uwe Kleine-KÃnig <ukleinek@xxxxxxxxxxxxxxxxxxxxxxxxxx>
Cc: David Brownell <david-b@xxxxxxxxxxx>
Cc: Guennadi Liakhovetski <g.liakhovetski@xxxxxxxxxxxxxx>
Cc: Greg KH <greg@xxxxxxxxx>
Cc: Kay Sievers <kay.sievers@xxxxxxxx>
Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
Cc: Russell King <rmk+kernel@xxxxxxxxxxxxxxxx>

this is a new version of the patch I sent on 2008-07-24 07:28:35 GMT

David Brownell suggested (via private mail) to split the patch along
arch lines. I did that, added Blackfin (which I missed last time) and
left out DaVinci (in ARCH=arm) on Dave's request.

Something that really made me happy is that git managed to use the old
patch although many includes for arm changed location with only three

Note the series is not compile tested because I only have an x86
compiler handy at the moment.

Best regards

drivers/gpio/gpiolib.c | 2 ++
include/linux/gpio.h | 3 +++
2 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 8d29405..317004f 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -792,6 +792,8 @@ void gpio_free(unsigned gpio)
unsigned long flags;
struct gpio_desc *desc;

+ might_sleep();
if (!gpio_is_valid(gpio)) {
diff --git a/include/linux/gpio.h b/include/linux/gpio.h
index 730a20b..e10c49a 100644
--- a/include/linux/gpio.h
+++ b/include/linux/gpio.h
@@ -8,6 +8,7 @@


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

@@ -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 */

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/