Commit 1bbc557d authored by Peng Fan's avatar Peng Fan Committed by Linus Walleij

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: default avatarPeng Fan <van.freenix@gmail.com>
Cc: Alexandre Courbot <gnurou@gmail.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 9e26b0b1
...@@ -196,13 +196,16 @@ static int mxs_gpio_set_wake_irq(struct irq_data *d, unsigned int enable) ...@@ -196,13 +196,16 @@ static int mxs_gpio_set_wake_irq(struct irq_data *d, unsigned int enable)
return 0; return 0;
} }
static void __init mxs_gpio_init_gc(struct mxs_gpio_port *port, int irq_base) static int __init mxs_gpio_init_gc(struct mxs_gpio_port *port, int irq_base)
{ {
struct irq_chip_generic *gc; struct irq_chip_generic *gc;
struct irq_chip_type *ct; struct irq_chip_type *ct;
gc = irq_alloc_generic_chip("gpio-mxs", 1, irq_base, gc = irq_alloc_generic_chip("gpio-mxs", 1, irq_base,
port->base, handle_level_irq); port->base, handle_level_irq);
if (!gc)
return -ENOMEM;
gc->private = port; gc->private = port;
ct = gc->chip_types; ct = gc->chip_types;
...@@ -216,6 +219,8 @@ static void __init mxs_gpio_init_gc(struct mxs_gpio_port *port, int irq_base) ...@@ -216,6 +219,8 @@ static void __init mxs_gpio_init_gc(struct mxs_gpio_port *port, int irq_base)
irq_setup_generic_chip(gc, IRQ_MSK(32), IRQ_GC_INIT_NESTED_LOCK, irq_setup_generic_chip(gc, IRQ_MSK(32), IRQ_GC_INIT_NESTED_LOCK,
IRQ_NOREQUEST, 0); IRQ_NOREQUEST, 0);
return 0;
} }
static int mxs_gpio_to_irq(struct gpio_chip *gc, unsigned offset) 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,7 +322,9 @@ static int mxs_gpio_probe(struct platform_device *pdev)
} }
/* gpio-mxs can be a generic irq chip */ /* gpio-mxs can be a generic irq chip */
mxs_gpio_init_gc(port, irq_base); err = mxs_gpio_init_gc(port, irq_base);
if (err < 0)
goto out_irqdomain_remove;
/* setup one handler for each entry */ /* setup one handler for each entry */
irq_set_chained_handler_and_data(port->irq, mxs_gpio_irq_handler, 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,6 +350,8 @@ static int mxs_gpio_probe(struct platform_device *pdev)
out_bgpio_remove: out_bgpio_remove:
bgpio_remove(&port->bgc); bgpio_remove(&port->bgc);
out_irqdomain_remove:
irq_domain_remove(port->domain);
out_irqdesc_free: out_irqdesc_free:
irq_free_descs(irq_base, 32); irq_free_descs(irq_base, 32);
return err; return err;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment