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

gpio: aspeed-sgpio: 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
c5dcf768 061df08f

+36 -8
+36 -8
drivers/gpio/gpio-aspeed-sgpio.c
··· 14 14 #include <linux/kernel.h> 15 15 #include <linux/module.h> 16 16 #include <linux/platform_device.h> 17 + #include <linux/seq_file.h> 17 18 #include <linux/spinlock.h> 18 19 #include <linux/string.h> 19 20 ··· 30 29 31 30 struct aspeed_sgpio { 32 31 struct gpio_chip chip; 33 - struct irq_chip intc; 32 + struct device *dev; 34 33 struct clk *pclk; 35 34 raw_spinlock_t lock; 36 35 void __iomem *base; ··· 297 296 irqd_to_aspeed_sgpio_data(d, &gpio, &bank, &bit, &offset); 298 297 addr = bank_reg(gpio, bank, reg_irq_enable); 299 298 299 + /* Unmasking the IRQ */ 300 + if (set) 301 + gpiochip_enable_irq(&gpio->chip, irqd_to_hwirq(d)); 302 + 300 303 raw_spin_lock_irqsave(&gpio->lock, flags); 301 304 302 305 reg = ioread32(addr); ··· 312 307 iowrite32(reg, addr); 313 308 314 309 raw_spin_unlock_irqrestore(&gpio->lock, flags); 310 + 311 + /* Masking the IRQ */ 312 + if (!set) 313 + gpiochip_disable_irq(&gpio->chip, irqd_to_hwirq(d)); 314 + 315 + 315 316 } 316 317 317 318 static void aspeed_sgpio_irq_mask(struct irq_data *d) ··· 412 401 chained_irq_exit(ic, desc); 413 402 } 414 403 404 + static void aspeed_sgpio_irq_print_chip(struct irq_data *d, struct seq_file *p) 405 + { 406 + const struct aspeed_sgpio_bank *bank; 407 + struct aspeed_sgpio *gpio; 408 + u32 bit; 409 + int offset; 410 + 411 + irqd_to_aspeed_sgpio_data(d, &gpio, &bank, &bit, &offset); 412 + seq_printf(p, dev_name(gpio->dev)); 413 + } 414 + 415 + static const struct irq_chip aspeed_sgpio_irq_chip = { 416 + .irq_ack = aspeed_sgpio_irq_ack, 417 + .irq_mask = aspeed_sgpio_irq_mask, 418 + .irq_unmask = aspeed_sgpio_irq_unmask, 419 + .irq_set_type = aspeed_sgpio_set_type, 420 + .irq_print_chip = aspeed_sgpio_irq_print_chip, 421 + .flags = IRQCHIP_IMMUTABLE, 422 + GPIOCHIP_IRQ_RESOURCE_HELPERS, 423 + }; 424 + 415 425 static int aspeed_sgpio_setup_irqs(struct aspeed_sgpio *gpio, 416 426 struct platform_device *pdev) 417 427 { ··· 455 423 iowrite32(0xffffffff, bank_reg(gpio, bank, reg_irq_status)); 456 424 } 457 425 458 - gpio->intc.name = dev_name(&pdev->dev); 459 - gpio->intc.irq_ack = aspeed_sgpio_irq_ack; 460 - gpio->intc.irq_mask = aspeed_sgpio_irq_mask; 461 - gpio->intc.irq_unmask = aspeed_sgpio_irq_unmask; 462 - gpio->intc.irq_set_type = aspeed_sgpio_set_type; 463 - 464 426 irq = &gpio->chip.irq; 465 - irq->chip = &gpio->intc; 427 + gpio_irq_chip_set_chip(irq, &aspeed_sgpio_irq_chip); 466 428 irq->init_valid_mask = aspeed_sgpio_irq_init_valid_mask; 467 429 irq->handler = handle_bad_irq; 468 430 irq->default_type = IRQ_TYPE_NONE; ··· 549 523 gpio->base = devm_platform_ioremap_resource(pdev, 0); 550 524 if (IS_ERR(gpio->base)) 551 525 return PTR_ERR(gpio->base); 526 + 527 + gpio->dev = &pdev->dev; 552 528 553 529 pdata = device_get_match_data(&pdev->dev); 554 530 if (!pdata)