ASoC: SDCA: Factor out a helper to find SDCA IRQ data

Add a helper function to locate the sdca_interrupt structure for a given
SDCA IRQ, this makes the code a little more readable and will facilitate
some additions in the future.

Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.dev>
Link: https://patch.msgid.link/20251020155512.353774-8-ckeepax@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Charles Keepax 2025-10-20 16:55:00 +01:00 committed by Mark Brown
parent 56bbda23d4
commit 8d557cc486
No known key found for this signature in database
GPG Key ID: 24D68B725D5487D0

View File

@ -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);