Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

gpio: hlwd: Convert to immutable irq_chip

Convert the driver to immutable irq-chip with a bit of
intuition.

Cc: Marc Zyngier <maz@kernel.org>
Acked-by: Marc Zyngier <maz@kernel.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

authored by

Linus Walleij and committed by
Bartosz Golaszewski
ab42f021 39bdd6bd

+25 -8
+25 -8
drivers/gpio/gpio-hlwd.c
··· 11 11 #include <linux/module.h> 12 12 #include <linux/of.h> 13 13 #include <linux/of_platform.h> 14 + #include <linux/seq_file.h> 14 15 #include <linux/slab.h> 15 16 16 17 /* ··· 49 48 50 49 struct hlwd_gpio { 51 50 struct gpio_chip gpioc; 52 - struct irq_chip irqc; 51 + struct device *dev; 53 52 void __iomem *regs; 54 53 int irq; 55 54 u32 edge_emulation; ··· 124 123 mask &= ~BIT(data->hwirq); 125 124 iowrite32be(mask, hlwd->regs + HW_GPIOB_INTMASK); 126 125 raw_spin_unlock_irqrestore(&hlwd->gpioc.bgpio_lock, flags); 126 + gpiochip_disable_irq(&hlwd->gpioc, irqd_to_hwirq(data)); 127 127 } 128 128 129 129 static void hlwd_gpio_irq_unmask(struct irq_data *data) ··· 134 132 unsigned long flags; 135 133 u32 mask; 136 134 135 + gpiochip_enable_irq(&hlwd->gpioc, irqd_to_hwirq(data)); 137 136 raw_spin_lock_irqsave(&hlwd->gpioc.bgpio_lock, flags); 138 137 mask = ioread32be(hlwd->regs + HW_GPIOB_INTMASK); 139 138 mask |= BIT(data->hwirq); ··· 205 202 return 0; 206 203 } 207 204 205 + static void hlwd_gpio_irq_print_chip(struct irq_data *data, struct seq_file *p) 206 + { 207 + struct hlwd_gpio *hlwd = 208 + gpiochip_get_data(irq_data_get_irq_chip_data(data)); 209 + 210 + seq_printf(p, dev_name(hlwd->dev)); 211 + } 212 + 213 + static const struct irq_chip hlwd_gpio_irq_chip = { 214 + .irq_mask = hlwd_gpio_irq_mask, 215 + .irq_unmask = hlwd_gpio_irq_unmask, 216 + .irq_enable = hlwd_gpio_irq_enable, 217 + .irq_set_type = hlwd_gpio_irq_set_type, 218 + .irq_print_chip = hlwd_gpio_irq_print_chip, 219 + .flags = IRQCHIP_IMMUTABLE, 220 + GPIOCHIP_IRQ_RESOURCE_HELPERS, 221 + }; 222 + 208 223 static int hlwd_gpio_probe(struct platform_device *pdev) 209 224 { 210 225 struct hlwd_gpio *hlwd; ··· 236 215 hlwd->regs = devm_platform_ioremap_resource(pdev, 0); 237 216 if (IS_ERR(hlwd->regs)) 238 217 return PTR_ERR(hlwd->regs); 218 + 219 + hlwd->dev = &pdev->dev; 239 220 240 221 /* 241 222 * Claim all GPIOs using the OWNER register. This will not work on ··· 282 259 return hlwd->irq; 283 260 } 284 261 285 - hlwd->irqc.name = dev_name(&pdev->dev); 286 - hlwd->irqc.irq_mask = hlwd_gpio_irq_mask; 287 - hlwd->irqc.irq_unmask = hlwd_gpio_irq_unmask; 288 - hlwd->irqc.irq_enable = hlwd_gpio_irq_enable; 289 - hlwd->irqc.irq_set_type = hlwd_gpio_irq_set_type; 290 - 291 262 girq = &hlwd->gpioc.irq; 292 - girq->chip = &hlwd->irqc; 263 + gpio_irq_chip_set_chip(girq, &hlwd_gpio_irq_chip); 293 264 girq->parent_handler = hlwd_gpio_irqhandler; 294 265 girq->num_parents = 1; 295 266 girq->parents = devm_kcalloc(&pdev->dev, 1,