Skip to contentSkip to conversation

at91: gpio: use gpiolib API to mark a GPIO used as an IRQ

PATCH Superseded Jean-Jacques Hiblot 2 participants 4 messages Jan 22, 2014

Subsystems (5)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 at91: gpio: use gpiolib API to mark a GPIO used as an IRQ

When an IRQ is started on a GPIO line, mark this GPIO as IRQ in the gpiolib so we can keep track of the usage centrally.

---
 arch/arm/mach-at91/gpio.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
arch/arm/mach-at91/gpio.c +24 -0
index a5afcf7..6176b4b 100644
@@ -577,8 +577,32 @@ static int alt_gpio_irq_type(struct irq_data *d, unsigned type)
 	return 0;
 }
 
+static unsigned int gpio_irq_startup(struct irq_data *d)
+{
+	struct at91_gpio_chip *at91_gpio = irq_data_get_irq_chip_data(d);
+	unsigned	pin = d->hwirq;
+	int ret;
+
+	ret = gpio_lock_as_irq(&at91_gpio->chip, pin);
+	if (ret) {
+		dev_err(at91_gpio->chip.dev, "unable to lock pind %lu IRQ\n",
+			d->hwirq);
+		return ret;
+	}
+	return 0;
+}
+static void gpio_irq_shutdown(struct irq_data *d)
+{
+	struct at91_gpio_chip *at91_gpio = irq_data_get_irq_chip_data(d);
+	unsigned	pin = d->hwirq;
+
+	gpio_unlock_as_irq(&at91_gpio->chip, pin);
+}
+
 static struct irq_chip gpio_irqchip = {
 	.name		= "GPIO",
+	.irq_shutdown	= gpio_irq_shutdown,
+	.irq_startup	= gpio_irq_startup,
 	.irq_disable	= gpio_irq_mask,
 	.irq_mask	= gpio_irq_mask,
 	.irq_unmask	= gpio_irq_unmask,
Signature · 1 line
1.8.5.2
#1 lore raw

PATCH 2/2 at91: pinctrl: use gpiolib API to mark a GPIO used as an IRQ

When an IRQ is started on a GPIO line, mark this GPIO as IRQ in the gpiolib so we can keep track of the usage centrally.

---
 drivers/pinctrl/pinctrl-at91.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
drivers/pinctrl/pinctrl-at91.c +24 -0
index e8c8301..fbedde2 100644
@@ -1299,6 +1299,28 @@ static int alt_gpio_irq_type(struct irq_data *d, unsigned type)
 	return 0;
 }
 
+static unsigned int gpio_irq_startup(struct irq_data *d)
+{
+	struct at91_gpio_chip *at91_gpio = irq_data_get_irq_chip_data(d);
+	unsigned	pin = d->hwirq;
+	int ret;
+
+	ret = gpio_lock_as_irq(&at91_gpio->chip, pin);
+	if (ret) {
+		dev_err(at91_gpio->chip.dev, "unable to lock pind %lu IRQ\n",
+			d->hwirq);
+		return ret;
+	}
+	return 0;
+}
+static void gpio_irq_shutdown(struct irq_data *d)
+{
+	struct at91_gpio_chip *at91_gpio = irq_data_get_irq_chip_data(d);
+	unsigned	pin = d->hwirq;
+
+	gpio_unlock_as_irq(&at91_gpio->chip, pin);
+}
+
 #ifdef CONFIG_PM
 
 static u32 wakeups[MAX_GPIO_BANKS];
@@ -1377,6 +1399,8 @@ void at91_pinctrl_gpio_resume(void)
 
 static struct irq_chip gpio_irqchip = {
 	.name		= "GPIO",
+	.irq_startup	= gpio_irq_startup,
+	.irq_shutdown	= gpio_irq_shutdown,
 	.irq_disable	= gpio_irq_mask,
 	.irq_mask	= gpio_irq_mask,
 	.irq_unmask	= gpio_irq_unmask,
Signature · 1 line
1.8.5.2
#2 lore raw

PATCH 2/2 at91: pinctrl: use gpiolib API to mark a GPIO used as an IRQ

Hi Jean-Jacques,

Quoted 20 lines · Jean-Jacques Hiblot

When an IRQ is started on a GPIO line, mark this GPIO as IRQ in the gpiolib so we can keep track of the usage centrally.

---
 drivers/pinctrl/pinctrl-at91.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
drivers/pinctrl/pinctrl-at91.c +4 -0
index e8c8301..fbedde2 100644
@@ -1299,6 +1299,28 @@ static int alt_gpio_irq_type(struct irq_data *d, unsigned type)
 	return 0;
 }
 
