diff options
author | Peng Fan <van.freenix@gmail.com> | 2015-08-23 09:11:52 -0400 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2015-09-14 03:12:02 -0400 |
commit | 9e26b0b114adb321a9bf41520bac304ef49e77d1 (patch) | |
tree | eb9b378efe9e7f791912061769cb128bd2dcae7d | |
parent | 6ff33f3902c3b1c5d0db6b1e2c70b6d76fba357f (diff) |
gpio: mxc: 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 mxc_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>
[Manually rebased]
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
-rw-r--r-- | drivers/gpio/gpio-mxc.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/drivers/gpio/gpio-mxc.c b/drivers/gpio/gpio-mxc.c index b752b560126e..8813abab9736 100644 --- a/drivers/gpio/gpio-mxc.c +++ b/drivers/gpio/gpio-mxc.c | |||
@@ -339,13 +339,15 @@ static int gpio_set_wake_irq(struct irq_data *d, u32 enable) | |||
339 | return 0; | 339 | return 0; |
340 | } | 340 | } |
341 | 341 | ||
342 | static void mxc_gpio_init_gc(struct mxc_gpio_port *port, int irq_base) | 342 | static int mxc_gpio_init_gc(struct mxc_gpio_port *port, int irq_base) |
343 | { | 343 | { |
344 | struct irq_chip_generic *gc; | 344 | struct irq_chip_generic *gc; |
345 | struct irq_chip_type *ct; | 345 | struct irq_chip_type *ct; |
346 | 346 | ||
347 | gc = irq_alloc_generic_chip("gpio-mxc", 1, irq_base, | 347 | gc = irq_alloc_generic_chip("gpio-mxc", 1, irq_base, |
348 | port->base, handle_level_irq); | 348 | port->base, handle_level_irq); |
349 | if (!gc) | ||
350 | return -ENOMEM; | ||
349 | gc->private = port; | 351 | gc->private = port; |
350 | 352 | ||
351 | ct = gc->chip_types; | 353 | ct = gc->chip_types; |
@@ -360,6 +362,8 @@ static void mxc_gpio_init_gc(struct mxc_gpio_port *port, int irq_base) | |||
360 | 362 | ||
361 | irq_setup_generic_chip(gc, IRQ_MSK(32), IRQ_GC_INIT_NESTED_LOCK, | 363 | irq_setup_generic_chip(gc, IRQ_MSK(32), IRQ_GC_INIT_NESTED_LOCK, |
362 | IRQ_NOREQUEST, 0); | 364 | IRQ_NOREQUEST, 0); |
365 | |||
366 | return 0; | ||
363 | } | 367 | } |
364 | 368 | ||
365 | static void mxc_gpio_get_hw(struct platform_device *pdev) | 369 | static void mxc_gpio_get_hw(struct platform_device *pdev) |
@@ -477,12 +481,16 @@ static int mxc_gpio_probe(struct platform_device *pdev) | |||
477 | } | 481 | } |
478 | 482 | ||
479 | /* gpio-mxc can be a generic irq chip */ | 483 | /* gpio-mxc can be a generic irq chip */ |
480 | mxc_gpio_init_gc(port, irq_base); | 484 | err = mxc_gpio_init_gc(port, irq_base); |
485 | if (err < 0) | ||
486 | goto out_irqdomain_remove; | ||
481 | 487 | ||
482 | list_add_tail(&port->node, &mxc_gpio_ports); | 488 | list_add_tail(&port->node, &mxc_gpio_ports); |
483 | 489 | ||
484 | return 0; | 490 | return 0; |
485 | 491 | ||
492 | out_irqdomain_remove: | ||
493 | irq_domain_remove(port->domain); | ||
486 | out_irqdesc_free: | 494 | out_irqdesc_free: |
487 | irq_free_descs(irq_base, 32); | 495 | irq_free_descs(irq_base, 32); |
488 | out_gpiochip_remove: | 496 | out_gpiochip_remove: |