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

gpio: mlxbf2: 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
5bfff76d db45f0e1

+25 -7
+25 -7
drivers/gpio/gpio-mlxbf2.c
··· 17 17 #include <linux/platform_device.h> 18 18 #include <linux/pm.h> 19 19 #include <linux/resource.h> 20 + #include <linux/seq_file.h> 20 21 #include <linux/spinlock.h> 21 22 #include <linux/types.h> 22 23 ··· 66 65 /* BlueField-2 gpio block context structure. */ 67 66 struct mlxbf2_gpio_context { 68 67 struct gpio_chip gc; 69 - struct irq_chip irq_chip; 70 68 71 69 /* YU GPIO blocks address */ 72 70 void __iomem *gpio_io; 71 + struct device *dev; 73 72 74 73 struct mlxbf2_gpio_context_save_regs *csave_regs; 75 74 }; ··· 238 237 unsigned long flags; 239 238 u32 val; 240 239 240 + gpiochip_enable_irq(gc, irqd_to_hwirq(irqd)); 241 241 raw_spin_lock_irqsave(&gs->gc.bgpio_lock, flags); 242 242 val = readl(gs->gpio_io + YU_GPIO_CAUSE_OR_CLRCAUSE); 243 243 val |= BIT(offset); ··· 263 261 val &= ~BIT(offset); 264 262 writel(val, gs->gpio_io + YU_GPIO_CAUSE_OR_EVTEN0); 265 263 raw_spin_unlock_irqrestore(&gs->gc.bgpio_lock, flags); 264 + gpiochip_disable_irq(gc, irqd_to_hwirq(irqd)); 266 265 } 267 266 268 267 static irqreturn_t mlxbf2_gpio_irq_handler(int irq, void *ptr) ··· 325 322 return 0; 326 323 } 327 324 325 + static void mlxbf2_gpio_irq_print_chip(struct irq_data *irqd, 326 + struct seq_file *p) 327 + { 328 + struct gpio_chip *gc = irq_data_get_irq_chip_data(irqd); 329 + struct mlxbf2_gpio_context *gs = gpiochip_get_data(gc); 330 + 331 + seq_printf(p, dev_name(gs->dev)); 332 + } 333 + 334 + static const struct irq_chip mlxbf2_gpio_irq_chip = { 335 + .irq_set_type = mlxbf2_gpio_irq_set_type, 336 + .irq_enable = mlxbf2_gpio_irq_enable, 337 + .irq_disable = mlxbf2_gpio_irq_disable, 338 + .irq_print_chip = mlxbf2_gpio_irq_print_chip, 339 + .flags = IRQCHIP_IMMUTABLE, 340 + GPIOCHIP_IRQ_RESOURCE_HELPERS, 341 + }; 342 + 328 343 /* BlueField-2 GPIO driver initialization routine. */ 329 344 static int 330 345 mlxbf2_gpio_probe(struct platform_device *pdev) ··· 360 339 gs = devm_kzalloc(dev, sizeof(*gs), GFP_KERNEL); 361 340 if (!gs) 362 341 return -ENOMEM; 342 + 343 + gs->dev = dev; 363 344 364 345 /* YU GPIO block address */ 365 346 gs->gpio_io = devm_platform_ioremap_resource(pdev, 0); ··· 399 376 400 377 irq = platform_get_irq(pdev, 0); 401 378 if (irq >= 0) { 402 - gs->irq_chip.name = name; 403 - gs->irq_chip.irq_set_type = mlxbf2_gpio_irq_set_type; 404 - gs->irq_chip.irq_enable = mlxbf2_gpio_irq_enable; 405 - gs->irq_chip.irq_disable = mlxbf2_gpio_irq_disable; 406 - 407 379 girq = &gs->gc.irq; 408 - girq->chip = &gs->irq_chip; 380 + gpio_irq_chip_set_chip(girq, &mlxbf2_gpio_irq_chip); 409 381 girq->handler = handle_simple_irq; 410 382 girq->default_type = IRQ_TYPE_NONE; 411 383 /* This will let us handle the parent IRQ in the driver */