diff mbox

[v2,1/1] gpio: gpio-wcove: fix GPIO IRQ status mask

Message ID 3257d22879148692da6887f89843389bd37ee877.1493060870.git.sathyanarayanan.kuppuswamy@linux.intel.com
State New
Headers show

Commit Message

Kuppuswamy Sathyanarayanan April 24, 2017, 7:15 p.m. UTC
From: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>

According to Whiskey Cove PMIC spec, bit 7 of GPIOIRQ0_REG belongs to
battery IO. So we should skip this bit when checking for GPIO IRQ pending
status. Otherwise, wcove_gpio_irq_handler() might go into the infinite
loop until IRQ "pending" status becomes 0. This patch fixes this issue.

Signed-off-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
---
 drivers/gpio/gpio-wcove.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Changes since v1:
 * Used GENMASK API.
 * Fixed some style issues.
 * Updated commit message.

Comments

Linus Walleij April 26, 2017, 2:26 p.m. UTC | #1
On Mon, Apr 24, 2017 at 9:15 PM,
<sathyanarayanan.kuppuswamy@linux.intel.com> wrote:

> From: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
>
> According to Whiskey Cove PMIC spec, bit 7 of GPIOIRQ0_REG belongs to
> battery IO. So we should skip this bit when checking for GPIO IRQ pending
> status. Otherwise, wcove_gpio_irq_handler() might go into the infinite
> loop until IRQ "pending" status becomes 0. This patch fixes this issue.
>
> Signed-off-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>

Looks fine to me, tentatively applied.

Bin, Mika, Andy, OK?

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Mika Westerberg April 26, 2017, 2:50 p.m. UTC | #2
On Wed, Apr 26, 2017 at 04:26:17PM +0200, Linus Walleij wrote:
> On Mon, Apr 24, 2017 at 9:15 PM,
> <sathyanarayanan.kuppuswamy@linux.intel.com> wrote:
> 
> > From: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
> >
> > According to Whiskey Cove PMIC spec, bit 7 of GPIOIRQ0_REG belongs to
> > battery IO. So we should skip this bit when checking for GPIO IRQ pending
> > status. Otherwise, wcove_gpio_irq_handler() might go into the infinite
> > loop until IRQ "pending" status becomes 0. This patch fixes this issue.
> >
> > Signed-off-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
> 
> Looks fine to me, tentatively applied.
> 
> Bin, Mika, Andy, OK?

Looks fine to me as well :)

Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com>
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Andy Shevchenko April 26, 2017, 2:52 p.m. UTC | #3
On Wed, Apr 26, 2017 at 5:26 PM, Linus Walleij <linus.walleij@linaro.org> wrote:
> On Mon, Apr 24, 2017 at 9:15 PM,
> <sathyanarayanan.kuppuswamy@linux.intel.com> wrote:
>
>> From: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
>>
>> According to Whiskey Cove PMIC spec, bit 7 of GPIOIRQ0_REG belongs to
>> battery IO. So we should skip this bit when checking for GPIO IRQ pending
>> status. Otherwise, wcove_gpio_irq_handler() might go into the infinite
>> loop until IRQ "pending" status becomes 0. This patch fixes this issue.
>>
>> Signed-off-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
>
> Looks fine to me, tentatively applied.
>
> Bin, Mika, Andy, OK?

Yes, thanks!
Gao, Bin April 26, 2017, 4:42 p.m. UTC | #4
On Wed, April 26, 2017 at 7:26 AM, Linus Walleij wrote:
>On Mon, Apr 24, 2017 at 9:15 PM,

><sathyanarayanan.kuppuswamy@linux.intel.com> wrote:

>

>> From: Kuppuswamy Sathyanarayanan 

>> <sathyanarayanan.kuppuswamy@linux.intel.com>

>>

>> According to Whiskey Cove PMIC spec, bit 7 of GPIOIRQ0_REG belongs to 

>> battery IO. So we should skip this bit when checking for GPIO IRQ 

>> pending status. Otherwise, wcove_gpio_irq_handler() might go into the 

>> infinite loop until IRQ "pending" status becomes 0. This patch fixes this issue.

>>

>> Signed-off-by: Kuppuswamy Sathyanarayanan 

>> <sathyanarayanan.kuppuswamy@linux.intel.com>

>

>Looks fine to me, tentatively applied.

>

>Bin, Mika, Andy, OK?

>

>Yours,

>Linus Walleij


Looks reasonable to me.

Thanks,
Bin
diff mbox

Patch

diff --git a/drivers/gpio/gpio-wcove.c b/drivers/gpio/gpio-wcove.c
index 97613de..7872435 100644
--- a/drivers/gpio/gpio-wcove.c
+++ b/drivers/gpio/gpio-wcove.c
@@ -51,6 +51,8 @@ 
 #define GROUP1_NR_IRQS		6
 #define IRQ_MASK_BASE		0x4e19
 #define IRQ_STATUS_BASE		0x4e0b
+#define GPIO_IRQ0_MASK		GENMASK(6, 0)
+#define GPIO_IRQ1_MASK		GENMASK(5, 0)
 #define UPDATE_IRQ_TYPE		BIT(0)
 #define UPDATE_IRQ_MASK		BIT(1)
 
@@ -309,7 +311,7 @@  static irqreturn_t wcove_gpio_irq_handler(int irq, void *data)
 		return IRQ_NONE;
 	}
 
-	pending = p[0] | (p[1] << 8);
+	pending = (p[0] & GPIO_IRQ0_MASK) | ((p[1] & GPIO_IRQ1_MASK) << 7);
 	if (!pending)
 		return IRQ_NONE;
 
@@ -333,7 +335,7 @@  static irqreturn_t wcove_gpio_irq_handler(int irq, void *data)
 			break;
 		}
 
-		pending = p[0] | (p[1] << 8);
+		pending = (p[0] & GPIO_IRQ0_MASK) | ((p[1] & GPIO_IRQ1_MASK) << 7);
 	}
 
 	return IRQ_HANDLED;