diff mbox series

pinctrl: ingenic: Pass irqchip when adding gpiochip

Message ID 20191001133209.17164-1-linus.walleij@linaro.org
State Accepted
Commit 142b876750a97b883f1c29e1ceae08adfe38c97c
Headers show
Series pinctrl: ingenic: Pass irqchip when adding gpiochip | expand

Commit Message

Linus Walleij Oct. 1, 2019, 1:32 p.m. UTC
We need to convert all old gpio irqchips to pass the irqchip
setup along when adding the gpio_chip. For more info see
drivers/gpio/TODO.

For chained irqchips this is a pretty straight-forward
conversion.

Cc: Zhou Yanjie <zhouyanjie@zoho.com>
Cc: Paul Cercueil <paul@crapouillou.net>
Cc: Thierry Reding <thierry.reding@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

---
 drivers/pinctrl/pinctrl-ingenic.c | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

-- 
2.21.0

Comments

Zhou Yanjie Oct. 2, 2019, 11:49 a.m. UTC | #1
On 2019年10月01日 21:32, Linus Walleij wrote:
> We need to convert all old gpio irqchips to pass the irqchip

> setup along when adding the gpio_chip. For more info see

> drivers/gpio/TODO.

>

> For chained irqchips this is a pretty straight-forward

> conversion.


Acked-by: Zhou Yanjie <zhouyanjie@zoho.com>


>

> Cc: Zhou Yanjie <zhouyanjie@zoho.com>

> Cc: Paul Cercueil <paul@crapouillou.net>

> Cc: Thierry Reding <thierry.reding@gmail.com>

> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

> ---

>   drivers/pinctrl/pinctrl-ingenic.c | 22 ++++++++++++++--------

>   1 file changed, 14 insertions(+), 8 deletions(-)

>

> diff --git a/drivers/pinctrl/pinctrl-ingenic.c b/drivers/pinctrl/pinctrl-ingenic.c

> index 6e2683016c1f..06cae38f6daf 100644

> --- a/drivers/pinctrl/pinctrl-ingenic.c

> +++ b/drivers/pinctrl/pinctrl-ingenic.c

