]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ASoC: SDCA: Factor out a helper to find SDCA IRQ data
authorCharles Keepax <ckeepax@opensource.cirrus.com>
Mon, 20 Oct 2025 15:55:00 +0000 (16:55 +0100)
committerMark Brown <broonie@kernel.org>
Mon, 27 Oct 2025 15:31:17 +0000 (15:31 +0000)
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>
sound/soc/sdca/sdca_interrupts.c

index cb7c7a6f356ed8cc22dd558981ccbaa03732631d..2b3bb7d0cb4439f6b3c4645e13d6d3cfc5811117 100644 (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) {
-                               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);