On Fri, May 20, 2022 at 3:36 PM Geert Uytterhoeven <geert+renesas@xxxxxxxxx> wrote: > > Commit 6c846d026d49 ("gpio: Don't fiddle with irqchips marked as > immutable") added a warning to indicate if the gpiolib is altering the > internals of irqchips. Following this change the following warning is > now observed for the gpio-rcar driver: > > gpio gpiochip0: (e6050000.gpio): not an immutable chip, please consider fixing it! > > Fix this by making the irqchip in the gpio-rcar driver immutable. Reviewed-by: Andy Shevchenko <andy.shevchenko@xxxxxxxxx> > Signed-off-by: Geert Uytterhoeven <geert+renesas@xxxxxxxxx> > --- > Against gpio/for-next. > Tested on the koelsch development board (R-Car M2-W). > > v2: > - Factor out hwirq using preferred helper. > --- > drivers/gpio/gpio-rcar.c | 31 ++++++++++++++++++------------- > 1 file changed, 18 insertions(+), 13 deletions(-) > > diff --git a/drivers/gpio/gpio-rcar.c b/drivers/gpio/gpio-rcar.c > index 356aac4de17cf142..5b117f3bd322b5a7 100644 > --- a/drivers/gpio/gpio-rcar.c > +++ b/drivers/gpio/gpio-rcar.c > @@ -44,7 +44,6 @@ struct gpio_rcar_priv { > spinlock_t lock; > struct device *dev; > struct gpio_chip gpio_chip; > - struct irq_chip irq_chip; > unsigned int irq_parent; > atomic_t wakeup_path; > struct gpio_rcar_info info; > @@ -96,16 +95,20 @@ static void gpio_rcar_irq_disable(struct irq_data *d) > { > struct gpio_chip *gc = irq_data_get_irq_chip_data(d); > struct gpio_rcar_priv *p = gpiochip_get_data(gc); > + irq_hw_number_t hwirq = irqd_to_hwirq(d); > > - gpio_rcar_write(p, INTMSK, ~BIT(irqd_to_hwirq(d))); > + gpio_rcar_write(p, INTMSK, ~BIT(hwirq)); > + gpiochip_disable_irq(gc, hwirq); > } > > static void gpio_rcar_irq_enable(struct irq_data *d) > { > struct gpio_chip *gc = irq_data_get_irq_chip_data(d); > struct gpio_rcar_priv *p = gpiochip_get_data(gc); > + irq_hw_number_t hwirq = irqd_to_hwirq(d); > > - gpio_rcar_write(p, MSKCLR, BIT(irqd_to_hwirq(d))); > + gpiochip_enable_irq(gc, hwirq); > + gpio_rcar_write(p, MSKCLR, BIT(hwirq)); > } > > static void gpio_rcar_config_interrupt_input_mode(struct gpio_rcar_priv *p, > @@ -203,6 +206,17 @@ static int gpio_rcar_irq_set_wake(struct irq_data *d, unsigned int on) > return 0; > } > > +static const struct irq_chip gpio_rcar_irq_chip = { > + .name = "gpio-rcar", > + .irq_mask = gpio_rcar_irq_disable, > + .irq_unmask = gpio_rcar_irq_enable, > + .irq_set_type = gpio_rcar_irq_set_type, > + .irq_set_wake = gpio_rcar_irq_set_wake, > + .flags = IRQCHIP_IMMUTABLE | IRQCHIP_SET_TYPE_MASKED | > + IRQCHIP_MASK_ON_SUSPEND, > + GPIOCHIP_IRQ_RESOURCE_HELPERS, > +}; > + > static irqreturn_t gpio_rcar_irq_handler(int irq, void *dev_id) > { > struct gpio_rcar_priv *p = dev_id; > @@ -481,7 +495,6 @@ static int gpio_rcar_probe(struct platform_device *pdev) > { > struct gpio_rcar_priv *p; > struct gpio_chip *gpio_chip; > - struct irq_chip *irq_chip; > struct gpio_irq_chip *girq; > struct device *dev = &pdev->dev; > const char *name = dev_name(dev); > @@ -531,16 +544,8 @@ static int gpio_rcar_probe(struct platform_device *pdev) > gpio_chip->base = -1; > gpio_chip->ngpio = npins; > > - irq_chip = &p->irq_chip; > - irq_chip->name = "gpio-rcar"; > - irq_chip->irq_mask = gpio_rcar_irq_disable; > - irq_chip->irq_unmask = gpio_rcar_irq_enable; > - irq_chip->irq_set_type = gpio_rcar_irq_set_type; > - irq_chip->irq_set_wake = gpio_rcar_irq_set_wake; > - irq_chip->flags = IRQCHIP_SET_TYPE_MASKED | IRQCHIP_MASK_ON_SUSPEND; > - > girq = &gpio_chip->irq; > - girq->chip = irq_chip; > + gpio_irq_chip_set_chip(girq, &gpio_rcar_irq_chip); > /* This will let us handle the parent IRQ in the driver */ > girq->parent_handler = NULL; > girq->num_parents = 0; > -- > 2.25.1 > -- With Best Regards, Andy Shevchenko