* [PATCH 1/2] gpio: mxc: need to check return value of irq_alloc_generic_chip
@ 2015-08-23 13:11 Peng Fan
2015-08-23 13:11 ` [PATCH 2/2] gpio: mxs: " Peng Fan
2015-09-08 8:32 ` [PATCH 1/2] gpio: mxc: " Linus Walleij
0 siblings, 2 replies; 4+ messages in thread
From: Peng Fan @ 2015-08-23 13:11 UTC (permalink / raw)
To: linus.walleij, gnurou, shawn.guo; +Cc: linux-gpio, linux-kernel, van.freenix
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: Linus Walleij <linus.walleij@linaro.org>
Cc: Alexandre Courbot <gnurou@gmail.com>
---
drivers/gpio/gpio-mxc.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/drivers/gpio/gpio-mxc.c b/drivers/gpio/gpio-mxc.c
index 9f7446a..45bbe729 100644
--- a/drivers/gpio/gpio-mxc.c
+++ b/drivers/gpio/gpio-mxc.c
@@ -339,13 +339,16 @@ static int gpio_set_wake_irq(struct irq_data *d, u32 enable)
return 0;
}
-static void __init mxc_gpio_init_gc(struct mxc_gpio_port *port, int irq_base)
+static int __init mxc_gpio_init_gc(struct mxc_gpio_port *port, int irq_base)
{
struct irq_chip_generic *gc;
struct irq_chip_type *ct;
gc = irq_alloc_generic_chip("gpio-mxc", 1, irq_base,
port->base, handle_level_irq);
+ if (!gc)
+ return -ENOMEM;
+
gc->private = port;
ct = gc->chip_types;
@@ -359,6 +362,8 @@ static void __init mxc_gpio_init_gc(struct mxc_gpio_port *port, int irq_base)
irq_setup_generic_chip(gc, IRQ_MSK(32), IRQ_GC_INIT_NESTED_LOCK,
IRQ_NOREQUEST, 0);
+
+ return 0;
}
static void mxc_gpio_get_hw(struct platform_device *pdev)
@@ -476,12 +481,16 @@ static int mxc_gpio_probe(struct platform_device *pdev)
}
/* gpio-mxc can be a generic irq chip */
- mxc_gpio_init_gc(port, irq_base);
+ err = mxc_gpio_init_gc(port, irq_base);
+ if (err < 0)
+ goto out_irqdomain_remove;
list_add_tail(&port->node, &mxc_gpio_ports);
return 0;
+out_irqdomain_remove:
+ irq_domain_remove(port->domain);
out_irqdesc_free:
irq_free_descs(irq_base, 32);
out_gpiochip_remove:
--
1.8.4.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] gpio: mxs: need to check return value of irq_alloc_generic_chip
2015-08-23 13:11 [PATCH 1/2] gpio: mxc: need to check return value of irq_alloc_generic_chip Peng Fan
@ 2015-08-23 13:11 ` Peng Fan
2015-09-08 8:34 ` Linus Walleij
2015-09-08 8:32 ` [PATCH 1/2] gpio: mxc: " Linus Walleij
1 sibling, 1 reply; 4+ messages in thread
From: Peng Fan @ 2015-08-23 13:11 UTC (permalink / raw)
To: linus.walleij, gnurou, shawn.guo; +Cc: linux-gpio, linux-kernel, van.freenix
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: Linus Walleij <linus.walleij@linaro.org>
Cc: Alexandre Courbot <gnurou@gmail.com>
---
drivers/gpio/gpio-mxs.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/drivers/gpio/gpio-mxs.c b/drivers/gpio/gpio-mxs.c
index 84cbda6..f7c3550 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)
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_type *ct;
gc = irq_alloc_generic_chip("gpio-mxs", 1, irq_base,
port->base, handle_level_irq);
+ if (!gc)
+ return -ENOMEM;
+
gc->private = port;
ct = gc->chip_types;
@@ -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_NOREQUEST, 0);
+
+ return 0;
}
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)
}
/* 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 */
irq_set_chained_handler(port->irq, mxs_gpio_irq_handler);
@@ -343,6 +350,8 @@ static int mxs_gpio_probe(struct platform_device *pdev)
out_bgpio_remove:
bgpio_remove(&port->bgc);
+out_irqdomain_remove:
+ irq_domain_remove(port->domain);
out_irqdesc_free:
irq_free_descs(irq_base, 32);
return err;
--
1.8.4.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] gpio: mxc: need to check return value of irq_alloc_generic_chip
2015-08-23 13:11 [PATCH 1/2] gpio: mxc: need to check return value of irq_alloc_generic_chip Peng Fan
2015-08-23 13:11 ` [PATCH 2/2] gpio: mxs: " Peng Fan
@ 2015-09-08 8:32 ` Linus Walleij
1 sibling, 0 replies; 4+ messages in thread
From: Linus Walleij @ 2015-09-08 8:32 UTC (permalink / raw)
To: Peng Fan
Cc: Alexandre Courbot, Shawn Guo, linux-gpio@vger.kernel.org,
linux-kernel@vger.kernel.org
On Sun, Aug 23, 2015 at 3:11 PM, Peng Fan <van.freenix@gmail.com> wrote:
> 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: Linus Walleij <linus.walleij@linaro.org>
> Cc: Alexandre Courbot <gnurou@gmail.com>
I manually rebased this and applied to fixes.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] gpio: mxs: need to check return value of irq_alloc_generic_chip
2015-08-23 13:11 ` [PATCH 2/2] gpio: mxs: " Peng Fan
@ 2015-09-08 8:34 ` Linus Walleij
0 siblings, 0 replies; 4+ messages in thread
From: Linus Walleij @ 2015-09-08 8:34 UTC (permalink / raw)
To: Peng Fan
Cc: Alexandre Courbot, Shawn Guo, linux-gpio@vger.kernel.org,
linux-kernel@vger.kernel.org
On Sun, Aug 23, 2015 at 3:11 PM, Peng Fan <van.freenix@gmail.com> wrote:
> 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: Linus Walleij <linus.walleij@linaro.org>
> Cc: Alexandre Courbot <gnurou@gmail.com>
Rebased and applied for fixes.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-09-08 8:34 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-23 13:11 [PATCH 1/2] gpio: mxc: need to check return value of irq_alloc_generic_chip Peng Fan
2015-08-23 13:11 ` [PATCH 2/2] gpio: mxs: " Peng Fan
2015-09-08 8:34 ` Linus Walleij
2015-09-08 8:32 ` [PATCH 1/2] gpio: mxc: " Linus Walleij
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox