Skip to content

Commit a6d2ed2

Browse files
committed
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 <[email protected]>
1 parent b8afa26 commit a6d2ed2

File tree

3 files changed

+11
-19
lines changed

3 files changed

+11
-19
lines changed

drivers/gpio/gpio_stm32.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -522,10 +522,7 @@ static int gpio_stm32_pin_interrupt_configure(struct device *dev,
522522

523523
stm32_exti_trigger(pin, edge);
524524

525-
if (stm32_exti_enable(pin) != 0) {
526-
err = -EIO;
527-
goto release_lock;
528-
}
525+
stm32_exti_enable(pin);
529526

530527
release_lock:
531528
#if defined(CONFIG_STM32H7_DUAL_CORE)

drivers/interrupt_controller/exti_stm32.c

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -89,30 +89,25 @@ struct stm32_exti_data {
8989
struct __exti_cb cb[ARRAY_SIZE(exti_irq_table)];
9090
};
9191

92-
int stm32_exti_enable(int line)
92+
void stm32_exti_enable(int line)
9393
{
9494
int irqnum = 0;
9595

96-
/* Enable requested line interrupt */
97-
if (line < 32) {
98-
LL_EXTI_EnableIT_0_31(1 << line);
99-
} else {
96+
if (line >= ARRAY_SIZE(exti_irq_table)) {
10097
__ASSERT_NO_MSG(line);
10198
}
10299

103-
/* Get matching exti irq mathcing provided line thanks to irq_table */
104-
if (line < ARRAY_SIZE(exti_irq_table)) {
105-
irqnum = exti_irq_table[line];
106-
if (irqnum == 0xFF)
107-
return 0;
108-
} else {
109-
return -ENOTSUP;
100+
/* Get matching exti irq provided line thanks to irq_table */
101+
irqnum = exti_irq_table[line];
102+
if (irqnum == 0xFF) {
103+
__ASSERT_NO_MSG(line);
110104
}
111105

106+
/* Enable requested line interrupt */
107+
LL_EXTI_EnableIT_0_31(1 << line);
108+
112109
/* Enable exti irq interrupt */
113110
irq_enable(irqnum);
114-
115-
return 0;
116111
}
117112

118113
void stm32_exti_disable(int line)

drivers/interrupt_controller/exti_stm32.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
*
3232
* @param line EXTI# line
3333
*/
34-
int stm32_exti_enable(int line);
34+
void stm32_exti_enable(int line);
3535

3636
/**
3737
* @brief disable EXTI interrupt for specific line

0 commit comments

Comments
 (0)