ASoC: SOF: Intel: hda: simplify and reduce indentation for hda_sdw_machine_select()
authorPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Fri, 26 Apr 2024 15:39:00 +0000 (10:39 -0500)
committerMark Brown <broonie@kernel.org>
Mon, 29 Apr 2024 15:16:35 +0000 (00:16 +0900)
Simplify code to return when no links are enabled. No functional
change, just code cleanup before updates.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Link: https://lore.kernel.org/r/20240426153902.39560-4-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/sof/intel/hda.c

index 2fc10bec7331c7d63d957d6055a1e65f78dcf3bb..d69cafc2d313e51357f3925dd99d7975c1c7a9fa 100644 (file)
@@ -1653,92 +1653,95 @@ static struct snd_soc_acpi_mach *hda_sdw_machine_select(struct snd_sof_dev *sdev
        hdev = pdata->hw_pdata;
        link_mask = hdev->info.link_mask;
 
+       if (!link_mask) {
+               dev_info(sdev->dev, "SoundWire links not enabled\n");
+               return NULL;
+       }
+
        /*
         * Select SoundWire machine driver if needed using the
         * alternate tables. This case deals with SoundWire-only
         * machines, for mixed cases with I2C/I2S the detection relies
         * on the HID list.
         */
-       if (link_mask) {
-               for (mach = pdata->desc->alt_machines;
-                    mach && mach->link_mask; mach++) {
-                       /*
-                        * On some platforms such as Up Extreme all links
-                        * are enabled but only one link can be used by
-                        * external codec. Instead of exact match of two masks,
-                        * first check whether link_mask of mach is subset of
-                        * link_mask supported by hw and then go on searching
-                        * link_adr
-                        */
-                       if (~link_mask & mach->link_mask)
-                               continue;
-
-                       /* No need to match adr if there is no links defined */
-                       if (!mach->links)
-                               break;
-
-                       link = mach->links;
-                       for (i = 0; i < hdev->info.count && link->num_adr;
-                            i++, link++) {
-                               /*
-                                * Try next machine if any expected Slaves
-                                * are not found on this link.
-                                */
-                               if (!snd_soc_acpi_sdw_link_slaves_found(sdev->dev, link,
-                                                                       hdev->sdw->ids,
-                                                                       hdev->sdw->num_slaves))
-                                       break;
-                       }
-                       /* Found if all Slaves are checked */
-                       if (i == hdev->info.count || !link->num_adr)
-                               break;
-               }
-               if (mach && mach->link_mask) {
-                       int dmic_num = 0;
-                       bool tplg_fixup;
-                       const char *tplg_filename;
-
-                       mach->mach_params.links = mach->links;
-                       mach->mach_params.link_mask = mach->link_mask;
-                       mach->mach_params.platform = dev_name(sdev->dev);
+       for (mach = pdata->desc->alt_machines;
+            mach && mach->link_mask; mach++) {
+               /*
+                * On some platforms such as Up Extreme all links
+                * are enabled but only one link can be used by
+                * external codec. Instead of exact match of two masks,
+                * first check whether link_mask of mach is subset of
+                * link_mask supported by hw and then go on searching
+                * link_adr
+                */
+               if (~link_mask & mach->link_mask)
+                       continue;
 
-                       if (pdata->tplg_filename) {
-                               tplg_fixup = false;
-                       } else {
-                               tplg_fixup = true;
-                               tplg_filename = mach->sof_tplg_filename;
-                       }
+               /* No need to match adr if there is no links defined */
+               if (!mach->links)
+                       break;
 
+               link = mach->links;
+               for (i = 0; i < hdev->info.count && link->num_adr;
+                    i++, link++) {
                        /*
-                        * DMICs use up to 4 pins and are typically pin-muxed with SoundWire
-                        * link 2 and 3, or link 1 and 2, thus we only try to enable dmics
-                        * if all conditions are true:
-                        * a) 2 or fewer links are used by SoundWire
-                        * b) the NHLT table reports the presence of microphones
+                        * Try next machine if any expected Slaves
+                        * are not found on this link.
                         */
-                       if (hweight_long(mach->link_mask) <= 2) {
-                               int ret;
-
-                               ret = dmic_detect_topology_fixup(sdev, &tplg_filename, "",
-                                                                &dmic_num, tplg_fixup);
-                               if (ret < 0)
-                                       return NULL;
-                       }
-                       if (tplg_fixup)
-                               pdata->tplg_filename = tplg_filename;
-                       mach->mach_params.dmic_num = dmic_num;
+                       if (!snd_soc_acpi_sdw_link_slaves_found(sdev->dev, link,
+                                                               hdev->sdw->ids,
+                                                               hdev->sdw->num_slaves))
+                               break;
+               }
+               /* Found if all Slaves are checked */
+               if (i == hdev->info.count || !link->num_adr)
+                       break;
+       }
+       if (mach && mach->link_mask) {
+               int dmic_num = 0;
+               bool tplg_fixup;
+               const char *tplg_filename;
+
+               mach->mach_params.links = mach->links;
+               mach->mach_params.link_mask = mach->link_mask;
+               mach->mach_params.platform = dev_name(sdev->dev);
+
+               if (pdata->tplg_filename) {
+                       tplg_fixup = false;
+               } else {
+                       tplg_fixup = true;
+                       tplg_filename = mach->sof_tplg_filename;
+               }
 
-                       dev_dbg(sdev->dev,
-                               "SoundWire machine driver %s topology %s\n",
-                               mach->drv_name,
-                               pdata->tplg_filename);
+               /*
+                * DMICs use up to 4 pins and are typically pin-muxed with SoundWire
+                * link 2 and 3, or link 1 and 2, thus we only try to enable dmics
+                * if all conditions are true:
+                * a) 2 or fewer links are used by SoundWire
+                * b) the NHLT table reports the presence of microphones
+                */
+               if (hweight_long(mach->link_mask) <= 2) {
+                       int ret;
 
-                       return mach;
+                       ret = dmic_detect_topology_fixup(sdev, &tplg_filename, "",
+                                                        &dmic_num, tplg_fixup);
+                       if (ret < 0)
+                               return NULL;
                }
+               if (tplg_fixup)
+                       pdata->tplg_filename = tplg_filename;
+               mach->mach_params.dmic_num = dmic_num;
 
-               dev_info(sdev->dev, "No SoundWire machine driver found\n");
+               dev_dbg(sdev->dev,
+                       "SoundWire machine driver %s topology %s\n",
+                       mach->drv_name,
+                       pdata->tplg_filename);
+
+               return mach;
        }
 
+       dev_info(sdev->dev, "No SoundWire machine driver found\n");
+
        return NULL;
 }
 #else