Skip to content

Commit 216f373

Browse files
maquefelBartosz Golaszewski
authored andcommitted
gpio: ep93xx: Make irqchip immutable
This turns the Cirrus ep93xx gpio irqchip immutable. Preserve per-chip labels by adding an ->irq_print_chip() callback. Signed-off-by: Nikita Shubin <[email protected]> Signed-off-by: Bartosz Golaszewski <[email protected]>
1 parent 0f04cdb commit 216f373

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed

drivers/gpio/gpio-ep93xx.c

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <linux/slab.h>
1818
#include <linux/gpio/driver.h>
1919
#include <linux/bitops.h>
20+
#include <linux/seq_file.h>
2021

2122
#define EP93XX_GPIO_F_INT_STATUS 0x5c
2223
#define EP93XX_GPIO_A_INT_STATUS 0xa0
@@ -40,7 +41,6 @@
4041
#define EP93XX_GPIO_F_IRQ_BASE 80
4142

4243
struct ep93xx_gpio_irq_chip {
43-
struct irq_chip ic;
4444
u8 irq_offset;
4545
u8 int_unmasked;
4646
u8 int_enabled;
@@ -185,6 +185,7 @@ static void ep93xx_gpio_irq_mask_ack(struct irq_data *d)
185185
ep93xx_gpio_update_int_params(epg, eic);
186186

187187
writeb(port_mask, epg->base + eic->irq_offset + EP93XX_INT_EOI_OFFSET);
188+
gpiochip_disable_irq(gc, irqd_to_hwirq(d));
188189
}
189190

190191
static void ep93xx_gpio_irq_mask(struct irq_data *d)
@@ -195,6 +196,7 @@ static void ep93xx_gpio_irq_mask(struct irq_data *d)
195196

196197
eic->int_unmasked &= ~BIT(d->irq & 7);
197198
ep93xx_gpio_update_int_params(epg, eic);
199+
gpiochip_disable_irq(gc, irqd_to_hwirq(d));
198200
}
199201

200202
static void ep93xx_gpio_irq_unmask(struct irq_data *d)
@@ -203,6 +205,7 @@ static void ep93xx_gpio_irq_unmask(struct irq_data *d)
203205
struct ep93xx_gpio_irq_chip *eic = to_ep93xx_gpio_irq_chip(gc);
204206
struct ep93xx_gpio *epg = gpiochip_get_data(gc);
205207

208+
gpiochip_enable_irq(gc, irqd_to_hwirq(d));
206209
eic->int_unmasked |= BIT(d->irq & 7);
207210
ep93xx_gpio_update_int_params(epg, eic);
208211
}
@@ -320,15 +323,25 @@ static int ep93xx_gpio_set_config(struct gpio_chip *gc, unsigned offset,
320323
return 0;
321324
}
322325

323-
static void ep93xx_init_irq_chip(struct device *dev, struct irq_chip *ic)
326+
static void ep93xx_irq_print_chip(struct irq_data *data, struct seq_file *p)
324327
{
325-
ic->irq_ack = ep93xx_gpio_irq_ack;
326-
ic->irq_mask_ack = ep93xx_gpio_irq_mask_ack;
327-
ic->irq_mask = ep93xx_gpio_irq_mask;
328-
ic->irq_unmask = ep93xx_gpio_irq_unmask;
329-
ic->irq_set_type = ep93xx_gpio_irq_type;
328+
struct gpio_chip *gc = irq_data_get_irq_chip_data(data);
329+
330+
seq_printf(p, dev_name(gc->parent));
330331
}
331332

333+
static const struct irq_chip gpio_eic_irq_chip = {
334+
.name = "ep93xx-gpio-eic",
335+
.irq_ack = ep93xx_gpio_irq_ack,
336+
.irq_mask = ep93xx_gpio_irq_mask,
337+
.irq_unmask = ep93xx_gpio_irq_unmask,
338+
.irq_mask_ack = ep93xx_gpio_irq_mask_ack,
339+
.irq_set_type = ep93xx_gpio_irq_type,
340+
.irq_print_chip = ep93xx_irq_print_chip,
341+
.flags = IRQCHIP_IMMUTABLE,
342+
GPIOCHIP_IRQ_RESOURCE_HELPERS,
343+
};
344+
332345
static int ep93xx_gpio_add_bank(struct ep93xx_gpio_chip *egc,
333346
struct platform_device *pdev,
334347
struct ep93xx_gpio *epg,
@@ -359,12 +372,7 @@ static int ep93xx_gpio_add_bank(struct ep93xx_gpio_chip *egc,
359372
if (!egc->eic)
360373
return -ENOMEM;
361374
egc->eic->irq_offset = bank->irq;
362-
ic = &egc->eic->ic;
363-
ic->name = devm_kasprintf(dev, GFP_KERNEL, "gpio-irq-%s", bank->label);
364-
if (!ic->name)
365-
return -ENOMEM;
366-
ep93xx_init_irq_chip(dev, ic);
367-
girq->chip = ic;
375+
gpio_irq_chip_set_chip(girq, &gpio_eic_irq_chip);
368376
}
369377

370378
if (bank->has_irq) {

0 commit comments

Comments
 (0)