* [PATCH] gpio: adp5588: Use irqchip template
@ 2020-07-16 15:05 Linus Walleij
2020-07-17 8:33 ` Hennerich, Michael
0 siblings, 1 reply; 2+ messages in thread
From: Linus Walleij @ 2020-07-16 15:05 UTC (permalink / raw)
To: linux-gpio
Cc: Bartosz Golaszewski, Linus Walleij, Nikolaus Voss, Michael Hennerich
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: Nikolaus Voss <nv@vosn.de>
Cc: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
drivers/gpio/gpio-adp5588.c | 39 +++++++++++++++++++++++--------------
1 file changed, 24 insertions(+), 15 deletions(-)
diff --git a/drivers/gpio/gpio-adp5588.c b/drivers/gpio/gpio-adp5588.c
index 49f423d7beba..f1e4ac90e7d3 100644
--- a/drivers/gpio/gpio-adp5588.c
+++ b/drivers/gpio/gpio-adp5588.c
@@ -272,13 +272,24 @@ static irqreturn_t adp5588_irq_handler(int irq, void *devid)
return IRQ_HANDLED;
}
+
+static int adp5588_irq_init_hw(struct gpio_chip *gc)
+{
+ struct adp5588_gpio *dev = gpiochip_get_data(gc);
+ /* Enable IRQs after registering chip */
+ adp5588_gpio_write(dev->client, CFG,
+ ADP5588_AUTO_INC | ADP5588_INT_CFG | ADP5588_KE_IEN);
+
+ return 0;
+}
+
static int adp5588_irq_setup(struct adp5588_gpio *dev)
{
struct i2c_client *client = dev->client;
int ret;
struct adp5588_gpio_platform_data *pdata =
dev_get_platdata(&client->dev);
- int irq_base = pdata ? pdata->irq_base : 0;
+ struct gpio_irq_chip *girq;
adp5588_gpio_write(client, CFG, ADP5588_AUTO_INC);
adp5588_gpio_write(client, INT_STAT, -1); /* status is W1C */
@@ -294,21 +305,19 @@ static int adp5588_irq_setup(struct adp5588_gpio *dev)
client->irq);
return ret;
}
- ret = gpiochip_irqchip_add_nested(&dev->gpio_chip,
- &adp5588_irq_chip, irq_base,
- handle_simple_irq,
- IRQ_TYPE_NONE);
- if (ret) {
- dev_err(&client->dev,
- "could not connect irqchip to gpiochip\n");
- return ret;
- }
- gpiochip_set_nested_irqchip(&dev->gpio_chip,
- &adp5588_irq_chip,
- client->irq);
- adp5588_gpio_write(client, CFG,
- ADP5588_AUTO_INC | ADP5588_INT_CFG | ADP5588_KE_IEN);
+ /* This will be registered in the call to devm_gpiochip_add_data() */
+ girq = &dev->gpio_chip.irq;
+ girq->chip = &adp5588_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->first = pdata ? pdata->irq_base : 0;
+ girq->default_type = IRQ_TYPE_NONE;
+ girq->handler = handle_simple_irq;
+ girq->init_hw = adp5588_irq_init_hw;
+ girq->threaded = true;
return 0;
}
--
2.26.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* RE: [PATCH] gpio: adp5588: Use irqchip template
2020-07-16 15:05 [PATCH] gpio: adp5588: Use irqchip template Linus Walleij
@ 2020-07-17 8:33 ` Hennerich, Michael
0 siblings, 0 replies; 2+ messages in thread
From: Hennerich, Michael @ 2020-07-17 8:33 UTC (permalink / raw)
To: Linus Walleij, linux-gpio; +Cc: Bartosz Golaszewski, Nikolaus Voss
> -----Original Message-----
> From: Linus Walleij <linus.walleij@linaro.org>
> Sent: Donnerstag, 16. Juli 2020 17:05
> To: linux-gpio@vger.kernel.org
> Cc: Bartosz Golaszewski <bgolaszewski@baylibre.com>; Linus Walleij
> <linus.walleij@linaro.org>; Nikolaus Voss <nv@vosn.de>; Hennerich, Michael
> <Michael.Hennerich@analog.com>
> Subject: [PATCH] gpio: adp5588: Use irqchip template
>
> 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: Nikolaus Voss <nv@vosn.de>
> Cc: Michael Hennerich <michael.hennerich@analog.com>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Michael Hennerich <michael.hennerich@analog.com>
> ---
> drivers/gpio/gpio-adp5588.c | 39 +++++++++++++++++++++++--------------
> 1 file changed, 24 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/gpio/gpio-adp5588.c b/drivers/gpio/gpio-adp5588.c index
> 49f423d7beba..f1e4ac90e7d3 100644
> --- a/drivers/gpio/gpio-adp5588.c
> +++ b/drivers/gpio/gpio-adp5588.c
> @@ -272,13 +272,24 @@ static irqreturn_t adp5588_irq_handler(int irq, void
> *devid)
> return IRQ_HANDLED;
> }
>
> +
> +static int adp5588_irq_init_hw(struct gpio_chip *gc) {
> + struct adp5588_gpio *dev = gpiochip_get_data(gc);
> + /* Enable IRQs after registering chip */
> + adp5588_gpio_write(dev->client, CFG,
> + ADP5588_AUTO_INC | ADP5588_INT_CFG |
> ADP5588_KE_IEN);
> +
> + return 0;
> +}
> +
> static int adp5588_irq_setup(struct adp5588_gpio *dev) {
> struct i2c_client *client = dev->client;
> int ret;
> struct adp5588_gpio_platform_data *pdata =
> dev_get_platdata(&client->dev);
> - int irq_base = pdata ? pdata->irq_base : 0;
> + struct gpio_irq_chip *girq;
>
> adp5588_gpio_write(client, CFG, ADP5588_AUTO_INC);
> adp5588_gpio_write(client, INT_STAT, -1); /* status is W1C */ @@ -
> 294,21 +305,19 @@ static int adp5588_irq_setup(struct adp5588_gpio *dev)
> client->irq);
> return ret;
> }
> - ret = gpiochip_irqchip_add_nested(&dev->gpio_chip,
> - &adp5588_irq_chip, irq_base,
> - handle_simple_irq,
> - IRQ_TYPE_NONE);
> - if (ret) {
> - dev_err(&client->dev,
> - "could not connect irqchip to gpiochip\n");
> - return ret;
> - }
> - gpiochip_set_nested_irqchip(&dev->gpio_chip,
> - &adp5588_irq_chip,
> - client->irq);
>
> - adp5588_gpio_write(client, CFG,
> - ADP5588_AUTO_INC | ADP5588_INT_CFG |
> ADP5588_KE_IEN);
> + /* This will be registered in the call to devm_gpiochip_add_data() */
> + girq = &dev->gpio_chip.irq;
> + girq->chip = &adp5588_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->first = pdata ? pdata->irq_base : 0;
> + girq->default_type = IRQ_TYPE_NONE;
> + girq->handler = handle_simple_irq;
> + girq->init_hw = adp5588_irq_init_hw;
> + girq->threaded = true;
>
> return 0;
> }
> --
> 2.26.2
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-07-17 8:33 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-16 15:05 [PATCH] gpio: adp5588: Use irqchip template Linus Walleij
2020-07-17 8:33 ` Hennerich, Michael
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).