Skip to content

Commit 10134ec

Browse files
Fabrice Gasnierjic23
authored andcommitted
iio: adc: stm32-adc: fix a wrong error message when probing interrupts
A wrong error message is printed out currently, like on STM32MP15: - stm32-adc-core 48003000.adc: IRQ index 2 not found. This is seen since commit 7723f4c ("driver core: platform: Add an error message to platform_get_irq*()"). The STM32 ADC core driver wrongly requests up to 3 interrupt lines. It should request only the necessary IRQs, based on the compatible: - stm32f4/h7 ADCs share a common interrupt - stm32mp1, has one interrupt line per ADC. So add the number of required interrupts to the compatible data. Fixes: d58c67d ("iio: adc: stm32-adc: add support for STM32MP1") Signed-off-by: Fabrice Gasnier <[email protected]> Cc: <[email protected]> Signed-off-by: Jonathan Cameron <[email protected]>
1 parent f6dbf83 commit 10134ec

File tree

1 file changed

+14
-20
lines changed

1 file changed

+14
-20
lines changed

drivers/iio/adc/stm32-adc-core.c

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,14 @@ struct stm32_adc_priv;
6565
* @clk_sel: clock selection routine
6666
* @max_clk_rate_hz: maximum analog clock rate (Hz, from datasheet)
6767
* @has_syscfg: SYSCFG capability flags
68+
* @num_irqs: number of interrupt lines
6869
*/
6970
struct stm32_adc_priv_cfg {
7071
const struct stm32_adc_common_regs *regs;
7172
int (*clk_sel)(struct platform_device *, struct stm32_adc_priv *);
7273
u32 max_clk_rate_hz;
7374
unsigned int has_syscfg;
75+
unsigned int num_irqs;
7476
};
7577

7678
/**
@@ -375,21 +377,15 @@ static int stm32_adc_irq_probe(struct platform_device *pdev,
375377
struct device_node *np = pdev->dev.of_node;
376378
unsigned int i;
377379

378-
for (i = 0; i < STM32_ADC_MAX_ADCS; i++) {
380+
/*
381+
* Interrupt(s) must be provided, depending on the compatible:
382+
* - stm32f4/h7 shares a common interrupt line.
383+
* - stm32mp1, has one line per ADC
384+
*/
385+
for (i = 0; i < priv->cfg->num_irqs; i++) {
379386
priv->irq[i] = platform_get_irq(pdev, i);
380-
if (priv->irq[i] < 0) {
381-
/*
382-
* At least one interrupt must be provided, make others
383-
* optional:
384-
* - stm32f4/h7 shares a common interrupt.
385-
* - stm32mp1, has one line per ADC (either for ADC1,
386-
* ADC2 or both).
387-
*/
388-
if (i && priv->irq[i] == -ENXIO)
389-
continue;
390-
387+
if (priv->irq[i] < 0)
391388
return priv->irq[i];
392-
}
393389
}
394390

395391
priv->domain = irq_domain_add_simple(np, STM32_ADC_MAX_ADCS, 0,
@@ -400,9 +396,7 @@ static int stm32_adc_irq_probe(struct platform_device *pdev,
400396
return -ENOMEM;
401397
}
402398

403-
for (i = 0; i < STM32_ADC_MAX_ADCS; i++) {
404-
if (priv->irq[i] < 0)
405-
continue;
399+
for (i = 0; i < priv->cfg->num_irqs; i++) {
406400
irq_set_chained_handler(priv->irq[i], stm32_adc_irq_handler);
407401
irq_set_handler_data(priv->irq[i], priv);
408402
}
@@ -420,11 +414,8 @@ static void stm32_adc_irq_remove(struct platform_device *pdev,
420414
irq_dispose_mapping(irq_find_mapping(priv->domain, hwirq));
421415
irq_domain_remove(priv->domain);
422416

423-
for (i = 0; i < STM32_ADC_MAX_ADCS; i++) {
424-
if (priv->irq[i] < 0)
425-
continue;
417+
for (i = 0; i < priv->cfg->num_irqs; i++)
426418
irq_set_chained_handler(priv->irq[i], NULL);
427-
}
428419
}
429420

430421
static int stm32_adc_core_switches_supply_en(struct stm32_adc_priv *priv,
@@ -817,20 +808,23 @@ static const struct stm32_adc_priv_cfg stm32f4_adc_priv_cfg = {
817808
.regs = &stm32f4_adc_common_regs,
818809
.clk_sel = stm32f4_adc_clk_sel,
819810
.max_clk_rate_hz = 36000000,
811+
.num_irqs = 1,
820812
};
821813

822814
static const struct stm32_adc_priv_cfg stm32h7_adc_priv_cfg = {
823815
.regs = &stm32h7_adc_common_regs,
824816
.clk_sel = stm32h7_adc_clk_sel,
825817
.max_clk_rate_hz = 36000000,
826818
.has_syscfg = HAS_VBOOSTER,
819+
.num_irqs = 1,
827820
};
828821

829822
static const struct stm32_adc_priv_cfg stm32mp1_adc_priv_cfg = {
830823
.regs = &stm32h7_adc_common_regs,
831824
.clk_sel = stm32h7_adc_clk_sel,
832825
.max_clk_rate_hz = 40000000,
833826
.has_syscfg = HAS_VBOOSTER | HAS_ANASWVDD,
827+
.num_irqs = 2,
834828
};
835829

836830
static const struct of_device_id stm32_adc_of_match[] = {

0 commit comments

Comments
 (0)