From mboxrd@z Thu Jan 1 00:00:00 1970 From: grinberg@compulab.co.il (Igor Grinberg) Date: Tue, 12 Apr 2011 12:56:29 +0300 Subject: [PATCH] pxa270 rtc wakeup event fix In-Reply-To: <4DA40D2D.40807@googlemail.com> References: <4D9F3AE4.2040101@gmail.com> <201104082136.52297.marek.vasut@gmail.com> <4DA40D2D.40807@googlemail.com> Message-ID: <4DA421CD.8090103@compulab.co.il> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org Hi Nick, On 04/12/11 11:28, Nick Bane wrote: > >> Hi Nick, >> >> Thanks for spotting this. The problem is really IRQ_TO_GPIO() macro >> doesn't behave as assumed. A better approach would be to return -1 >> when none-GPIO IRQs are mapped back, let me know if you are OK w/ >> the patch below: >> > Hi Eric > That looks like the right answer. > Nick >> diff --git a/arch/arm/mach-pxa/include/mach/gpio.h >> b/arch/arm/mach-pxa/include/mach/gpio.h >> index b024a8b..b9f4ed1 100644 >> --- a/arch/arm/mach-pxa/include/mach/gpio.h >> +++ b/arch/arm/mach-pxa/include/mach/gpio.h >> @@ -103,7 +103,20 @@ >> >> #define gpio_to_bank(gpio) ((gpio)>> 5) >> #define gpio_to_irq(gpio) IRQ_GPIO(gpio) >> -#define irq_to_gpio(irq) IRQ_TO_GPIO(irq) >> + >> +static inline int irq_to_gpio(unsigned int irq) >> +{ >> + int gpio; >> + >> + if (irq == IRQ_GPIO0 || irq == IRQ_GPIO1) >> + return irq - IRQ_GPIO0; >> + >> + gpio = irq - PXA_GPIO_IRQ_BASE; >> + if (gpio>= 2&& gpio< NR_BUILTIN_GPIO) This is a really nice white space game, your mailer plays ;) Really funny... >> + return gpio; >> + >> + return -1; >> +} >> >> #ifdef CONFIG_CPU_PXA26x >> /* GPIO86/87/88/89 on PXA26x have their direction bits in GPDR2 inverted, >> diff --git a/arch/arm/mach-pxa/include/mach/irqs.h >> b/arch/arm/mach-pxa/include/mach/irqs.h >> index a4285fc..0384024 100644 >> --- a/arch/arm/mach-pxa/include/mach/irqs.h >> +++ b/arch/arm/mach-pxa/include/mach/irqs.h >> @@ -93,9 +93,6 @@ >> #define GPIO_2_x_TO_IRQ(x) (PXA_GPIO_IRQ_BASE + (x)) >> #define IRQ_GPIO(x) (((x)< 2) ? (IRQ_GPIO0 + (x)) : GPIO_2_x_TO_IRQ(x)) >> >> -#define IRQ_TO_GPIO_2_x(i) ((i) - PXA_GPIO_IRQ_BASE) >> -#define IRQ_TO_GPIO(i) (((i)< IRQ_GPIO(2)) ? ((i) - IRQ_GPIO0) : >> IRQ_TO_GPIO_2_x(i)) >> - >> /* >> * The following interrupts are for board specific purposes. Since >> * the kernel can only run on one machine at a time, we can re-use >> diff --git a/arch/arm/mach-pxa/pxa25x.c b/arch/arm/mach-pxa/pxa25x.c >> index 6bde595..a4af8c5 100644 >> --- a/arch/arm/mach-pxa/pxa25x.c >> +++ b/arch/arm/mach-pxa/pxa25x.c >> @@ -285,7 +285,7 @@ static inline void pxa25x_init_pm(void) {} >> >> static int pxa25x_set_wake(struct irq_data *d, unsigned int on) >> { >> - int gpio = IRQ_TO_GPIO(d->irq); >> + int gpio = irq_to_gpio(d->irq); >> uint32_t mask = 0; >> >> if (gpio>= 0&& gpio< 85) >> diff --git a/arch/arm/mach-pxa/pxa27x.c b/arch/arm/mach-pxa/pxa27x.c >> index 1cb5d0f..909756e 100644 >> --- a/arch/arm/mach-pxa/pxa27x.c >> +++ b/arch/arm/mach-pxa/pxa27x.c >> @@ -345,7 +345,7 @@ static inline void pxa27x_init_pm(void) {} >> */ >> static int pxa27x_set_wake(struct irq_data *d, unsigned int on) >> { >> - int gpio = IRQ_TO_GPIO(d->irq); >> + int gpio = irq_to_gpio(d->irq); >> uint32_t mask; >> >> if (gpio>= 0&& gpio< 128) > > > _______________________________________________ > linux-arm-kernel mailing list > linux-arm-kernel at lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel > -- Regards, Igor.