Linux-GPIO Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] pinctrl: sx150x: Use irqchip template
@ 2020-07-21 13:25 Linus Walleij
  2020-07-21 13:53 ` Neil Armstrong
  0 siblings, 1 reply; 2+ messages in thread
From: Linus Walleij @ 2020-07-21 13:25 UTC (permalink / raw)
  To: linux-gpio; +Cc: Linus Walleij, Peter Rosin, Andrey Smirnov, Neil Armstrong

This makes the driver use the irqchip template to assign
properties to the gpio_irq_chip instead of using the
explicit calls to gpiochip_irqchip_add_nested() and
gpiochip_set_nested_irqchip(). The irqchip is instead
added while adding the gpiochip.

Cc: Peter Rosin <peda@axentia.se>
Cc: Andrey Smirnov <andrew.smirnov@gmail.com>
Cc: Neil Armstrong <narmstrong@baylibre.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/pinctrl/pinctrl-sx150x.c | 44 ++++++++++++++++----------------
 1 file changed, 22 insertions(+), 22 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-sx150x.c b/drivers/pinctrl/pinctrl-sx150x.c
index 708bc91862fe..b325a136ac48 100644
--- a/drivers/pinctrl/pinctrl-sx150x.c
+++ b/drivers/pinctrl/pinctrl-sx150x.c
@@ -1187,17 +1187,10 @@ static int sx150x_probe(struct i2c_client *client,
 	if (pctl->data->model != SX150X_789)
 		pctl->gpio.set_multiple = sx150x_gpio_set_multiple;
 
-	ret = devm_gpiochip_add_data(dev, &pctl->gpio, pctl);
-	if (ret)
-		return ret;
-
-	ret = gpiochip_add_pin_range(&pctl->gpio, dev_name(dev),
-				     0, 0, pctl->data->npins);
-	if (ret)
-		return ret;
-
 	/* Add Interrupt support if an irq is specified */
 	if (client->irq > 0) {
+		struct gpio_irq_chip *girq;
+
 		pctl->irq_chip.irq_mask = sx150x_irq_mask;
 		pctl->irq_chip.irq_unmask = sx150x_irq_unmask;
 		pctl->irq_chip.irq_set_type = sx150x_irq_set_type;
@@ -1213,8 +1206,8 @@ static int sx150x_probe(struct i2c_client *client,
 
 		/*
 		 * Because sx150x_irq_threaded_fn invokes all of the
-		 * nested interrrupt handlers via handle_nested_irq,
-		 * any "handler" passed to gpiochip_irqchip_add()
+		 * nested interrupt handlers via handle_nested_irq,
+		 * any "handler" assigned to struct gpio_irq_chip
 		 * below is going to be ignored, so the choice of the
 		 * function does not matter that much.
 		 *
@@ -1222,13 +1215,15 @@ static int sx150x_probe(struct i2c_client *client,
 		 * plus it will be instantly noticeable if it is ever
 		 * called (should not happen)
 		 */
-		ret = gpiochip_irqchip_add_nested(&pctl->gpio,
-					&pctl->irq_chip, 0,
-					handle_bad_irq, IRQ_TYPE_NONE);
-		if (ret) {
-			dev_err(dev, "could not connect irqchip to gpiochip\n");
-			return ret;
-		}
+		girq = &pctl->gpio.irq;
+		girq->chip = &pctl->irq_chip;
+		/* This will let us handle the parent IRQ in the driver */
+		girq->parent_handler = NULL;
+		girq->num_parents = 0;
+		girq->parents = NULL;
+		girq->default_type = IRQ_TYPE_NONE;
+		girq->handler = handle_bad_irq;
+		girq->threaded = true;
 
 		ret = devm_request_threaded_irq(dev, client->irq, NULL,
 						sx150x_irq_thread_fn,
@@ -1237,12 +1232,17 @@ static int sx150x_probe(struct i2c_client *client,
 						pctl->irq_chip.name, pctl);
 		if (ret < 0)
 			return ret;
-
-		gpiochip_set_nested_irqchip(&pctl->gpio,
-					    &pctl->irq_chip,
-					    client->irq);
 	}
 
+	ret = devm_gpiochip_add_data(dev, &pctl->gpio, pctl);
+	if (ret)
+		return ret;
+
+	ret = gpiochip_add_pin_range(&pctl->gpio, dev_name(dev),
+				     0, 0, pctl->data->npins);
+	if (ret)
+		return ret;
+
 	return 0;
 }
 
-- 
2.26.2


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] pinctrl: sx150x: Use irqchip template
  2020-07-21 13:25 [PATCH] pinctrl: sx150x: Use irqchip template Linus Walleij
@ 2020-07-21 13:53 ` Neil Armstrong
  0 siblings, 0 replies; 2+ messages in thread
From: Neil Armstrong @ 2020-07-21 13:53 UTC (permalink / raw)
  To: Linus Walleij, linux-gpio; +Cc: Peter Rosin, Andrey Smirnov

