diff --git a/sound/soc/sdca/sdca_interrupts.c b/sound/soc/sdca/sdca_interrupts.c index cb7c7a6f356e..2b3bb7d0cb44 100644 --- a/sound/soc/sdca/sdca_interrupts.c +++ b/sound/soc/sdca/sdca_interrupts.c @@ -341,6 +341,24 @@ int sdca_irq_data_populate(struct snd_soc_component *component, } EXPORT_SYMBOL_NS_GPL(sdca_irq_data_populate, "SND_SOC_SDCA"); +static struct sdca_interrupt *get_interrupt_data(struct device *dev, int irq, + struct sdca_interrupt_info *info) +{ + if (irq == SDCA_NO_INTERRUPT) { + return NULL; + } else if (irq < 0 || irq >= SDCA_MAX_INTERRUPTS) { + dev_err(dev, "bad irq position: %d\n", irq); + return ERR_PTR(-EINVAL); + } + + if (info->irqs[irq].irq) { + dev_dbg(dev, "skipping irq %d, already requested\n", irq); + return NULL; + } + + return &info->irqs[irq]; +} + /** * sdca_irq_populate - Request all the individual IRQs for an SDCA Function * @function: Pointer to the SDCA Function. @@ -370,21 +388,11 @@ int sdca_irq_populate(struct sdca_function_data *function, irq_handler_t handler; int ret; - if (irq == SDCA_NO_INTERRUPT) { + interrupt = get_interrupt_data(dev, irq, info); + if (IS_ERR(interrupt)) + return PTR_ERR(interrupt); + else if (!interrupt) continue; - } else if (irq < 0 || irq >= SDCA_MAX_INTERRUPTS) { - dev_err(dev, "bad irq position: %d\n", irq); - return -EINVAL; - } - - interrupt = &info->irqs[irq]; - - if (interrupt->requested) { - dev_dbg(dev, - "skipping irq %d, already requested\n", - irq); - continue; - } ret = sdca_irq_data_populate(component, function, entity, control, interrupt);