drivers/interrup_controller: stm32: stm32_exti_enable could be void

stm32_exti_enable was returning errors on line > 32 or line pointing
to non implemented line. Both conditions are hard-coded, hence there
is no use to detect them dynamically in the code.
Check them with assert. As a consequence, function could now be void.

Additionally, enable exti irq line only if both checks are passed.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
This commit is contained in:
Erwan Gouriou 2019-10-09 13:54:29 +02:00 committed by Carles Cufí
commit 78d7b2106a
3 changed files with 11 additions and 19 deletions

View file

@ -522,10 +522,7 @@ static int gpio_stm32_pin_interrupt_configure(struct device *dev,
stm32_exti_trigger(pin, edge); stm32_exti_trigger(pin, edge);
if (stm32_exti_enable(pin) != 0) { stm32_exti_enable(pin);
err = -EIO;
goto release_lock;
}
release_lock: release_lock:
#if defined(CONFIG_STM32H7_DUAL_CORE) #if defined(CONFIG_STM32H7_DUAL_CORE)

View file

@ -89,30 +89,25 @@ struct stm32_exti_data {
struct __exti_cb cb[ARRAY_SIZE(exti_irq_table)]; struct __exti_cb cb[ARRAY_SIZE(exti_irq_table)];
}; };
int stm32_exti_enable(int line) void stm32_exti_enable(int line)
{ {
int irqnum = 0; int irqnum = 0;
/* Enable requested line interrupt */ if (line >= ARRAY_SIZE(exti_irq_table)) {
if (line < 32) {
LL_EXTI_EnableIT_0_31(1 << line);
} else {
__ASSERT_NO_MSG(line); __ASSERT_NO_MSG(line);
} }
/* Get matching exti irq mathcing provided line thanks to irq_table */ /* Get matching exti irq provided line thanks to irq_table */
if (line < ARRAY_SIZE(exti_irq_table)) { irqnum = exti_irq_table[line];
irqnum = exti_irq_table[line]; if (irqnum == 0xFF) {
if (irqnum == 0xFF) __ASSERT_NO_MSG(line);
return 0;
} else {
return -ENOTSUP;
} }
/* Enable requested line interrupt */
LL_EXTI_EnableIT_0_31(1 << line);
/* Enable exti irq interrupt */ /* Enable exti irq interrupt */
irq_enable(irqnum); irq_enable(irqnum);
return 0;
} }
void stm32_exti_disable(int line) void stm32_exti_disable(int line)

View file

@ -31,7 +31,7 @@
* *
* @param line EXTI# line * @param line EXTI# line
*/ */
int stm32_exti_enable(int line); void stm32_exti_enable(int line);
/** /**
* @brief disable EXTI interrupt for specific line * @brief disable EXTI interrupt for specific line