From: marek.vasut@gmail.com (Marek Vasut)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] pxa270 rtc wakeup event fix
Date: Tue, 12 Apr 2011 12:53:38 +0200 [thread overview]
Message-ID: <201104121253.38937.marek.vasut@gmail.com> (raw)
In-Reply-To: <BANLkTi=dUVins-kj2H6t6vwQKPKG8-PzQw@mail.gmail.com>
On Tuesday 12 April 2011 09:44:17 Eric Miao 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:
>
> 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)
Maybe drop the explicit inline?
Cheers
> +{
> + 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)
> + 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)
next prev parent reply other threads:[~2011-04-12 10:53 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-08 16:42 [PATCH] pxa270 rtc wakeup event fix Nick Bane
2011-04-08 19:36 ` Marek Vasut
2011-04-12 7:44 ` Eric Miao
2011-04-12 8:28 ` Nick Bane
2011-04-12 9:56 ` Igor Grinberg
2011-04-12 10:53 ` Marek Vasut [this message]
2011-04-12 13:47 ` Eric Miao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201104121253.38937.marek.vasut@gmail.com \
--to=marek.vasut@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).