Message ID | 20200726221259.133536-1-linus.walleij@linaro.org |
---|---|
State | New |
Headers | show |
Series | [v2] gpio: max732x: Use irqchip template | expand |
Hi Linus, On Mon, 27 Jul 2020 at 01:15, Linus Walleij <linus.walleij@linaro.org> 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: Sam Protsenko <semen.protsenko@linaro.org> > Signed-off-by: Linus Walleij <linus.walleij@linaro.org> > --- > ChangeLog v1->v2: > - Set up the IRQ template *before* registering the GPIO > chip. > --- Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org> Tested-by: Sam Protsenko <semen.protsenko@linaro.org> Everything works fine with MAX7325. Checked LEDs (on O8-O15 pins) and buttons via interrupts (on P0-P7 pins). The code looks good as well, much clearer with interrupt controller implementation hidden behind the GPIO chip abstraction. Thanks! > drivers/gpio/gpio-max732x.c | 30 +++++++++++++++--------------- > 1 file changed, 15 insertions(+), 15 deletions(-) > > diff --git a/drivers/gpio/gpio-max732x.c b/drivers/gpio/gpio-max732x.c > index 63472f308857..238cbe926b9f 100644 > --- a/drivers/gpio/gpio-max732x.c > +++ b/drivers/gpio/gpio-max732x.c > @@ -503,6 +503,8 @@ static int max732x_irq_setup(struct max732x_chip *chip, > > if (((pdata && pdata->irq_base) || client->irq) > && has_irq != INT_NONE) { > + struct gpio_irq_chip *girq; > + > if (pdata) > irq_base = pdata->irq_base; > chip->irq_features = has_irq; > @@ -517,19 +519,17 @@ static int max732x_irq_setup(struct max732x_chip *chip, > client->irq); > return ret; > } > - ret = gpiochip_irqchip_add_nested(&chip->gpio_chip, > - &max732x_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(&chip->gpio_chip, > - &max732x_irq_chip, > - client->irq); > + > + girq = &chip->gpio_chip.irq; > + girq->chip = &max732x_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_simple_irq; > + girq->threaded = true; > + girq->first = irq_base; /* FIXME: get rid of this */ > } > > return 0; > @@ -695,11 +695,11 @@ static int max732x_probe(struct i2c_client *client, > return ret; > } > > - ret = devm_gpiochip_add_data(&client->dev, &chip->gpio_chip, chip); > + ret = max732x_irq_setup(chip, id); > if (ret) > return ret; > > - ret = max732x_irq_setup(chip, id); > + ret = devm_gpiochip_add_data(&client->dev, &chip->gpio_chip, chip); > if (ret) > return ret; > > -- > 2.26.2 >
diff --git a/drivers/gpio/gpio-max732x.c b/drivers/gpio/gpio-max732x.c index 63472f308857..238cbe926b9f 100644 --- a/drivers/gpio/gpio-max732x.c +++ b/drivers/gpio/gpio-max732x.c @@ -503,6 +503,8 @@ static int max732x_irq_setup(struct max732x_chip *chip, if (((pdata && pdata->irq_base) || client->irq) && has_irq != INT_NONE) { + struct gpio_irq_chip *girq; + if (pdata) irq_base = pdata->irq_base; chip->irq_features = has_irq; @@ -517,19 +519,17 @@ static int max732x_irq_setup(struct max732x_chip *chip, client->irq); return ret; } - ret = gpiochip_irqchip_add_nested(&chip->gpio_chip, - &max732x_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(&chip->gpio_chip, - &max732x_irq_chip, - client->irq); + + girq = &chip->gpio_chip.irq; + girq->chip = &max732x_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_simple_irq; + girq->threaded = true; + girq->first = irq_base; /* FIXME: get rid of this */ } return 0; @@ -695,11 +695,11 @@ static int max732x_probe(struct i2c_client *client, return ret; } - ret = devm_gpiochip_add_data(&client->dev, &chip->gpio_chip, chip); + ret = max732x_irq_setup(chip, id); if (ret) return ret; - ret = max732x_irq_setup(chip, id); + ret = devm_gpiochip_add_data(&client->dev, &chip->gpio_chip, chip); if (ret) return ret;
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: Sam Protsenko <semen.protsenko@linaro.org> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> --- ChangeLog v1->v2: - Set up the IRQ template *before* registering the GPIO chip. --- drivers/gpio/gpio-max732x.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-)