Skip to content

Commit 8e43827

Browse files
Linus WalleijBartosz Golaszewski
authored andcommitted
gpio: tqmx86: Convert to immutable irq_chip
Convert the driver to immutable irq-chip with a bit of intuition. Cc: Marc Zyngier <maz@kernel.org> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Reviewed-by: Marc Zyngier <maz@kernel.org> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
1 parent ef902f5 commit 8e43827

1 file changed

Lines changed: 20 additions & 8 deletions

File tree

drivers/gpio/gpio-tqmx86.c

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <linux/module.h>
1616
#include <linux/platform_device.h>
1717
#include <linux/pm_runtime.h>
18+
#include <linux/seq_file.h>
1819
#include <linux/slab.h>
1920

2021
#define TQMX86_NGPIO 8
@@ -34,7 +35,6 @@
3435

3536
struct tqmx86_gpio_data {
3637
struct gpio_chip chip;
37-
struct irq_chip irq_chip;
3838
void __iomem *io_base;
3939
int irq;
4040
raw_spinlock_t spinlock;
@@ -122,6 +122,7 @@ static void tqmx86_gpio_irq_mask(struct irq_data *data)
122122
gpiic &= ~mask;
123123
tqmx86_gpio_write(gpio, gpiic, TQMX86_GPIIC);
124124
raw_spin_unlock_irqrestore(&gpio->spinlock, flags);
125+
gpiochip_disable_irq(&gpio->chip, irqd_to_hwirq(data));
125126
}
126127

127128
static void tqmx86_gpio_irq_unmask(struct irq_data *data)
@@ -134,6 +135,7 @@ static void tqmx86_gpio_irq_unmask(struct irq_data *data)
134135

135136
mask = TQMX86_GPII_MASK << (offset * TQMX86_GPII_BITS);
136137

138+
gpiochip_enable_irq(&gpio->chip, irqd_to_hwirq(data));
137139
raw_spin_lock_irqsave(&gpio->spinlock, flags);
138140
gpiic = tqmx86_gpio_read(gpio, TQMX86_GPIIC);
139141
gpiic &= ~mask;
@@ -226,6 +228,22 @@ static void tqmx86_init_irq_valid_mask(struct gpio_chip *chip,
226228
clear_bit(3, valid_mask);
227229
}
228230

231+
static void tqmx86_gpio_irq_print_chip(struct irq_data *d, struct seq_file *p)
232+
{
233+
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
234+
235+
seq_printf(p, gc->label);
236+
}
237+
238+
static const struct irq_chip tqmx86_gpio_irq_chip = {
239+
.irq_mask = tqmx86_gpio_irq_mask,
240+
.irq_unmask = tqmx86_gpio_irq_unmask,
241+
.irq_set_type = tqmx86_gpio_irq_set_type,
242+
.irq_print_chip = tqmx86_gpio_irq_print_chip,
243+
.flags = IRQCHIP_IMMUTABLE,
244+
GPIOCHIP_IRQ_RESOURCE_HELPERS,
245+
};
246+
229247
static int tqmx86_gpio_probe(struct platform_device *pdev)
230248
{
231249
struct device *dev = &pdev->dev;
@@ -277,14 +295,8 @@ static int tqmx86_gpio_probe(struct platform_device *pdev)
277295
pm_runtime_enable(&pdev->dev);
278296

279297
if (irq > 0) {
280-
struct irq_chip *irq_chip = &gpio->irq_chip;
281298
u8 irq_status;
282299

283-
irq_chip->name = chip->label;
284-
irq_chip->irq_mask = tqmx86_gpio_irq_mask;
285-
irq_chip->irq_unmask = tqmx86_gpio_irq_unmask;
286-
irq_chip->irq_set_type = tqmx86_gpio_irq_set_type;
287-
288300
/* Mask all interrupts */
289301
tqmx86_gpio_write(gpio, 0, TQMX86_GPIIC);
290302

@@ -293,7 +305,7 @@ static int tqmx86_gpio_probe(struct platform_device *pdev)
293305
tqmx86_gpio_write(gpio, irq_status, TQMX86_GPIIS);
294306

295307
girq = &chip->irq;
296-
girq->chip = irq_chip;
308+
gpio_irq_chip_set_chip(girq, &tqmx86_gpio_irq_chip);
297309
girq->parent_handler = tqmx86_gpio_irq_handler;
298310
girq->num_parents = 1;
299311
girq->parents = devm_kcalloc(&pdev->dev, 1,

0 commit comments

Comments
 (0)