diff options
author | Peng Fan <van.freenix@gmail.com> | 2015-08-23 09:11:53 -0400 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2015-09-14 03:12:03 -0400 |
commit | 1bbc557d976b4e5ae9a41d619bd79f09ccac9afc (patch) | |
tree | 802816dd4c955efc16730564ff88dd64915b5deb | |
parent | 9e26b0b114adb321a9bf41520bac304ef49e77d1 (diff) |
gpio: mxs: need to check return value of irq_alloc_generic_chip
Need to check return value of irq_alloc_generic_chip, because
it may return NULL.
1. Change mxs_gpio_init_gc return type from void to int.
2. Add a new lable out_irqdomain_remove to remove the irq domain
when mxc_gpio_init_gc fail.
Signed-off-by: Peng Fan <van.freenix@gmail.com>
Cc: Alexandre Courbot <gnurou@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
-rw-r--r-- | drivers/gpio/gpio-mxs.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/drivers/gpio/gpio-mxs.c b/drivers/gpio/gpio-mxs.c index b7f383eb18d9..1387385e6697 100644 --- a/drivers/gpio/gpio-mxs.c +++ b/drivers/gpio/gpio-mxs.c | |||
@@ -196,13 +196,16 @@ static int mxs_gpio_set_wake_irq(struct irq_data *d, unsigned int enable) | |||
196 | return 0; | 196 | return 0; |
197 | } | 197 | } |
198 | 198 | ||
199 | static void __init mxs_gpio_init_gc(struct mxs_gpio_port *port, int irq_base) | 199 | static int __init mxs_gpio_init_gc(struct mxs_gpio_port *port, int irq_base) |
200 | { | 200 | { |
201 | struct irq_chip_generic *gc; | 201 | struct irq_chip_generic *gc; |
202 | struct irq_chip_type *ct; | 202 | struct irq_chip_type *ct; |
203 | 203 | ||
204 | gc = irq_alloc_generic_chip("gpio-mxs", 1, irq_base, | 204 | gc = irq_alloc_generic_chip("gpio-mxs", 1, irq_base, |
205 | port->base, handle_level_irq); | 205 | port->base, handle_level_irq); |
206 | if (!gc) | ||
207 | return -ENOMEM; | ||
208 | |||
206 | gc->private = port; | 209 | gc->private = port; |
207 | 210 | ||
208 | ct = gc->chip_types; | 211 | ct = gc->chip_types; |
@@ -216,6 +219,8 @@ static void __init mxs_gpio_init_gc(struct mxs_gpio_port *port, int irq_base) | |||
216 | 219 | ||
217 | irq_setup_generic_chip(gc, IRQ_MSK(32), IRQ_GC_INIT_NESTED_LOCK, | 220 | irq_setup_generic_chip(gc, IRQ_MSK(32), IRQ_GC_INIT_NESTED_LOCK, |
218 | IRQ_NOREQUEST, 0); | 221 | IRQ_NOREQUEST, 0); |
222 | |||
223 | return 0; | ||
219 | } | 224 | } |
220 | 225 | ||
221 | static int mxs_gpio_to_irq(struct gpio_chip *gc, unsigned offset) | 226 | static int mxs_gpio_to_irq(struct gpio_chip *gc, unsigned offset) |
@@ -317,7 +322,9 @@ static int mxs_gpio_probe(struct platform_device *pdev) | |||
317 | } | 322 | } |
318 | 323 | ||
319 | /* gpio-mxs can be a generic irq chip */ | 324 | /* gpio-mxs can be a generic irq chip */ |
320 | mxs_gpio_init_gc(port, irq_base); | 325 | err = mxs_gpio_init_gc(port, irq_base); |
326 | if (err < 0) | ||
327 | goto out_irqdomain_remove; | ||
321 | 328 | ||
322 | /* setup one handler for each entry */ | 329 | /* setup one handler for each entry */ |
323 | irq_set_chained_handler_and_data(port->irq, mxs_gpio_irq_handler, | 330 | irq_set_chained_handler_and_data(port->irq, mxs_gpio_irq_handler, |
@@ -343,6 +350,8 @@ static int mxs_gpio_probe(struct platform_device *pdev) | |||
343 | 350 | ||
344 | out_bgpio_remove: | 351 | out_bgpio_remove: |
345 | bgpio_remove(&port->bgc); | 352 | bgpio_remove(&port->bgc); |
353 | out_irqdomain_remove: | ||
354 | irq_domain_remove(port->domain); | ||
346 | out_irqdesc_free: | 355 | out_irqdesc_free: |
347 | irq_free_descs(irq_base, 32); | 356 | irq_free_descs(irq_base, 32); |
348 | return err; | 357 | return err; |