You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ac...@apache.org on 2023/11/14 00:03:42 UTC
(nuttx) branch master updated: stm32/stm32_adc.c: protect irq_attach with refcounter
This is an automated email from the ASF dual-hosted git repository.
acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 0e40cc2853 stm32/stm32_adc.c: protect irq_attach with refcounter
0e40cc2853 is described below
commit 0e40cc285366e82f2603f8ca569f52051f886851
Author: raiden00pl <ra...@railab.me>
AuthorDate: Mon Nov 13 17:24:10 2023 +0100
stm32/stm32_adc.c: protect irq_attach with refcounter
irq_attach should only be called once for ADCs that share a common interrupt handler.
We can move irq_attach to just before interrupts are enabled.
---
arch/arm/src/stm32/stm32_adc.c | 22 ++++++++++------------
1 file changed, 10 insertions(+), 12 deletions(-)
diff --git a/arch/arm/src/stm32/stm32_adc.c b/arch/arm/src/stm32/stm32_adc.c
index ca39b6a1d2..7b8877edb6 100644
--- a/arch/arm/src/stm32/stm32_adc.c
+++ b/arch/arm/src/stm32/stm32_adc.c
@@ -2890,17 +2890,6 @@ static int adc_setup(struct adc_dev_s *dev)
return OK;
}
- /* Attach the ADC interrupt */
-
-#ifndef CONFIG_STM32_ADC_NOIRQ
- ret = irq_attach(priv->irq, priv->isr, NULL);
- if (ret < 0)
- {
- ainfo("irq_attach failed: %d\n", ret);
- return ret;
- }
-#endif
-
/* Make sure that the ADC device is in the powered up, reset state */
adc_reset(dev);
@@ -2954,9 +2943,18 @@ static int adc_setup(struct adc_dev_s *dev)
if (priv->cmn->refcount == 0)
#endif
{
+#ifndef CONFIG_STM32_ADC_NOIRQ
+ /* Attach the ADC interrupt */
+
+ ret = irq_attach(priv->irq, priv->isr, NULL);
+ if (ret < 0)
+ {
+ ainfo("irq_attach failed: %d\n", ret);
+ return ret;
+ }
+
/* Enable the ADC interrupt */
-#ifndef CONFIG_STM32_ADC_NOIRQ
ainfo("Enable the ADC interrupt: irq=%d\n", priv->irq);
up_enable_irq(priv->irq);
#endif