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:
parent
29e9780ad1
commit
78d7b2106a
3 changed files with 11 additions and 19 deletions
|
@ -522,10 +522,7 @@ static int gpio_stm32_pin_interrupt_configure(struct device *dev,
|
|||
|
||||
stm32_exti_trigger(pin, edge);
|
||||
|
||||
if (stm32_exti_enable(pin) != 0) {
|
||||
err = -EIO;
|
||||
goto release_lock;
|
||||
}
|
||||
stm32_exti_enable(pin);
|
||||
|
||||
release_lock:
|
||||
#if defined(CONFIG_STM32H7_DUAL_CORE)
|
||||
|
|
|
@ -89,30 +89,25 @@ struct stm32_exti_data {
|
|||
struct __exti_cb cb[ARRAY_SIZE(exti_irq_table)];
|
||||
};
|
||||
|
||||
int stm32_exti_enable(int line)
|
||||
void stm32_exti_enable(int line)
|
||||
{
|
||||
int irqnum = 0;
|
||||
|
||||
/* Enable requested line interrupt */
|
||||
if (line < 32) {
|
||||
LL_EXTI_EnableIT_0_31(1 << line);
|
||||
} else {
|
||||
if (line >= ARRAY_SIZE(exti_irq_table)) {
|
||||
__ASSERT_NO_MSG(line);
|
||||
}
|
||||
|
||||
/* Get matching exti irq mathcing provided line thanks to irq_table */
|
||||
if (line < ARRAY_SIZE(exti_irq_table)) {
|
||||
irqnum = exti_irq_table[line];
|
||||
if (irqnum == 0xFF)
|
||||
return 0;
|
||||
} else {
|
||||
return -ENOTSUP;
|
||||
/* Get matching exti irq provided line thanks to irq_table */
|
||||
irqnum = exti_irq_table[line];
|
||||
if (irqnum == 0xFF) {
|
||||
__ASSERT_NO_MSG(line);
|
||||
}
|
||||
|
||||
/* Enable requested line interrupt */
|
||||
LL_EXTI_EnableIT_0_31(1 << line);
|
||||
|
||||
/* Enable exti irq interrupt */
|
||||
irq_enable(irqnum);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void stm32_exti_disable(int line)
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
*
|
||||
* @param line EXTI# line
|
||||
*/
|
||||
int stm32_exti_enable(int line);
|
||||
void stm32_exti_enable(int line);
|
||||
|
||||
/**
|
||||
* @brief disable EXTI interrupt for specific line
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue