Skip to content
Permalink
Browse files

drivers/interrupt_controller: stm32: Remove unused code

Some code in stm32 exti driver was considering exti lines number
for which no IRQ_CONNECT was available. To be clear, this code
was not functional and since no one complained it was not used.
Besides, code to take into account these "high" irq lines was
complex hard to read and review.
Simplify state of things by removing completely this part of code.
It could be put back again piece by piece when required.

This change allows to get rid of EXTI_LINES definition.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
  • Loading branch information...
erwango authored and nashif committed Jun 11, 2019
1 parent edbf173 commit 959c2d521a39e5e853893d7613f15ae9189bdac6
Showing with 4 additions and 136 deletions.
  1. +4 −136 drivers/interrupt_controller/exti_stm32.c
@@ -21,36 +21,6 @@
#include <misc/__assert.h>
#include "exti_stm32.h"

#if defined(CONFIG_SOC_SERIES_STM32F0X)
#define EXTI_LINES 32
#elif defined(CONFIG_SOC_SERIES_STM32F1X)
#define EXTI_LINES 19
#elif defined(CONFIG_SOC_SERIES_STM32F2X)
#define EXTI_LINES 23
#elif defined(CONFIG_SOC_STM32F302X8)
#define EXTI_LINES 36
#elif defined(CONFIG_SOC_STM32F303XC)
#define EXTI_LINES 36
#elif defined(CONFIG_SOC_STM32F334X8)
#define EXTI_LINES 36
#elif defined(CONFIG_SOC_STM32F373XC)
#define EXTI_LINES 29
#elif defined(CONFIG_SOC_SERIES_STM32F4X)
#define EXTI_LINES 23
#elif defined(CONFIG_SOC_SERIES_STM32F7X)
#define EXTI_LINES 24
#elif defined(CONFIG_SOC_SERIES_STM32L0X)
#define EXTI_LINES 30
#elif defined(CONFIG_SOC_SERIES_STM32L1X)
#define EXTI_LINES 24
#elif defined(CONFIG_SOC_SERIES_STM32L4X)
#define EXTI_LINES 40
#elif defined(CONFIG_SOC_SERIES_STM32MP1X)
#define EXTI_LINES 76
#elif defined(CONFIG_SOC_SERIES_STM32WBX)
#define EXTI_LINES 49
#endif

#if defined(CONFIG_SOC_SERIES_STM32F0X) || \
defined(CONFIG_SOC_SERIES_STM32L0X)
IRQn_Type exti_irq_table[] = {
@@ -100,21 +70,7 @@ IRQn_Type exti_irq_table[] = {
EXTI0_IRQn, EXTI1_IRQn, EXTI2_IRQn, EXTI3_IRQn,
EXTI4_IRQn, EXTI5_IRQn, EXTI6_IRQn, EXTI7_IRQn,
EXTI8_IRQn, EXTI9_IRQn, EXTI10_IRQn, EXTI11_IRQn,
EXTI12_IRQn, EXTI13_IRQn, EXTI14_IRQn, EXTI15_IRQn,
PVD_AVD_IRQn, RTC_TIMESTAMP_IRQn, TAMP_IRQn, RTC_WKUP_ALARM_IRQn,
0xFF, I2C1_EV_IRQn, I2C2_EV_IRQn, I2C3_EV_IRQn,
I2C3_EV_IRQn, I2C5_EV_IRQn, USART1_IRQn, USART2_IRQn,
USART3_IRQn, USART6_IRQn, UART4_IRQn, UART5_IRQn,
UART7_IRQn, UART8_IRQn, 0xFF, 0xFF,
SPI1_IRQn, SPI2_IRQn, SPI3_IRQn, SPI4_IRQn,
SPI5_IRQn, SPI6_IRQn, MDIOS_IRQn, USBH_OHCI_IRQn,
OTG_IRQn, 0xFF, 0xFF, LPTIM1_IRQn,
LPTIM2_IRQn, 0xFF, LPTIM3_IRQn, 0xFF,
LPTIM4_IRQn, LPTIM5_IRQn, I2C6_EV_IRQn, WAKEUP_PIN_IRQn,
WAKEUP_PIN_IRQn, WAKEUP_PIN_IRQn, WAKEUP_PIN_IRQn, WAKEUP_PIN_IRQn,
WAKEUP_PIN_IRQn, IPCC_RX0_IRQn, IPCC_RX1_IRQn, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF,
0xFF, CEC_IRQn, ETH1_WKUP_IRQn, 0xFF, DTS_IRQn
EXTI12_IRQn, EXTI13_IRQn, EXTI14_IRQn, EXTI15_IRQn
};
#endif

@@ -127,7 +83,7 @@ struct __exti_cb {
/* driver data */
struct stm32_exti_data {
/* per-line callbacks */
struct __exti_cb cb[EXTI_LINES];
struct __exti_cb cb[ARRAY_SIZE(exti_irq_table)];
};

int stm32_exti_enable(int line)
@@ -137,18 +93,8 @@ int stm32_exti_enable(int line)
/* Enable requested line interrupt */
if (line < 32) {
LL_EXTI_EnableIT_0_31(1 << line);
} else if (line < 64) {
#if EXTI_LINES > 32
LL_EXTI_EnableIT_32_63(1 << (line - 32));
#else
__ASSERT_NO_MSG(line);
#endif
} else {
#if EXTI_LINES > 64
LL_EXTI_EnableIT_64_95(1 << (line - 32));
#else
__ASSERT_NO_MSG(line);
#endif
}

/* Get matching exti irq mathcing provided line thanks to irq_table */
@@ -170,18 +116,10 @@ void stm32_exti_disable(int line)
{
if (line < 32) {
LL_EXTI_DisableIT_0_31(1 << line);
} else if (line < 64) {
#if EXTI_LINES > 32
LL_EXTI_DisableIT_32_63(1 << (line - 32));
#else
__ASSERT_NO_MSG(line);
#endif
} else {
#if EXTI_LINES > 64
LL_EXTI_DisableIT_64_95(1 << (line - 64));
#else

__ASSERT_NO_MSG(line);
#endif

}
}

@@ -198,31 +136,10 @@ static inline int stm32_exti_is_pending(int line)
LL_EXTI_IsActiveFallingFlag_0_31(1 << line));
#else
return LL_EXTI_IsActiveFlag_0_31(1 << line);
#endif
} else if (line < 64) {
#if EXTI_LINES > 32
#if defined(CONFIG_SOC_SERIES_STM32MP1X)
__ASSERT_NO_MSG(line);
return 0;
#else
return LL_EXTI_IsActiveFlag_32_63(1 << (line - 32));
#endif
#else
__ASSERT_NO_MSG(line);
return 0;
#endif
} else {
#if EXTI_LINES > 64
#if defined(CONFIG_SOC_SERIES_STM32MP1X)
return (LL_EXTI_IsActiveRisingFlag_64_95(1 << (line - 64)) ||
LL_EXTI_IsActiveFallingFlag_64_95(1 << (line - 64)));
#else
return LL_EXTI_IsActiveFlag_64_96(1 << (line - 64));
#endif
#else
__ASSERT_NO_MSG(line);
return 0;
#endif
}
}

@@ -239,26 +156,9 @@ static inline void stm32_exti_clear_pending(int line)
LL_EXTI_ClearFallingFlag_0_31(1 << line);
#else
LL_EXTI_ClearFlag_0_31(1 << line);
#endif
} else if (line < 64) {
#if EXTI_LINES > 32
#if !defined(CONFIG_SOC_SERIES_STM32MP1X)
LL_EXTI_ClearFlag_32_63(1 << (line - 32));
#endif
#else
__ASSERT_NO_MSG(line);
#endif
} else {
#if EXTI_LINES > 64
#if defined(CONFIG_SOC_SERIES_STM32MP1X)
LL_EXTI_ClearRisingFlag_64_95(1 << (line - 64));
LL_EXTI_ClearFallingFlag_64_95(1 << (line - 64));
#else
__ASSERT_NO_MSG(line);
#endif
#else
__ASSERT_NO_MSG(line);
#endif
}
}

@@ -267,48 +167,16 @@ void stm32_exti_trigger(int line, int trigger)
if (trigger & STM32_EXTI_TRIG_RISING) {
if (line < 32) {
LL_EXTI_EnableRisingTrig_0_31(1 << line);
} else if (line < 64) {
#if EXTI_LINES > 32
#if defined(CONFIG_SOC_SERIES_STM32MP1X)
__ASSERT_NO_MSG(line);
#else
LL_EXTI_EnableRisingTrig_32_63(1 << (line - 32));
#endif
#else
__ASSERT_NO_MSG(line);
#endif
} else {
#if EXTI_LINES > 64
#if !defined(CONFIG_SOC_SERIES_STM32MP1X)
__ASSERT_NO_MSG(line);
#else
LL_EXTI_EnableRisingTrig_64_95(1 << (line - 64));
#endif
#endif
}
}

if (trigger & STM32_EXTI_TRIG_FALLING) {
if (line < 32) {
LL_EXTI_EnableFallingTrig_0_31(1 << line);
} else if (line < 64) {
#if EXTI_LINES > 32
#if defined(CONFIG_SOC_SERIES_STM32MP1X)
__ASSERT_NO_MSG(line);
#else
LL_EXTI_EnableFallingTrig_32_63(1 << (line - 32));
#endif
#else
__ASSERT_NO_MSG(line);
#endif
} else {
#if EXTI_LINES > 64
#if !defined(CONFIG_SOC_SERIES_STM32MP1X)
__ASSERT_NO_MSG(line);
#else
LL_EXTI_EnableRisingTrig_64_95(1 << (line - 64));
#endif
#endif
}
}
}

0 comments on commit 959c2d5

Please sign in to comment.
You can’t perform that action at this time.