Message ID | 1425331858-6018-1-git-send-email-robh@kernel.org |
---|---|
State | New |
Headers | show |
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> -- To unsubscribe from this list: send the line "unsubscribe linux-gpio" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
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 -- To unsubscribe from this list: send the line "unsubscribe linux-gpio" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
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;
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(-)