Commit b11ce7e4 authored by Linus Walleij's avatar Linus Walleij Committed by Bartosz Golaszewski
Browse files

gpio: ath79: 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: default avatarMarc Zyngier <maz@kernel.org>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Signed-off-by: default avatarBartosz Golaszewski <bartosz.golaszewski@linaro.org>
parent c5dcf768
Loading
Loading
Loading
Loading
+6 −2
Original line number Original line Diff line number Diff line
@@ -71,6 +71,7 @@ static void ath79_gpio_irq_unmask(struct irq_data *data)
	u32 mask = BIT(irqd_to_hwirq(data));
	u32 mask = BIT(irqd_to_hwirq(data));
	unsigned long flags;
	unsigned long flags;


	gpiochip_enable_irq(&ctrl->gc, irqd_to_hwirq(data));
	raw_spin_lock_irqsave(&ctrl->lock, flags);
	raw_spin_lock_irqsave(&ctrl->lock, flags);
	ath79_gpio_update_bits(ctrl, AR71XX_GPIO_REG_INT_MASK, mask, mask);
	ath79_gpio_update_bits(ctrl, AR71XX_GPIO_REG_INT_MASK, mask, mask);
	raw_spin_unlock_irqrestore(&ctrl->lock, flags);
	raw_spin_unlock_irqrestore(&ctrl->lock, flags);
@@ -85,6 +86,7 @@ static void ath79_gpio_irq_mask(struct irq_data *data)
	raw_spin_lock_irqsave(&ctrl->lock, flags);
	raw_spin_lock_irqsave(&ctrl->lock, flags);
	ath79_gpio_update_bits(ctrl, AR71XX_GPIO_REG_INT_MASK, mask, 0);
	ath79_gpio_update_bits(ctrl, AR71XX_GPIO_REG_INT_MASK, mask, 0);
	raw_spin_unlock_irqrestore(&ctrl->lock, flags);
	raw_spin_unlock_irqrestore(&ctrl->lock, flags);
	gpiochip_disable_irq(&ctrl->gc, irqd_to_hwirq(data));
}
}


static void ath79_gpio_irq_enable(struct irq_data *data)
static void ath79_gpio_irq_enable(struct irq_data *data)
@@ -169,13 +171,15 @@ static int ath79_gpio_irq_set_type(struct irq_data *data,
	return 0;
	return 0;
}
}


static struct irq_chip ath79_gpio_irqchip = {
static const struct irq_chip ath79_gpio_irqchip = {
	.name = "gpio-ath79",
	.name = "gpio-ath79",
	.irq_enable = ath79_gpio_irq_enable,
	.irq_enable = ath79_gpio_irq_enable,
	.irq_disable = ath79_gpio_irq_disable,
	.irq_disable = ath79_gpio_irq_disable,
	.irq_mask = ath79_gpio_irq_mask,
	.irq_mask = ath79_gpio_irq_mask,
	.irq_unmask = ath79_gpio_irq_unmask,
	.irq_unmask = ath79_gpio_irq_unmask,
	.irq_set_type = ath79_gpio_irq_set_type,
	.irq_set_type = ath79_gpio_irq_set_type,
	.flags = IRQCHIP_IMMUTABLE,
	GPIOCHIP_IRQ_RESOURCE_HELPERS,
};
};


static void ath79_gpio_irq_handler(struct irq_desc *desc)
static void ath79_gpio_irq_handler(struct irq_desc *desc)
@@ -274,7 +278,7 @@ static int ath79_gpio_probe(struct platform_device *pdev)
	/* Optional interrupt setup */
	/* Optional interrupt setup */
	if (!np || of_property_read_bool(np, "interrupt-controller")) {
	if (!np || of_property_read_bool(np, "interrupt-controller")) {
		girq = &ctrl->gc.irq;
		girq = &ctrl->gc.irq;
		girq->chip = &ath79_gpio_irqchip;
		gpio_irq_chip_set_chip(girq, &ath79_gpio_irqchip);
		girq->parent_handler = ath79_gpio_irq_handler;
		girq->parent_handler = ath79_gpio_irq_handler;
		girq->num_parents = 1;
		girq->num_parents = 1;
		girq->parents = devm_kcalloc(dev, 1, sizeof(*girq->parents),
		girq->parents = devm_kcalloc(dev, 1, sizeof(*girq->parents),