[v1,1/2] gpio: gpio-wcove: fix GPIO irq status mask

Submitted by Kuppuswamy Sathyanarayanan on April 14, 2017, 5:29 p.m.

Details

Message ID d2f4d86de7bb816663e1db3a1385ae917aa699ca.1492190203.git.sathyanarayanan.kuppuswamy@linux.intel.com
State New
Headers show

Commit Message

Kuppuswamy Sathyanarayanan April 14, 2017, 5:29 p.m.
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 | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Comments

Andy Shevchenko April 19, 2017, 8:41 p.m.
On Fri, Apr 14, 2017 at 8:29 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

cove -> Cove

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

irq -> IRQ

> status. Otherwise, wcove_gpio_irq_handler() might go into the infinite
> loop until irq "pending" status becomes 0. This patch fixes this issue.

Ditto.

> +#define GPIO_IRQ0_MASK         0x7f
> +#define GPIO_IRQ1_MASK         0x3f

GENMASK()

> -               pending = p[0] | (p[1] << 8);
> +               pending = (p[0] & GPIO_IRQ0_MASK) |
> +                       ((p[1] & GPIO_IRQ1_MASK) << 7);

I would leave this on one line despite 80 characters limit (actually
how long is it?).
Kuppuswamy Sathyanarayanan April 21, 2017, 12:52 a.m.
Hi Andy,

Thanks for the review.


On 04/19/2017 01:41 PM, Andy Shevchenko wrote:
> On Fri, Apr 14, 2017 at 8:29 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
> cove -> Cove
Will fix it in next version.
>
>> battery IO. So we should skip this bit when checking for GPIO irq pending
> irq -> IRQ
Ditto.
>
>> status. Otherwise, wcove_gpio_irq_handler() might go into the infinite
>> loop until irq "pending" status becomes 0. This patch fixes this issue.
> Ditto.
>
>> +#define GPIO_IRQ0_MASK         0x7f
>> +#define GPIO_IRQ1_MASK         0x3f
> GENMASK()
Ditto.
>
>> -               pending = p[0] | (p[1] << 8);
>> +               pending = (p[0] & GPIO_IRQ0_MASK) |
>> +                       ((p[1] & GPIO_IRQ1_MASK) << 7);
> I would leave this on one line despite 80 characters limit (actually
> how long is it?).
It comes to 84 characters. Should I leave it as it is ?
>

Patch hide | download patch | download mbox

diff --git a/drivers/gpio/gpio-wcove.c b/drivers/gpio/gpio-wcove.c
index 97613de..68ef061 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		0x7f
+#define GPIO_IRQ1_MASK		0x3f
 #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,8 @@  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;