diff mbox series

[3/5] gpio: siox: Pass irqchip when adding gpiochip

Message ID 20190626084407.27976-3-linus.walleij@linaro.org
State New
Headers show
Series [1/5] gpio: siox: Do not call gpiochip_remove() on errorpath | expand

Commit Message

Linus Walleij June 26, 2019, 8:44 a.m. UTC
We need to convert all old gpio irqchips to pass the irqchip
setup along when adding the gpio_chip.

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

Cc: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Cc: Thierry Reding <treding@nvidia.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

---
ChangeLog v1->v2:
- Split out bugfixes to separate patches.
---
 drivers/gpio/gpio-siox.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

-- 
2.20.1

Comments

Uwe Kleine-König June 26, 2019, 9:16 a.m. UTC | #1
On Wed, Jun 26, 2019 at 10:44:05AM +0200, Linus Walleij wrote:
> We need to convert all old gpio irqchips to pass the irqchip

> setup along when adding the gpio_chip.

> 

> For chained irqchips this is a pretty straight-forward

> conversion.

> 

> Cc: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

> Cc: Thierry Reding <treding@nvidia.com>

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

> ---

> ChangeLog v1->v2:

> - Split out bugfixes to separate patches.

> ---

>  drivers/gpio/gpio-siox.c | 14 +++++++-------

>  1 file changed, 7 insertions(+), 7 deletions(-)

> 

> diff --git a/drivers/gpio/gpio-siox.c b/drivers/gpio/gpio-siox.c

> index 40067e1535d3..31749c058e33 100644

> --- a/drivers/gpio/gpio-siox.c

> +++ b/drivers/gpio/gpio-siox.c

> @@ -211,6 +211,7 @@ static int gpio_siox_get_direction(struct gpio_chip *chip, unsigned int offset)

>  static int gpio_siox_probe(struct siox_device *sdevice)

>  {

>  	struct gpio_siox_ddata *ddata;

> +	struct gpio_irq_chip *girq;

>  	int ret;

>  

>  	ddata = devm_kzalloc(&sdevice->dev, sizeof(*ddata), GFP_KERNEL);

> @@ -239,6 +240,11 @@ static int gpio_siox_probe(struct siox_device *sdevice)

>  	ddata->ichip.irq_unmask = gpio_siox_irq_unmask;

>  	ddata->ichip.irq_set_type = gpio_siox_irq_set_type;

>  

> +	girq = &ddata->gchip.irq;

> +	girq->chip = &ddata->ichip;

> +	girq->default_type = IRQ_TYPE_NONE;

> +	girq->handler = handle_level_irq;

> +

>  	ret = gpiochip_add(&ddata->gchip);

>  	if (ret) {

>  		dev_err(&sdevice->dev,

> @@ -246,13 +252,7 @@ static int gpio_siox_probe(struct siox_device *sdevice)

>  		return ret;

>  	}

>  

> -	ret = gpiochip_irqchip_add(&ddata->gchip, &ddata->ichip,

> -				   0, handle_level_irq, IRQ_TYPE_NONE);

> -	if (ret)

> -		dev_err(&sdevice->dev,

> -			"Failed to register irq chip (%d)\n", ret);

> -

> -	return ret;

> +	return 0;

>  }


You can simplify this a bit further from:

	if (ret) {
		...
		return ret;
	}
	return 0;

to

	if (ret) {
		...
	}
	return ret;

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
diff mbox series

Patch

diff --git a/drivers/gpio/gpio-siox.c b/drivers/gpio/gpio-siox.c
index 40067e1535d3..31749c058e33 100644
--- a/drivers/gpio/gpio-siox.c
+++ b/drivers/gpio/gpio-siox.c
@@ -211,6 +211,7 @@  static int gpio_siox_get_direction(struct gpio_chip *chip, unsigned int offset)
 static int gpio_siox_probe(struct siox_device *sdevice)
 {
 	struct gpio_siox_ddata *ddata;
+	struct gpio_irq_chip *girq;
 	int ret;
 
 	ddata = devm_kzalloc(&sdevice->dev, sizeof(*ddata), GFP_KERNEL);
@@ -239,6 +240,11 @@  static int gpio_siox_probe(struct siox_device *sdevice)
 	ddata->ichip.irq_unmask = gpio_siox_irq_unmask;
 	ddata->ichip.irq_set_type = gpio_siox_irq_set_type;
 
+	girq = &ddata->gchip.irq;
+	girq->chip = &ddata->ichip;
+	girq->default_type = IRQ_TYPE_NONE;
+	girq->handler = handle_level_irq;
+
 	ret = gpiochip_add(&ddata->gchip);
 	if (ret) {
 		dev_err(&sdevice->dev,
@@ -246,13 +252,7 @@  static int gpio_siox_probe(struct siox_device *sdevice)
 		return ret;
 	}
 
-	ret = gpiochip_irqchip_add(&ddata->gchip, &ddata->ichip,
-				   0, handle_level_irq, IRQ_TYPE_NONE);
-	if (ret)
-		dev_err(&sdevice->dev,
-			"Failed to register irq chip (%d)\n", ret);
-
-	return ret;
+	return 0;
 }
 
 static int gpio_siox_remove(struct siox_device *sdevice)