diff mbox series

[RFCv3,4/4] gpio-bcm-kona: use new req/relres and dis/enable_irq funcs

Message ID 20180831143744.126063-5-hverkuil@xs4all.nl
State New
Headers show
Series gpiolib: track irq enabled/disabled state | expand

Commit Message

Hans Verkuil Aug. 31, 2018, 2:37 p.m. UTC
From: Hans Verkuil <hans.verkuil@cisco.com>

Since this driver does not use the gpiolib irqchip helpers it will have to
allocate the irq resources and irq_en/disable itself.

Use the new gpiochip_req/relres_irq helpers to request/release all the
resources.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/gpio/gpio-bcm-kona.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

Comments

Linus Walleij Sept. 5, 2018, 10:33 a.m. UTC | #1
On Fri, Aug 31, 2018 at 4:37 PM Hans Verkuil <hverkuil@xs4all.nl> wrote:

> From: Hans Verkuil <hans.verkuil@cisco.com>
>
> Since this driver does not use the gpiolib irqchip helpers it will have to
> allocate the irq resources and irq_en/disable itself.
>
> Use the new gpiochip_req/relres_irq helpers to request/release all the
> resources.
>
> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>

This is just beautiful and makes everything so much easier.

I have an urge to simply apply the patch set, it will make
Lina's work cleaner and easier too.

Yours,
Linus Walleij
Hans Verkuil (hansverk) Sept. 5, 2018, 12:21 p.m. UTC | #2
On 09/05/18 12:33, Linus Walleij wrote:
> On Fri, Aug 31, 2018 at 4:37 PM Hans Verkuil <hverkuil@xs4all.nl> wrote:
> 
>> From: Hans Verkuil <hans.verkuil@cisco.com>
>>
>> Since this driver does not use the gpiolib irqchip helpers it will have to
>> allocate the irq resources and irq_en/disable itself.
>>
>> Use the new gpiochip_req/relres_irq helpers to request/release all the
>> resources.
>>
>> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
> 
> This is just beautiful and makes everything so much easier.
> 
> I have an urge to simply apply the patch set, it will make
> Lina's work cleaner and easier too.

Well, let me post this as a non-RFC and if you want to merge it,
then who am I to object? :-)

Regards,

	Hans
Lina Iyer Sept. 5, 2018, 2:51 p.m. UTC | #3
On Wed, Sep 05 2018 at 04:33 -0600, Linus Walleij wrote:
>On Fri, Aug 31, 2018 at 4:37 PM Hans Verkuil <hverkuil@xs4all.nl> wrote:
>
>> From: Hans Verkuil <hans.verkuil@cisco.com>
>>
>> Since this driver does not use the gpiolib irqchip helpers it will have to
>> allocate the irq resources and irq_en/disable itself.
>>
>> Use the new gpiochip_req/relres_irq helpers to request/release all the
>> resources.
>>
>> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
>
>This is just beautiful and makes everything so much easier.
>
>I have an urge to simply apply the patch set, it will make
>Lina's work cleaner and easier too.
>
I will rebase my next series on this (or the next version from Hans).

-- Lina
diff mbox series

Patch

diff --git a/drivers/gpio/gpio-bcm-kona.c b/drivers/gpio/gpio-bcm-kona.c
index d0707fc23afd..c5536a509b59 100644
--- a/drivers/gpio/gpio-bcm-kona.c
+++ b/drivers/gpio/gpio-bcm-kona.c
@@ -373,6 +373,7 @@  static void bcm_kona_gpio_irq_mask(struct irq_data *d)
 	val = readl(reg_base + GPIO_INT_MASK(bank_id));
 	val |= BIT(bit);
 	writel(val, reg_base + GPIO_INT_MASK(bank_id));
+	gpiochip_disable_irq(&kona_gpio->gpio_chip, gpio);
 
 	raw_spin_unlock_irqrestore(&kona_gpio->lock, flags);
 }
@@ -394,6 +395,7 @@  static void bcm_kona_gpio_irq_unmask(struct irq_data *d)
 	val = readl(reg_base + GPIO_INT_MSKCLR(bank_id));
 	val |= BIT(bit);
 	writel(val, reg_base + GPIO_INT_MSKCLR(bank_id));
+	gpiochip_enable_irq(&kona_gpio->gpio_chip, gpio);
 
 	raw_spin_unlock_irqrestore(&kona_gpio->lock, flags);
 }
@@ -485,23 +487,15 @@  static void bcm_kona_gpio_irq_handler(struct irq_desc *desc)
 static int bcm_kona_gpio_irq_reqres(struct irq_data *d)
 {
 	struct bcm_kona_gpio *kona_gpio = irq_data_get_irq_chip_data(d);
-	int ret;
 
-	ret = gpiochip_lock_as_irq(&kona_gpio->gpio_chip, d->hwirq);
-	if (ret) {
-		dev_err(kona_gpio->gpio_chip.parent,
-			"unable to lock HW IRQ %lu for IRQ\n",
-			d->hwirq);
-		return ret;
-	}
-	return 0;
+	return gpiochip_reqres_irq(&kona_gpio->gpio_chip, d->hwirq);
 }
 
 static void bcm_kona_gpio_irq_relres(struct irq_data *d)
 {
 	struct bcm_kona_gpio *kona_gpio = irq_data_get_irq_chip_data(d);
 
-	gpiochip_unlock_as_irq(&kona_gpio->gpio_chip, d->hwirq);
+	gpiochip_relres_irq(&kona_gpio->gpio_chip, d->hwirq);
 }
 
 static struct irq_chip bcm_gpio_irq_chip = {