@@ -1105,7 +1105,8 @@ int hda_dsp_remove(struct snd_sof_dev *sdev)
11051105}
11061106
11071107#if IS_ENABLED (CONFIG_SND_SOC_SOF_HDA )
1108- static int hda_generic_machine_select (struct snd_sof_dev * sdev )
1108+ static void hda_generic_machine_select (struct snd_sof_dev * sdev ,
1109+ struct snd_soc_acpi_mach * * mach )
11091110{
11101111 struct hdac_bus * bus = sof_to_bus (sdev );
11111112 struct snd_soc_acpi_mach_params * mach_params ;
@@ -1137,7 +1138,7 @@ static int hda_generic_machine_select(struct snd_sof_dev *sdev)
11371138 * - one HDMI codec, and/or
11381139 * - one external HDAudio codec
11391140 */
1140- if (!pdata -> machine && codec_num <= 2 ) {
1141+ if (!* mach && codec_num <= 2 ) {
11411142 hda_mach = snd_soc_acpi_intel_hda_machines ;
11421143
11431144 dev_info (bus -> dev , "using HDA machine driver %s now\n" ,
@@ -1152,10 +1153,9 @@ static int hda_generic_machine_select(struct snd_sof_dev *sdev)
11521153 tplg_filename = hda_mach -> sof_tplg_filename ;
11531154 ret = dmic_topology_fixup (sdev , & tplg_filename , idisp_str , & dmic_num );
11541155 if (ret < 0 )
1155- return ret ;
1156+ return ;
11561157
11571158 hda_mach -> mach_params .dmic_num = dmic_num ;
1158- pdata -> machine = hda_mach ;
11591159 pdata -> tplg_filename = tplg_filename ;
11601160
11611161 if (codec_num == 2 ) {
@@ -1165,23 +1165,22 @@ static int hda_generic_machine_select(struct snd_sof_dev *sdev)
11651165 */
11661166 hda_mach -> mach_params .link_mask = 0 ;
11671167 }
1168+
1169+ * mach = hda_mach ;
11681170 }
11691171 }
11701172
11711173 /* used by hda machine driver to create dai links */
1172- if (pdata -> machine ) {
1173- mach_params = (struct snd_soc_acpi_mach_params * )
1174- & pdata -> machine -> mach_params ;
1174+ if (* mach ) {
1175+ mach_params = & (* mach )-> mach_params ;
11751176 mach_params -> codec_mask = bus -> codec_mask ;
11761177 mach_params -> common_hdmi_codec_drv = hda_codec_use_common_hdmi ;
11771178 }
1178-
1179- return 0 ;
11801179}
11811180#else
1182- static int hda_generic_machine_select (struct snd_sof_dev * sdev )
1181+ static void hda_generic_machine_select (struct snd_sof_dev * sdev ,
1182+ struct snd_soc_acpi_mach * * mach )
11831183{
1184- return 0 ;
11851184}
11861185#endif
11871186
@@ -1264,7 +1263,7 @@ static bool link_slaves_found(struct snd_sof_dev *sdev,
12641263 return true;
12651264}
12661265
1267- static int hda_sdw_machine_select (struct snd_sof_dev * sdev )
1266+ static struct snd_soc_acpi_mach * hda_sdw_machine_select (struct snd_sof_dev * sdev )
12681267{
12691268 struct snd_sof_pdata * pdata = sdev -> pdata ;
12701269 const struct snd_soc_acpi_link_adr * link ;
@@ -1282,7 +1281,7 @@ static int hda_sdw_machine_select(struct snd_sof_dev *sdev)
12821281 * machines, for mixed cases with I2C/I2S the detection relies
12831282 * on the HID list.
12841283 */
1285- if (link_mask && ! pdata -> machine ) {
1284+ if (link_mask ) {
12861285 for (mach = pdata -> desc -> alt_machines ;
12871286 mach && mach -> link_mask ; mach ++ ) {
12881287 /*
@@ -1317,7 +1316,6 @@ static int hda_sdw_machine_select(struct snd_sof_dev *sdev)
13171316 if (mach && mach -> link_mask ) {
13181317 int dmic_num = 0 ;
13191318
1320- pdata -> machine = mach ;
13211319 mach -> mach_params .links = mach -> links ;
13221320 mach -> mach_params .link_mask = mach -> link_mask ;
13231321 mach -> mach_params .platform = dev_name (sdev -> dev );
@@ -1339,9 +1337,8 @@ static int hda_sdw_machine_select(struct snd_sof_dev *sdev)
13391337 int ret ;
13401338
13411339 ret = dmic_topology_fixup (sdev , & tplg_filename , "" , & dmic_num );
1342-
13431340 if (ret < 0 )
1344- return ret ;
1341+ return NULL ;
13451342
13461343 pdata -> tplg_filename = tplg_filename ;
13471344 }
@@ -1351,35 +1348,36 @@ static int hda_sdw_machine_select(struct snd_sof_dev *sdev)
13511348 "SoundWire machine driver %s topology %s\n" ,
13521349 mach -> drv_name ,
13531350 pdata -> tplg_filename );
1354- } else {
1355- dev_info (sdev -> dev ,
1356- "No SoundWire machine driver found\n" );
1351+
1352+ return mach ;
13571353 }
1354+
1355+ dev_info (sdev -> dev , "No SoundWire machine driver found\n" );
13581356 }
13591357
1360- return 0 ;
1358+ return NULL ;
13611359}
13621360#else
1363- static int hda_sdw_machine_select (struct snd_sof_dev * sdev )
1361+ static struct snd_soc_acpi_mach * hda_sdw_machine_select (struct snd_sof_dev * sdev )
13641362{
1365- return 0 ;
1363+ return NULL ;
13661364}
13671365#endif
13681366
1369- void hda_set_mach_params (const struct snd_soc_acpi_mach * mach ,
1367+ void hda_set_mach_params (struct snd_soc_acpi_mach * mach ,
13701368 struct snd_sof_dev * sdev )
13711369{
13721370 struct snd_sof_pdata * pdata = sdev -> pdata ;
13731371 const struct sof_dev_desc * desc = pdata -> desc ;
13741372 struct snd_soc_acpi_mach_params * mach_params ;
13751373
1376- mach_params = ( struct snd_soc_acpi_mach_params * ) & mach -> mach_params ;
1374+ mach_params = & mach -> mach_params ;
13771375 mach_params -> platform = dev_name (sdev -> dev );
13781376 mach_params -> num_dai_drivers = desc -> ops -> num_drv ;
13791377 mach_params -> dai_drivers = desc -> ops -> drv ;
13801378}
13811379
1382- void hda_machine_select (struct snd_sof_dev * sdev )
1380+ struct snd_soc_acpi_mach * hda_machine_select (struct snd_sof_dev * sdev )
13831381{
13841382 struct snd_sof_pdata * sof_pdata = sdev -> pdata ;
13851383 const struct sof_dev_desc * desc = sof_pdata -> desc ;
@@ -1394,8 +1392,6 @@ void hda_machine_select(struct snd_sof_dev *sdev)
13941392 if (!sof_pdata -> tplg_filename )
13951393 sof_pdata -> tplg_filename = mach -> sof_tplg_filename ;
13961394
1397- sof_pdata -> machine = mach ;
1398-
13991395 if (mach -> link_mask ) {
14001396 mach -> mach_params .links = mach -> links ;
14011397 mach -> mach_params .link_mask = mach -> link_mask ;
@@ -1405,16 +1401,18 @@ void hda_machine_select(struct snd_sof_dev *sdev)
14051401 /*
14061402 * If I2S fails, try SoundWire
14071403 */
1408- hda_sdw_machine_select (sdev );
1404+ if (!mach )
1405+ mach = hda_sdw_machine_select (sdev );
14091406
14101407 /*
14111408 * Choose HDA generic machine driver if mach is NULL.
14121409 * Otherwise, set certain mach params.
14131410 */
1414- hda_generic_machine_select (sdev );
1415-
1416- if (!sof_pdata -> machine )
1411+ hda_generic_machine_select (sdev , & mach );
1412+ if (!mach )
14171413 dev_warn (sdev -> dev , "warning: No matching ASoC machine driver found\n" );
1414+
1415+ return mach ;
14181416}
14191417
14201418int hda_pci_intel_probe (struct pci_dev * pci , const struct pci_device_id * pci_id )
0 commit comments