On 21/07/2020 15:25, Linus Walleij wrote:
> This makes the driver use the irqchip template to assign
> properties to the gpio_irq_chip instead of using the
> explicit calls to gpiochip_irqchip_add_nested() and
> gpiochip_set_nested_irqchip(). The irqchip is instead
> added while adding the gpiochip.
> 
> Cc: Peter Rosin <peda@axentia.se>
> Cc: Andrey Smirnov <andrew.smirnov@gmail.com>
> Cc: Neil Armstrong <narmstrong@baylibre.com>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
>  drivers/pinctrl/pinctrl-sx150x.c | 44 ++++++++++++++++----------------
>  1 file changed, 22 insertions(+), 22 deletions(-)
> 
> diff --git a/drivers/pinctrl/pinctrl-sx150x.c b/drivers/pinctrl/pinctrl-sx150x.c
> index 708bc91862fe..b325a136ac48 100644
> --- a/drivers/pinctrl/pinctrl-sx150x.c
> +++ b/drivers/pinctrl/pinctrl-sx150x.c
> @@ -1187,17 +1187,10 @@ static int sx150x_probe(struct i2c_client *client,
>  	if (pctl->data->model != SX150X_789)
>  		pctl->gpio.set_multiple = sx150x_gpio_set_multiple;
>  
> -	ret = devm_gpiochip_add_data(dev, &pctl->gpio, pctl);
> -	if (ret)
> -		return ret;
> -
> -	ret = gpiochip_add_pin_range(&pctl->gpio, dev_name(dev),
> -				     0, 0, pctl->data->npins);
> -	if (ret)
> -		return ret;
> -
>  	/* Add Interrupt support if an irq is specified */
>  	if (client->irq > 0) {
> +		struct gpio_irq_chip *girq;
> +
>  		pctl->irq_chip.irq_mask = sx150x_irq_mask;
>  		pctl->irq_chip.irq_unmask = sx150x_irq_unmask;
>  		pctl->irq_chip.irq_set_type = sx150x_irq_set_type;
> @@ -1213,8 +1206,8 @@ static int sx150x_probe(struct i2c_client *client,
>  
>  		/*
>  		 * Because sx150x_irq_threaded_fn invokes all of the
> -		 * nested interrrupt handlers via handle_nested_irq,
> -		 * any "handler" passed to gpiochip_irqchip_add()
> +		 * nested interrupt handlers via handle_nested_irq,
> +		 * any "handler" assigned to struct gpio_irq_chip
>  		 * below is going to be ignored, so the choice of the
>  		 * function does not matter that much.
>  		 *
> @@ -1222,13 +1215,15 @@ static int sx150x_probe(struct i2c_client *client,
>  		 * plus it will be instantly noticeable if it is ever
>  		 * called (should not happen)
>  		 */
> -		ret = gpiochip_irqchip_add_nested(&pctl->gpio,
> -					&pctl->irq_chip, 0,
> -					handle_bad_irq, IRQ_TYPE_NONE);
> -		if (ret) {
> -			dev_err(dev, "could not connect irqchip to gpiochip\n");
> -			return ret;
> -		}
> +		girq = &pctl->gpio.irq;
> +		girq->chip = &pctl->irq_chip;
> +		/* This will let us handle the parent IRQ in the driver */
> +		girq->parent_handler = NULL;
> +		girq->num_parents = 0;
> +		girq->parents = NULL;
> +		girq->default_type = IRQ_TYPE_NONE;
> +		girq->handler = handle_bad_irq;
> +		girq->threaded = true;
>  
>  		ret = devm_request_threaded_irq(dev, client->irq, NULL,
>  						sx150x_irq_thread_fn,
> @@ -1237,12 +1232,17 @@ static int sx150x_probe(struct i2c_client *client,
>  						pctl->irq_chip.name, pctl);
>  		if (ret < 0)
>  			return ret;
> -
> -		gpiochip_set_nested_irqchip(&pctl->gpio,
> -					    &pctl->irq_chip,
> -					    client->irq);
>  	}
>  
> +	ret = devm_gpiochip_add_data(dev, &pctl->gpio, pctl);
> +	if (ret)
> +		return ret;
> +
> +	ret = gpiochip_add_pin_range(&pctl->gpio, dev_name(dev),
> +				     0, 0, pctl->data->npins);
> +	if (ret)
> +		return ret;
> +
>  	return 0;
>  }
>  
> 

Acked-by: Neil Armstrong <narmstrong@baylibre.com>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-21 13:25 [PATCH] pinctrl: sx150x: Use irqchip template Linus Walleij
2020-07-21 13:53 ` Neil Armstrong

Linux-GPIO Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-gpio/0 linux-gpio/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-gpio linux-gpio/ https://lore.kernel.org/linux-gpio \
		linux-gpio@vger.kernel.org
	public-inbox-index linux-gpio

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-gpio


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git