diff mbox

[1/3] gpio: pl061: lock IRQs when starting them

Message ID 1385472227-25956-1-git-send-email-linus.walleij@linaro.org
State Accepted
Commit f6f293112e3d747e5d39ff0d12793909c3946035
Headers show

Commit Message

Linus Walleij Nov. 26, 2013, 1:23 p.m. UTC
This uses the new API for tagging GPIO lines as in use by
IRQs. This enforces a few semantic checks on how the underlying
GPIO line is used.

Cc: Haojian Zhuang <haojian.zhuang@linaro.org>
Cc: Baruch Siach <baruch@tkos.co.il>
Cc: Deepak Sikri <deepak.sikri@st.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/gpio/gpio-pl061.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
diff mbox

Patch

diff --git a/drivers/gpio/gpio-pl061.c b/drivers/gpio/gpio-pl061.c
index f22f7f3e2e53..1c37c97acc76 100644
--- a/drivers/gpio/gpio-pl061.c
+++ b/drivers/gpio/gpio-pl061.c
@@ -231,11 +231,33 @@  static void pl061_irq_unmask(struct irq_data *d)
 	spin_unlock(&chip->lock);
 }
 
+static unsigned int pl061_irq_startup(struct irq_data *d)
+{
+	struct pl061_gpio *chip = irq_data_get_irq_chip_data(d);
+
+	if (gpio_lock_as_irq(&chip->gc, irqd_to_hwirq(d)))
+		dev_err(chip->gc.dev,
+			"unable to lock HW IRQ %lu for IRQ\n",
+			irqd_to_hwirq(d));
+	pl061_irq_unmask(d);
+	return 0;
+}
+
+static void pl061_irq_shutdown(struct irq_data *d)
+{
+	struct pl061_gpio *chip = irq_data_get_irq_chip_data(d);
+
+	pl061_irq_mask(d);
+	gpio_unlock_as_irq(&chip->gc, irqd_to_hwirq(d));
+}
+
 static struct irq_chip pl061_irqchip = {
 	.name		= "pl061 gpio",
 	.irq_mask	= pl061_irq_mask,
 	.irq_unmask	= pl061_irq_unmask,
 	.irq_set_type	= pl061_irq_type,
+	.irq_startup	= pl061_irq_startup,
+	.irq_shutdown	= pl061_irq_shutdown,
 };
 
 static int pl061_irq_map(struct irq_domain *d, unsigned int irq,