Skip to content

Commit 5a7cb9f

Browse files
geertubrgl
authored andcommitted
gpio: sifive: Make the irqchip immutable
Commit 6c846d0 ("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 sifive driver: gpio gpiochip1: (38001000.gpio-controller): not an immutable chip, please consider fixing it! Fix this by making the irqchip in the sifive driver immutable. Signed-off-by: Geert Uytterhoeven <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Reviewed-by: Damien Le Moal <[email protected]> Signed-off-by: Bartosz Golaszewski <[email protected]>
1 parent 718b972 commit 5a7cb9f

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

drivers/gpio/gpio-sifive.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,12 @@ static void sifive_gpio_irq_enable(struct irq_data *d)
7575
{
7676
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
7777
struct sifive_gpio *chip = gpiochip_get_data(gc);
78-
int offset = irqd_to_hwirq(d) % SIFIVE_GPIO_MAX;
78+
irq_hw_number_t hwirq = irqd_to_hwirq(d);
79+
int offset = hwirq % SIFIVE_GPIO_MAX;
7980
u32 bit = BIT(offset);
8081
unsigned long flags;
8182

83+
gpiochip_enable_irq(gc, hwirq);
8284
irq_chip_enable_parent(d);
8385

8486
/* Switch to input */
@@ -101,11 +103,13 @@ static void sifive_gpio_irq_disable(struct irq_data *d)
101103
{
102104
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
103105
struct sifive_gpio *chip = gpiochip_get_data(gc);
104-
int offset = irqd_to_hwirq(d) % SIFIVE_GPIO_MAX;
106+
irq_hw_number_t hwirq = irqd_to_hwirq(d);
107+
int offset = hwirq % SIFIVE_GPIO_MAX;
105108

106109
assign_bit(offset, &chip->irq_state, 0);
107110
sifive_gpio_set_ie(chip, offset);
108111
irq_chip_disable_parent(d);
112+
gpiochip_disable_irq(gc, hwirq);
109113
}
110114

111115
static void sifive_gpio_irq_eoi(struct irq_data *d)
@@ -137,7 +141,7 @@ static int sifive_gpio_irq_set_affinity(struct irq_data *data,
137141
return -EINVAL;
138142
}
139143

140-
static struct irq_chip sifive_gpio_irqchip = {
144+
static const struct irq_chip sifive_gpio_irqchip = {
141145
.name = "sifive-gpio",
142146
.irq_set_type = sifive_gpio_irq_set_type,
143147
.irq_mask = irq_chip_mask_parent,
@@ -146,6 +150,8 @@ static struct irq_chip sifive_gpio_irqchip = {
146150
.irq_disable = sifive_gpio_irq_disable,
147151
.irq_eoi = sifive_gpio_irq_eoi,
148152
.irq_set_affinity = sifive_gpio_irq_set_affinity,
153+
.flags = IRQCHIP_IMMUTABLE,
154+
GPIOCHIP_IRQ_RESOURCE_HELPERS,
149155
};
150156

151157
static int sifive_gpio_child_to_parent_hwirq(struct gpio_chip *gc,
@@ -242,7 +248,7 @@ static int sifive_gpio_probe(struct platform_device *pdev)
242248
chip->gc.parent = dev;
243249
chip->gc.owner = THIS_MODULE;
244250
girq = &chip->gc.irq;
245-
girq->chip = &sifive_gpio_irqchip;
251+
gpio_irq_chip_set_chip(girq, &sifive_gpio_irqchip);
246252
girq->fwnode = of_node_to_fwnode(node);
247253
girq->parent_domain = parent;
248254
girq->child_to_parent_hwirq = sifive_gpio_child_to_parent_hwirq;

0 commit comments

Comments
 (0)