linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] gpio: pxa: simplify BANK_OFF macro offset calculation
@ 2015-03-02 21:30 Rob Herring
  2015-03-03  7:50 ` Alexandre Courbot
  2015-03-09 13:42 ` Linus Walleij
  0 siblings, 2 replies; 3+ messages in thread
From: Rob Herring @ 2015-03-02 21:30 UTC (permalink / raw)
  To: Linus Walleij; +Cc: Rob Herring, Alexandre Courbot, linux-gpio

The macro BANK_OFF which calculates the base offset for each GPIO port.
The macro is needlessly complex and unreadable. Simplify the
calculation to a simple math operation.

Signed-off-by: Rob Herring <robh@kernel.org>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Alexandre Courbot <gnurou@gmail.com>
Cc: linux-gpio@vger.kernel.org
---
 drivers/gpio/gpio-pxa.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpio/gpio-pxa.c b/drivers/gpio/gpio-pxa.c
index e45637b..d2324b9 100644
--- a/drivers/gpio/gpio-pxa.c
+++ b/drivers/gpio/gpio-pxa.c
@@ -61,8 +61,7 @@
 #define GAFR_OFFSET	0x54
 #define ED_MASK_OFFSET	0x9C	/* GPIO edge detection for AP side */
 
-#define BANK_OFF(n)	(((n) < 3) ? (n) << 2 : ((n) > 5 ? 0x200 : 0x100)	\
-			+ (((n) % 3) << 2))
+#define BANK_OFF(n)	(((n) / 3) << 8) + (((n) % 3) << 2)
 
 int pxa_last_gpio;
 static int irq_base;
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] gpio: pxa: simplify BANK_OFF macro offset calculation
  2015-03-02 21:30 [PATCH] gpio: pxa: simplify BANK_OFF macro offset calculation Rob Herring
@ 2015-03-03  7:50 ` Alexandre Courbot
  2015-03-09 13:42 ` Linus Walleij
  1 sibling, 0 replies; 3+ messages in thread
From: Alexandre Courbot @ 2015-03-03  7:50 UTC (permalink / raw)
  To: Rob Herring; +Cc: Linus Walleij, linux-gpio@vger.kernel.org

On Tue, Mar 3, 2015 at 6:30 AM, Rob Herring <robh@kernel.org> wrote:
> The macro BANK_OFF which calculates the base offset for each GPIO port.
> The macro is needlessly complex and unreadable. Simplify the
> calculation to a simple math operation.
>
> Signed-off-by: Rob Herring <robh@kernel.org>
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Cc: Alexandre Courbot <gnurou@gmail.com>
> Cc: linux-gpio@vger.kernel.org
> ---
>  drivers/gpio/gpio-pxa.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/gpio/gpio-pxa.c b/drivers/gpio/gpio-pxa.c
> index e45637b..d2324b9 100644
> --- a/drivers/gpio/gpio-pxa.c
> +++ b/drivers/gpio/gpio-pxa.c
> @@ -61,8 +61,7 @@
>  #define GAFR_OFFSET    0x54
>  #define ED_MASK_OFFSET 0x9C    /* GPIO edge detection for AP side */
>
> -#define BANK_OFF(n)    (((n) < 3) ? (n) << 2 : ((n) > 5 ? 0x200 : 0x100)       \
> -                       + (((n) % 3) << 2))
> +#define BANK_OFF(n)    (((n) / 3) << 8) + (((n) % 3) << 2)

Seems to indeed compute the same output as the previous macro in a
more readable way.

Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] gpio: pxa: simplify BANK_OFF macro offset calculation
  2015-03-02 21:30 [PATCH] gpio: pxa: simplify BANK_OFF macro offset calculation Rob Herring
  2015-03-03  7:50 ` Alexandre Courbot
@ 2015-03-09 13:42 ` Linus Walleij
  1 sibling, 0 replies; 3+ messages in thread
From: Linus Walleij @ 2015-03-09 13:42 UTC (permalink / raw)
  To: Rob Herring; +Cc: Alexandre Courbot, linux-gpio@vger.kernel.org

On Mon, Mar 2, 2015 at 10:30 PM, Rob Herring <robh@kernel.org> wrote:

> The macro BANK_OFF which calculates the base offset for each GPIO port.
> The macro is needlessly complex and unreadable. Simplify the
> calculation to a simple math operation.
>
> Signed-off-by: Rob Herring <robh@kernel.org>
> Cc: Linus Walleij <linus.walleij@linaro.org>
> Cc: Alexandre Courbot <gnurou@gmail.com>
> Cc: linux-gpio@vger.kernel.org

Patch applied, thanks Rob.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-03-09 13:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-02 21:30 [PATCH] gpio: pxa: simplify BANK_OFF macro offset calculation Rob Herring
2015-03-03  7:50 ` Alexandre Courbot
2015-03-09 13:42 ` Linus Walleij

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).