gpio: pxa: simplify BANK_OFF macro offset calculation
Subsystems (2)
PATCH 1/1 gpio: pxa: simplify BANK_OFF macro offset calculation
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 <[email protected]>
Cc Linus Walleij <[email protected]>
Cc Alexandre Courbot <[email protected]>
--- drivers/gpio/gpio-pxa.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpio/gpio-pxa.c +1 -2
@@ -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;
Signature · 1 line
2.1.0
Quoted 17 lines · Rob Herring
The macro
BANK_OFFwhich 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 <[email protected]>Cc Linus Walleij <[email protected]>Cc Alexandre Courbot <[email protected]>--- drivers/gpio/gpio-pxa.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/gpio/gpio-pxa.c +0
-0
drivers/gpio/gpio-pxa.c line 64
Quoted 6 lines
drivers/gpio/gpio-pxa.c +1
-2@@ -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 <[email protected]>
Quoted 8 lines · Rob Herring
The macro
BANK_OFFwhich 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 <[email protected]>Cc Linus Walleij <[email protected]>Cc Alexandre Courbot <[email protected]>
Patch applied, thanks Rob.
Yours,
Linus Walleij