pinctrl: qcom: spmi-gpio: Make irqchip immutable
authorManivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Tue, 30 Aug 2022 09:22:32 +0000 (14:52 +0530)
committerLinus Walleij <linus.walleij@linaro.org>
Thu, 8 Sep 2022 12:24:28 +0000 (14:24 +0200)
The irqchip implementation used inside the gpiochips are not supposed to
be changed during runtime. So let's make the one inside the spmi-gpio
gpiochip immutable.

This fixes the below warning during boot:
gpio gpiochip0: (c440000.spmi:pmic@0:gpio@c000): not an immutable chip, please consider fixing it!

Acked-by: Marc Zyngier <maz@kernel.org>
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Reviewed-by: Johan Hovold <johan+linaro@kernel.org>
Link: https://lore.kernel.org/r/20220830092232.168561-1-manivannan.sadhasivam@linaro.org
[switched two lines as indicated by Johan]
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/pinctrl/qcom/pinctrl-spmi-gpio.c

index ccaf40a..8ba3d50 100644 (file)
@@ -171,7 +171,6 @@ struct pmic_gpio_state {
        struct regmap   *map;
        struct pinctrl_dev *ctrl;
        struct gpio_chip chip;
-       struct irq_chip irq;
        u8 usid;
        u8 pid_base;
 };
@@ -985,6 +984,33 @@ static int pmic_gpio_populate_parent_fwspec(struct gpio_chip *chip,
        return 0;
 }
 
+static void pmic_gpio_irq_mask(struct irq_data *data)
+{
+       struct gpio_chip *gc = irq_data_get_irq_chip_data(data);
+
+       irq_chip_mask_parent(data);
+       gpiochip_disable_irq(gc, data->hwirq);
+}
+
+static void pmic_gpio_irq_unmask(struct irq_data *data)
+{
+       struct gpio_chip *gc = irq_data_get_irq_chip_data(data);
+
+       gpiochip_enable_irq(gc, data->hwirq);
+       irq_chip_unmask_parent(data);
+}
+
+static const struct irq_chip spmi_gpio_irq_chip = {
+       .name           = "spmi-gpio",
+       .irq_ack        = irq_chip_ack_parent,
+       .irq_mask       = pmic_gpio_irq_mask,
+       .irq_unmask     = pmic_gpio_irq_unmask,
+       .irq_set_type   = irq_chip_set_type_parent,
+       .irq_set_wake   = irq_chip_set_wake_parent,
+       .flags          = IRQCHIP_IMMUTABLE | IRQCHIP_MASK_ON_SUSPEND,
+       GPIOCHIP_IRQ_RESOURCE_HELPERS,
+};
+
 static int pmic_gpio_probe(struct platform_device *pdev)
 {
        struct irq_domain *parent_domain;
@@ -1078,16 +1104,8 @@ static int pmic_gpio_probe(struct platform_device *pdev)
        if (!parent_domain)
                return -ENXIO;
 
-       state->irq.name = "spmi-gpio",
-       state->irq.irq_ack = irq_chip_ack_parent,
-       state->irq.irq_mask = irq_chip_mask_parent,
-       state->irq.irq_unmask = irq_chip_unmask_parent,
-       state->irq.irq_set_type = irq_chip_set_type_parent,
-       state->irq.irq_set_wake = irq_chip_set_wake_parent,
-       state->irq.flags = IRQCHIP_MASK_ON_SUSPEND,
-
        girq = &state->chip.irq;
-       girq->chip = &state->irq;
+       gpio_irq_chip_set_chip(girq, &spmi_gpio_irq_chip);
        girq->default_type = IRQ_TYPE_NONE;
        girq->handler = handle_level_irq;
        girq->fwnode = of_node_to_fwnode(state->dev->of_node);