+static unsigned int gpio_irq_startup(struct irq_data *d)
+{
+	struct at91_gpio_chip *at91_gpio = irq_data_get_irq_chip_data(d);
+	unsigned	pin = d->hwirq;

drivers/pinctrl/pinctrl-at91.c static int alt_gpio_irq_type(struct irq_data *d, unsigned type) · line 1315

Quoted 10 lines
drivers/pinctrl/pinctrl-at91.c +10 -0
+	int ret;
+
+	ret = gpio_lock_as_irq(&at91_gpio->chip, pin);
+	if (ret) {
+		dev_err(at91_gpio->chip.dev, "unable to lock pind %lu IRQ\n",
+			d->hwirq);
+		return ret;
+	}
+	return 0;
+}

As for the 1st patch, a blank line between the 2 functions should be nice

Thanks,

Gregory

Quoted 21 lines
drivers/pinctrl/pinctrl-at91.c +10 -0
+static void gpio_irq_shutdown(struct irq_data *d)
+{
+	struct at91_gpio_chip *at91_gpio = irq_data_get_irq_chip_data(d);
+	unsigned	pin = d->hwirq;
+
+	gpio_unlock_as_irq(&at91_gpio->chip, pin);
+}
+
 #ifdef CONFIG_PM
 
 static u32 wakeups[MAX_GPIO_BANKS];
@@ -1377,6 +1399,8 @@ void at91_pinctrl_gpio_resume(void)
 
 static struct irq_chip gpio_irqchip = {
 	.name		= "GPIO",
+	.irq_startup	= gpio_irq_startup,
+	.irq_shutdown	= gpio_irq_shutdown,
 	.irq_disable	= gpio_irq_mask,
 	.irq_mask	= gpio_irq_mask,
 	.irq_unmask	= gpio_irq_unmask,
Signature · 4 lines
Gregory Clement, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
#3 lore raw

PATCH 1/2 at91: gpio: use gpiolib API to mark a GPIO used as an IRQ

In reply to Jean-Jacques Hiblot

Hi Jean-Jacques,

Quoted 20 lines · Jean-Jacques Hiblot

When an IRQ is started on a GPIO line, mark this GPIO as IRQ in the gpiolib so we can keep track of the usage centrally.

---
 arch/arm/mach-at91/gpio.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
arch/arm/mach-at91/gpio.c +4 -0
index a5afcf7..6176b4b 100644
@@ -577,8 +577,32 @@ static int alt_gpio_irq_type(struct irq_data *d, unsigned type)
 	return 0;
 }
 
+static unsigned int gpio_irq_startup(struct irq_data *d)
+{
+	struct at91_gpio_chip *at91_gpio = irq_data_get_irq_chip_data(d);
+	unsigned	pin = d->hwirq;

arch/arm/mach-at91/gpio.c static int alt_gpio_irq_type(struct irq_data *d, unsigned type) · line 593

Quoted 10 lines
arch/arm/mach-at91/gpio.c +10 -0
+	int ret;
+
+	ret = gpio_lock_as_irq(&at91_gpio->chip, pin);
+	if (ret) {
+		dev_err(at91_gpio->chip.dev, "unable to lock pind %lu IRQ\n",
+			d->hwirq);
+		return ret;
+	}
+	return 0;
+}

Nitpick: a blank line should be nice here between the 2 functions

Quoted 6 lines
arch/arm/mach-at91/gpio.c +5 -0
+static void gpio_irq_shutdown(struct irq_data *d)
+{
+	struct at91_gpio_chip *at91_gpio = irq_data_get_irq_chip_data(d);
+	unsigned	pin = d->hwirq;
+

arch/arm/mach-at91/gpio.c static int alt_gpio_irq_type(struct irq_data *d, unsigned type) · line 608

Quoted 10 lines
arch/arm/mach-at91/gpio.c +5 -0
+	gpio_unlock_as_irq(&at91_gpio->chip, pin);
+}
+
 static struct irq_chip gpio_irqchip = {
 	.name		= "GPIO",
+	.irq_shutdown	= gpio_irq_shutdown,
+	.irq_startup	= gpio_irq_startup,
 	.irq_disable	= gpio_irq_mask,
 	.irq_mask	= gpio_irq_mask,
 	.irq_unmask	= gpio_irq_unmask,

Thanks,

Gregory

Signature · 4 lines
Gregory Clement, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com