From 89f71ba0e27684107f6be413cd53821a707364bf Mon Sep 17 00:00:00 2001 From: Kumar Gala Date: Wed, 19 Oct 2016 11:26:55 -0500 Subject: [PATCH] stm32: cleanup how we get external interrupt base addr Move to utilizing an inline function for getting the base addr of the external interrupt register region. This is in prep for support more than 32 external interrupts. Change-Id: Ifdaad67703068395a7749543ef68435435e7c9ba Signed-off-by: Kumar Gala --- drivers/interrupt_controller/exti_stm32.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/interrupt_controller/exti_stm32.c b/drivers/interrupt_controller/exti_stm32.c index 4277fb05ab8..d55f933ccda 100644 --- a/drivers/interrupt_controller/exti_stm32.c +++ b/drivers/interrupt_controller/exti_stm32.c @@ -62,13 +62,14 @@ struct stm32_exti_data { struct __exti_cb cb[EXTI_LINES]; }; - -#define AS_EXTI(__base_addr) \ - ((struct stm32_exti *)(__base_addr)) +static inline struct stm32_exti *get_exti_base_addr(int line) +{ + return (struct stm32_exti *)EXTI_BASE; +} void stm32_exti_enable(int line) { - volatile struct stm32_exti *exti = AS_EXTI(EXTI_BASE); + volatile struct stm32_exti *exti = get_exti_base_addr(line); int irqnum; exti->imr |= 1 << line; @@ -89,7 +90,7 @@ void stm32_exti_enable(int line) void stm32_exti_disable(int line) { - volatile struct stm32_exti *exti = AS_EXTI(EXTI_BASE); + volatile struct stm32_exti *exti = get_exti_base_addr(line); exti->imr &= ~(1 << line); } @@ -101,7 +102,7 @@ void stm32_exti_disable(int line) */ static inline int stm32_exti_is_pending(int line) { - volatile struct stm32_exti *exti = AS_EXTI(EXTI_BASE); + volatile struct stm32_exti *exti = get_exti_base_addr(line); return (exti->pr & (1 << line)) ? 1 : 0; } @@ -113,14 +114,14 @@ static inline int stm32_exti_is_pending(int line) */ static inline void stm32_exti_clear_pending(int line) { - volatile struct stm32_exti *exti = AS_EXTI(EXTI_BASE); + volatile struct stm32_exti *exti = get_exti_base_addr(line); exti->pr = 1 << line; } void stm32_exti_trigger(int line, int trigger) { - volatile struct stm32_exti *exti = AS_EXTI(EXTI_BASE); + volatile struct stm32_exti *exti = get_exti_base_addr(line); if (trigger & STM32_EXTI_TRIG_RISING) { exti->rtsr |= 1 << line;