diff options
author | Laxman Dewangan <ldewangan@nvidia.com> | 2013-11-06 18:58:55 +0530 |
---|---|---|
committer | Laxman Dewangan <ldewangan@nvidia.com> | 2013-11-07 01:34:42 -0800 |
commit | db891ade3f16af81811794697618038e4ea887d3 (patch) | |
tree | 8646bcb7dc6bdabaa329fdb34bb3a9f6c3e59290 | |
parent | eca620c9554dca9cc8dc254f27e971abb84c2583 (diff) |
gpio: fix allocation in atomic context
For initialisation of the GPIO based on DT data, it allocates memory.
Hence calling the gpio initialisation based on dt node on non-atomic
context.
bug 1400884
Change-Id: I69b7a4be980078c1fa5e5e43f9c7bf24ecb97dd2
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Reviewed-on: http://git-master/r/327106
GVS: Gerrit_Virtual_Submit
-rw-r--r-- | drivers/gpio/gpiolib-of.c | 8 | ||||
-rw-r--r-- | drivers/gpio/gpiolib.c | 2 | ||||
-rw-r--r-- | include/linux/of_gpio.h | 2 |
3 files changed, 8 insertions, 4 deletions
diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c index 0fe1c83f4cbe..627b23cdabd8 100644 --- a/drivers/gpio/gpiolib-of.c +++ b/drivers/gpio/gpiolib-of.c @@ -218,7 +218,7 @@ static void of_gpiochip_add_pin_range(struct gpio_chip *chip) static void of_gpiochip_add_pin_range(struct gpio_chip *chip) {} #endif -static int of_gpio_init(struct gpio_chip *chip) +void of_gpiochip_init(struct gpio_chip *chip) { struct device_node *np = chip->of_node; struct device_node *np_config; @@ -231,6 +231,9 @@ static int of_gpio_init(struct gpio_chip *chip) int offset; int i; + if (!chip->of_node) + return; + /* For each defined state ID */ for (state = 0; ; state++) { /* Retrieve the gpio-init-* property */ @@ -276,8 +279,6 @@ static int of_gpio_init(struct gpio_chip *chip) of_node_put(np_config); kfree(propname); } - - return 0; } void of_gpiochip_add(struct gpio_chip *chip) @@ -294,7 +295,6 @@ void of_gpiochip_add(struct gpio_chip *chip) } of_gpiochip_add_pin_range(chip); - of_gpio_init(chip); of_node_get(chip->of_node); } diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index c2534d62911c..193bedfbcdcb 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -1226,6 +1226,8 @@ unlock: if (status) goto fail; + of_gpiochip_init(chip); + status = gpiochip_export(chip); if (status) goto fail; diff --git a/include/linux/of_gpio.h b/include/linux/of_gpio.h index a83dc6f5008e..dcd0729f28ab 100644 --- a/include/linux/of_gpio.h +++ b/include/linux/of_gpio.h @@ -54,6 +54,7 @@ extern int of_mm_gpiochip_add(struct device_node *np, struct of_mm_gpio_chip *mm_gc); extern void of_gpiochip_add(struct gpio_chip *gc); +extern void of_gpiochip_init(struct gpio_chip *gc); extern void of_gpiochip_remove(struct gpio_chip *gc); extern int of_gpio_simple_xlate(struct gpio_chip *gc, const struct of_phandle_args *gpiospec, @@ -76,6 +77,7 @@ static inline int of_gpio_simple_xlate(struct gpio_chip *gc, } static inline void of_gpiochip_add(struct gpio_chip *gc) { } +static inline void of_gpiochip_init(struct gpio_chip *gc) { } static inline void of_gpiochip_remove(struct gpio_chip *gc) { } #endif /* CONFIG_OF_GPIO */ |