> @@ -1940,6 +1940,7 @@ static int __init ingenic_gpio_probe(struct ingenic_pinctrl *jzpc,

>   {

>   	struct ingenic_gpio_chip *jzgc;

>   	struct device *dev = jzpc->dev;

> +	struct gpio_irq_chip *girq;

>   	unsigned int bank;

>   	int err;

>   

> @@ -1982,10 +1983,6 @@ static int __init ingenic_gpio_probe(struct ingenic_pinctrl *jzpc,

>   		jzgc->gc.free = gpiochip_generic_free;

>   	}

>   

> -	err = devm_gpiochip_add_data(dev, &jzgc->gc, jzgc);

> -	if (err)

> -		return err;

> -

>   	jzgc->irq = irq_of_parse_and_map(node, 0);

>   	if (!jzgc->irq)

>   		return -EINVAL;

> @@ -2000,13 +1997,22 @@ static int __init ingenic_gpio_probe(struct ingenic_pinctrl *jzpc,

>   	jzgc->irq_chip.irq_set_wake = ingenic_gpio_irq_set_wake;

>   	jzgc->irq_chip.flags = IRQCHIP_MASK_ON_SUSPEND;

>   

> -	err = gpiochip_irqchip_add(&jzgc->gc, &jzgc->irq_chip, 0,

> -			handle_level_irq, IRQ_TYPE_NONE);

> +	girq = &jzgc->gc.irq;

> +	girq->chip = &jzgc->irq_chip;

> +	girq->parent_handler = ingenic_gpio_irq_handler;

> +	girq->num_parents = 1;

> +	girq->parents = devm_kcalloc(dev, 1, sizeof(*girq->parents),

> +				     GFP_KERNEL);

> +	if (!girq->parents)

> +		return -ENOMEM;

> +	girq->parents[0] = jzgc->irq;

> +	girq->default_type = IRQ_TYPE_NONE;

> +	girq->handler = handle_level_irq;

> +

> +	err = devm_gpiochip_add_data(dev, &jzgc->gc, jzgc);

>   	if (err)

>   		return err;

>   

> -	gpiochip_set_chained_irqchip(&jzgc->gc, &jzgc->irq_chip,

> -			jzgc->irq, ingenic_gpio_irq_handler);

>   	return 0;

>   }

>
Paul Cercueil Oct. 6, 2019, 12:11 a.m. UTC | #2
Le mar., oct. 1, 2019 at 15:32, Linus Walleij 
<linus.walleij@linaro.org> a écrit :
> We need to convert all old gpio irqchips to pass the irqchip

> setup along when adding the gpio_chip. For more info see

> drivers/gpio/TODO.

> 

> For chained irqchips this is a pretty straight-forward

> conversion.

> 

> Cc: Zhou Yanjie <zhouyanjie@zoho.com>

> Cc: Paul Cercueil <paul@crapouillou.net>

> Cc: Thierry Reding <thierry.reding@gmail.com>

> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>


Acked-by: Paul Cercueil <paul@crapouillou.net>


> ---

>  drivers/pinctrl/pinctrl-ingenic.c | 22 ++++++++++++++--------

>  1 file changed, 14 insertions(+), 8 deletions(-)

> 

> diff --git a/drivers/pinctrl/pinctrl-ingenic.c 

> b/drivers/pinctrl/pinctrl-ingenic.c

> index 6e2683016c1f..06cae38f6daf 100644

> --- a/drivers/pinctrl/pinctrl-ingenic.c

> +++ b/drivers/pinctrl/pinctrl-ingenic.c

> @@ -1940,6 +1940,7 @@ static int __init ingenic_gpio_probe(struct 

> ingenic_pinctrl *jzpc,

>  {

>  	struct ingenic_gpio_chip *jzgc;

>  	struct device *dev = jzpc->dev;

> +	struct gpio_irq_chip *girq;

>  	unsigned int bank;

>  	int err;

> 

> @@ -1982,10 +1983,6 @@ static int __init ingenic_gpio_probe(struct 

> ingenic_pinctrl *jzpc,

>  		jzgc->gc.free = gpiochip_generic_free;

>  	}

> 

> -	err = devm_gpiochip_add_data(dev, &jzgc->gc, jzgc);

> -	if (err)

> -		return err;

> -

>  	jzgc->irq = irq_of_parse_and_map(node, 0);

>  	if (!jzgc->irq)

>  		return -EINVAL;

> @@ -2000,13 +1997,22 @@ static int __init ingenic_gpio_probe(struct 

> ingenic_pinctrl *jzpc,

>  	jzgc->irq_chip.irq_set_wake = ingenic_gpio_irq_set_wake;

>  	jzgc->irq_chip.flags = IRQCHIP_MASK_ON_SUSPEND;

> 

> -	err = gpiochip_irqchip_add(&jzgc->gc, &jzgc->irq_chip, 0,

> -			handle_level_irq, IRQ_TYPE_NONE);

> +	girq = &jzgc->gc.irq;

> +	girq->chip = &jzgc->irq_chip;

> +	girq->parent_handler = ingenic_gpio_irq_handler;

> +	girq->num_parents = 1;

> +	girq->parents = devm_kcalloc(dev, 1, sizeof(*girq->parents),

> +				     GFP_KERNEL);

> +	if (!girq->parents)

> +		return -ENOMEM;

> +	girq->parents[0] = jzgc->irq;

> +	girq->default_type = IRQ_TYPE_NONE;

> +	girq->handler = handle_level_irq;

> +

> +	err = devm_gpiochip_add_data(dev, &jzgc->gc, jzgc);

>  	if (err)

>  		return err;

> 

> -	gpiochip_set_chained_irqchip(&jzgc->gc, &jzgc->irq_chip,

> -			jzgc->irq, ingenic_gpio_irq_handler);

>  	return 0;

>  }

> 

> --

> 2.21.0

>
diff mbox series

Patch

diff --git a/drivers/pinctrl/pinctrl-ingenic.c b/drivers/pinctrl/pinctrl-ingenic.c
index 6e2683016c1f..06cae38f6daf 100644
--- a/drivers/pinctrl/pinctrl-ingenic.c
+++ b/drivers/pinctrl/pinctrl-ingenic.c
@@ -1940,6 +1940,7 @@  static int __init ingenic_gpio_probe(struct ingenic_pinctrl *jzpc,
 {
 	struct ingenic_gpio_chip *jzgc;
 	struct device *dev = jzpc->dev;
+	struct gpio_irq_chip *girq;
 	unsigned int bank;
 	int err;
 
@@ -1982,10 +1983,6 @@  static int __init ingenic_gpio_probe(struct ingenic_pinctrl *jzpc,
 		jzgc->gc.free = gpiochip_generic_free;
 	}
 
-	err = devm_gpiochip_add_data(dev, &jzgc->gc, jzgc);
-	if (err)
-		return err;
-
 	jzgc->irq = irq_of_parse_and_map(node, 0);
 	if (!jzgc->irq)
 		return -EINVAL;
@@ -2000,13 +1997,22 @@  static int __init ingenic_gpio_probe(struct ingenic_pinctrl *jzpc,
 	jzgc->irq_chip.irq_set_wake = ingenic_gpio_irq_set_wake;
 	jzgc->irq_chip.flags = IRQCHIP_MASK_ON_SUSPEND;
 
-	err = gpiochip_irqchip_add(&jzgc->gc, &jzgc->irq_chip, 0,
-			handle_level_irq, IRQ_TYPE_NONE);
+	girq = &jzgc->gc.irq;
+	girq->chip = &jzgc->irq_chip;
+	girq->parent_handler = ingenic_gpio_irq_handler;
+	girq->num_parents = 1;
+	girq->parents = devm_kcalloc(dev, 1, sizeof(*girq->parents),
+				     GFP_KERNEL);
+	if (!girq->parents)
+		return -ENOMEM;
+	girq->parents[0] = jzgc->irq;
+	girq->default_type = IRQ_TYPE_NONE;
+	girq->handler = handle_level_irq;
+
+	err = devm_gpiochip_add_data(dev, &jzgc->gc, jzgc);
 	if (err)
 		return err;
 
-	gpiochip_set_chained_irqchip(&jzgc->gc, &jzgc->irq_chip,
-			jzgc->irq, ingenic_gpio_irq_handler);
 	return 0;
 }