Re: [PATCH] gpio: pxa: simplify BANK_OFF macro offset calculation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Mar 3, 2015 at 6:30 AM, Rob Herring <robh@xxxxxxxxxx> 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@xxxxxxxxxx>
> Cc: Linus Walleij <linus.walleij@xxxxxxxxxx>
> Cc: Alexandre Courbot <gnurou@xxxxxxxxx>
> Cc: linux-gpio@xxxxxxxxxxxxxxx
> ---
>  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@xxxxxxxxxx>
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux