Unverified Commit 8d557cc4 authored by Charles Keepax's avatar Charles Keepax Committed by Mark Brown
Browse files

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: default avatarBard Liao <yung-chuan.liao@linux.intel.com>
Signed-off-by: default avatarCharles Keepax <ckeepax@opensource.cirrus.com>
Reviewed-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.dev>
Link: https://patch.msgid.link/20251020155512.353774-8-ckeepax@opensource.cirrus.com


Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 56bbda23
Loading
Loading
Loading
Loading
+22 −14
Original line number Diff line number Diff line
@@ -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) {
				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);
			interrupt = get_interrupt_data(dev, irq, info);
			if (IS_ERR(interrupt))
				return PTR_ERR(interrupt);
			else if (!interrupt)
				continue;
			}

			ret = sdca_irq_data_populate(component, function, entity,
						     control, interrupt);