Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ASoC: SOF: couple of cleanups

Merge series from Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>:

Guennadi spotted inconsistencies with our 'const' handling, Ajit Kumar
flagged a missing check for a null pointer and we missed the
definition of debug zones.

+66 -59
+2
include/sound/sof/debug.h
··· 19 19 SOF_IPC_MEM_ZONE_SYS_RUNTIME = 1, /**< System-runtime zone */ 20 20 SOF_IPC_MEM_ZONE_RUNTIME = 2, /**< Runtime zone */ 21 21 SOF_IPC_MEM_ZONE_BUFFER = 3, /**< Buffer zone */ 22 + SOF_IPC_MEM_ZONE_RUNTIME_SHARED = 4, /**< System runtime zone */ 23 + SOF_IPC_MEM_ZONE_SYS_SHARED = 5, /**< System shared zone */ 22 24 }; 23 25 24 26 /** ABI3.18 */
+4 -3
sound/soc/sof/amd/renoir.c
··· 104 104 }, 105 105 }; 106 106 107 - static void amd_sof_machine_select(struct snd_sof_dev *sdev) 107 + static struct snd_soc_acpi_mach *amd_sof_machine_select(struct snd_sof_dev *sdev) 108 108 { 109 109 struct snd_sof_pdata *sof_pdata = sdev->pdata; 110 110 const struct sof_dev_desc *desc = sof_pdata->desc; ··· 113 113 mach = snd_soc_acpi_find_machine(desc->machines); 114 114 if (!mach) { 115 115 dev_warn(sdev->dev, "No matching ASoC machine driver found\n"); 116 - return; 116 + return NULL; 117 117 } 118 118 119 119 sof_pdata->tplg_filename = mach->sof_tplg_filename; 120 120 sof_pdata->fw_filename = mach->fw_filename; 121 - sof_pdata->machine = mach; 121 + 122 + return mach; 122 123 } 123 124 124 125 /* AMD Renoir DSP ops */
+7 -6
sound/soc/sof/intel/atom.c
··· 293 293 return tplg_filename; 294 294 } 295 295 296 - void atom_machine_select(struct snd_sof_dev *sdev) 296 + struct snd_soc_acpi_mach *atom_machine_select(struct snd_sof_dev *sdev) 297 297 { 298 298 struct snd_sof_pdata *sof_pdata = sdev->pdata; 299 299 const struct sof_dev_desc *desc = sof_pdata->desc; ··· 304 304 mach = snd_soc_acpi_find_machine(desc->machines); 305 305 if (!mach) { 306 306 dev_warn(sdev->dev, "warning: No matching ASoC machine driver found\n"); 307 - return; 307 + return NULL; 308 308 } 309 309 310 310 pdev = to_platform_device(sdev->dev); ··· 322 322 if (!tplg_filename) { 323 323 dev_dbg(sdev->dev, 324 324 "error: no topology filename\n"); 325 - return; 325 + return NULL; 326 326 } 327 327 328 328 sof_pdata->tplg_filename = tplg_filename; 329 329 mach->mach_params.acpi_ipc_irq_index = desc->irqindex_host_ipc; 330 - sof_pdata->machine = mach; 330 + 331 + return mach; 331 332 } 332 333 EXPORT_SYMBOL_NS(atom_machine_select, SND_SOC_SOF_INTEL_ATOM_HIFI_EP); 333 334 ··· 403 402 }; 404 403 EXPORT_SYMBOL_NS(atom_dai, SND_SOC_SOF_INTEL_ATOM_HIFI_EP); 405 404 406 - void atom_set_mach_params(const struct snd_soc_acpi_mach *mach, 405 + void atom_set_mach_params(struct snd_soc_acpi_mach *mach, 407 406 struct snd_sof_dev *sdev) 408 407 { 409 408 struct snd_sof_pdata *pdata = sdev->pdata; 410 409 const struct sof_dev_desc *desc = pdata->desc; 411 410 struct snd_soc_acpi_mach_params *mach_params; 412 411 413 - mach_params = (struct snd_soc_acpi_mach_params *)&mach->mach_params; 412 + mach_params = &mach->mach_params; 414 413 mach_params->platform = dev_name(sdev->dev); 415 414 mach_params->num_dai_drivers = desc->ops->num_drv; 416 415 mach_params->dai_drivers = desc->ops->drv;
+2 -2
sound/soc/sof/intel/atom.h
··· 65 65 int atom_reset(struct snd_sof_dev *sdev); 66 66 void atom_dump(struct snd_sof_dev *sdev, u32 flags); 67 67 68 - void atom_machine_select(struct snd_sof_dev *sdev); 69 - void atom_set_mach_params(const struct snd_soc_acpi_mach *mach, 68 + struct snd_soc_acpi_mach *atom_machine_select(struct snd_sof_dev *sdev); 69 + void atom_set_mach_params(struct snd_soc_acpi_mach *mach, 70 70 struct snd_sof_dev *sdev); 71 71 72 72 extern struct snd_soc_dai_driver atom_dai[];
+6 -5
sound/soc/sof/intel/bdw.c
··· 509 509 return ret; 510 510 } 511 511 512 - static void bdw_machine_select(struct snd_sof_dev *sdev) 512 + static struct snd_soc_acpi_mach *bdw_machine_select(struct snd_sof_dev *sdev) 513 513 { 514 514 struct snd_sof_pdata *sof_pdata = sdev->pdata; 515 515 const struct sof_dev_desc *desc = sof_pdata->desc; ··· 518 518 mach = snd_soc_acpi_find_machine(desc->machines); 519 519 if (!mach) { 520 520 dev_warn(sdev->dev, "warning: No matching ASoC machine driver found\n"); 521 - return; 521 + return NULL; 522 522 } 523 523 524 524 sof_pdata->tplg_filename = mach->sof_tplg_filename; 525 525 mach->mach_params.acpi_ipc_irq_index = desc->irqindex_host_ipc; 526 - sof_pdata->machine = mach; 526 + 527 + return mach; 527 528 } 528 529 529 - static void bdw_set_mach_params(const struct snd_soc_acpi_mach *mach, 530 + static void bdw_set_mach_params(struct snd_soc_acpi_mach *mach, 530 531 struct snd_sof_dev *sdev) 531 532 { 532 533 struct snd_sof_pdata *pdata = sdev->pdata; 533 534 const struct sof_dev_desc *desc = pdata->desc; 534 535 struct snd_soc_acpi_mach_params *mach_params; 535 536 536 - mach_params = (struct snd_soc_acpi_mach_params *)&mach->mach_params; 537 + mach_params = &mach->mach_params; 537 538 mach_params->platform = dev_name(sdev->dev); 538 539 mach_params->num_dai_drivers = desc->ops->num_drv; 539 540 mach_params->dai_drivers = desc->ops->drv;
+29 -31
sound/soc/sof/intel/hda.c
··· 1105 1105 } 1106 1106 1107 1107 #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) 1109 1110 { 1110 1111 struct hdac_bus *bus = sof_to_bus(sdev); 1111 1112 struct snd_soc_acpi_mach_params *mach_params; ··· 1138 1137 * - one HDMI codec, and/or 1139 1138 * - one external HDAudio codec 1140 1139 */ 1141 - if (!pdata->machine && codec_num <= 2) { 1140 + if (!*mach && codec_num <= 2) { 1142 1141 hda_mach = snd_soc_acpi_intel_hda_machines; 1143 1142 1144 1143 dev_info(bus->dev, "using HDA machine driver %s now\n", ··· 1153 1152 tplg_filename = hda_mach->sof_tplg_filename; 1154 1153 ret = dmic_topology_fixup(sdev, &tplg_filename, idisp_str, &dmic_num); 1155 1154 if (ret < 0) 1156 - return ret; 1155 + return; 1157 1156 1158 1157 hda_mach->mach_params.dmic_num = dmic_num; 1159 - pdata->machine = hda_mach; 1160 1158 pdata->tplg_filename = tplg_filename; 1161 1159 1162 1160 if (codec_num == 2) { ··· 1165 1165 */ 1166 1166 hda_mach->mach_params.link_mask = 0; 1167 1167 } 1168 + 1169 + *mach = hda_mach; 1168 1170 } 1169 1171 } 1170 1172 1171 1173 /* 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; 1175 1176 mach_params->codec_mask = bus->codec_mask; 1176 1177 mach_params->common_hdmi_codec_drv = hda_codec_use_common_hdmi; 1177 1178 } 1178 - 1179 - return 0; 1180 1179 } 1181 1180 #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) 1183 1183 { 1184 - return 0; 1185 1184 } 1186 1185 #endif 1187 1186 ··· 1263 1264 return true; 1264 1265 } 1265 1266 1266 - static int hda_sdw_machine_select(struct snd_sof_dev *sdev) 1267 + static struct snd_soc_acpi_mach *hda_sdw_machine_select(struct snd_sof_dev *sdev) 1267 1268 { 1268 1269 struct snd_sof_pdata *pdata = sdev->pdata; 1269 1270 const struct snd_soc_acpi_link_adr *link; ··· 1281 1282 * machines, for mixed cases with I2C/I2S the detection relies 1282 1283 * on the HID list. 1283 1284 */ 1284 - if (link_mask && !pdata->machine) { 1285 + if (link_mask) { 1285 1286 for (mach = pdata->desc->alt_machines; 1286 1287 mach && mach->link_mask; mach++) { 1287 1288 /* ··· 1316 1317 if (mach && mach->link_mask) { 1317 1318 int dmic_num = 0; 1318 1319 1319 - pdata->machine = mach; 1320 1320 mach->mach_params.links = mach->links; 1321 1321 mach->mach_params.link_mask = mach->link_mask; 1322 1322 mach->mach_params.platform = dev_name(sdev->dev); ··· 1337 1339 int ret; 1338 1340 1339 1341 ret = dmic_topology_fixup(sdev, &tplg_filename, "", &dmic_num); 1340 - 1341 1342 if (ret < 0) 1342 - return ret; 1343 + return NULL; 1343 1344 1344 1345 pdata->tplg_filename = tplg_filename; 1345 1346 } ··· 1348 1351 "SoundWire machine driver %s topology %s\n", 1349 1352 mach->drv_name, 1350 1353 pdata->tplg_filename); 1351 - } else { 1352 - dev_info(sdev->dev, 1353 - "No SoundWire machine driver found\n"); 1354 + 1355 + return mach; 1354 1356 } 1357 + 1358 + dev_info(sdev->dev, "No SoundWire machine driver found\n"); 1355 1359 } 1356 1360 1357 - return 0; 1361 + return NULL; 1358 1362 } 1359 1363 #else 1360 - static int hda_sdw_machine_select(struct snd_sof_dev *sdev) 1364 + static struct snd_soc_acpi_mach *hda_sdw_machine_select(struct snd_sof_dev *sdev) 1361 1365 { 1362 - return 0; 1366 + return NULL; 1363 1367 } 1364 1368 #endif 1365 1369 1366 - void hda_set_mach_params(const struct snd_soc_acpi_mach *mach, 1370 + void hda_set_mach_params(struct snd_soc_acpi_mach *mach, 1367 1371 struct snd_sof_dev *sdev) 1368 1372 { 1369 1373 struct snd_sof_pdata *pdata = sdev->pdata; 1370 1374 const struct sof_dev_desc *desc = pdata->desc; 1371 1375 struct snd_soc_acpi_mach_params *mach_params; 1372 1376 1373 - mach_params = (struct snd_soc_acpi_mach_params *)&mach->mach_params; 1377 + mach_params = &mach->mach_params; 1374 1378 mach_params->platform = dev_name(sdev->dev); 1375 1379 mach_params->num_dai_drivers = desc->ops->num_drv; 1376 1380 mach_params->dai_drivers = desc->ops->drv; 1377 1381 } 1378 1382 1379 - void hda_machine_select(struct snd_sof_dev *sdev) 1383 + struct snd_soc_acpi_mach *hda_machine_select(struct snd_sof_dev *sdev) 1380 1384 { 1381 1385 struct snd_sof_pdata *sof_pdata = sdev->pdata; 1382 1386 const struct sof_dev_desc *desc = sof_pdata->desc; ··· 1392 1394 if (!sof_pdata->tplg_filename) 1393 1395 sof_pdata->tplg_filename = mach->sof_tplg_filename; 1394 1396 1395 - sof_pdata->machine = mach; 1396 - 1397 1397 if (mach->link_mask) { 1398 1398 mach->mach_params.links = mach->links; 1399 1399 mach->mach_params.link_mask = mach->link_mask; ··· 1401 1405 /* 1402 1406 * If I2S fails, try SoundWire 1403 1407 */ 1404 - hda_sdw_machine_select(sdev); 1408 + if (!mach) 1409 + mach = hda_sdw_machine_select(sdev); 1405 1410 1406 1411 /* 1407 1412 * Choose HDA generic machine driver if mach is NULL. 1408 1413 * Otherwise, set certain mach params. 1409 1414 */ 1410 - hda_generic_machine_select(sdev); 1411 - 1412 - if (!sof_pdata->machine) 1415 + hda_generic_machine_select(sdev, &mach); 1416 + if (!mach) 1413 1417 dev_warn(sdev->dev, "warning: No matching ASoC machine driver found\n"); 1418 + 1419 + return mach; 1414 1420 } 1415 1421 1416 1422 int hda_pci_intel_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)
+2 -2
sound/soc/sof/intel/hda.h
··· 728 728 extern const struct sof_intel_dsp_desc adls_chip_info; 729 729 730 730 /* machine driver select */ 731 - void hda_machine_select(struct snd_sof_dev *sdev); 732 - void hda_set_mach_params(const struct snd_soc_acpi_mach *mach, 731 + struct snd_soc_acpi_mach *hda_machine_select(struct snd_sof_dev *sdev); 732 + void hda_set_mach_params(struct snd_soc_acpi_mach *mach, 733 733 struct snd_sof_dev *sdev); 734 734 735 735 /* PCI driver selection and probe */
+2 -1
sound/soc/sof/ipc.c
··· 623 623 624 624 if (spcm->pcm.compress) 625 625 snd_sof_compr_fragment_elapsed(stream->cstream); 626 - else if (!stream->substream->runtime->no_period_wakeup) 626 + else if (stream->substream->runtime && 627 + !stream->substream->runtime->no_period_wakeup) 627 628 /* only inform ALSA for period_wakeup mode */ 628 629 snd_sof_pcm_period_elapsed(stream->substream); 629 630 }
+5 -3
sound/soc/sof/ops.h
··· 557 557 sof_ops(sdev)->machine_unregister(sdev, pdata); 558 558 } 559 559 560 - static inline void 560 + static inline struct snd_soc_acpi_mach * 561 561 snd_sof_machine_select(struct snd_sof_dev *sdev) 562 562 { 563 563 if (sof_ops(sdev) && sof_ops(sdev)->machine_select) 564 - sof_ops(sdev)->machine_select(sdev); 564 + return sof_ops(sdev)->machine_select(sdev); 565 + 566 + return NULL; 565 567 } 566 568 567 569 static inline void 568 - snd_sof_set_mach_params(const struct snd_soc_acpi_mach *mach, 570 + snd_sof_set_mach_params(struct snd_soc_acpi_mach *mach, 569 571 struct snd_sof_dev *sdev) 570 572 { 571 573 if (sof_ops(sdev) && sof_ops(sdev)->set_mach_params)
+5 -4
sound/soc/sof/sof-audio.c
··· 1027 1027 if (!IS_ENABLED(CONFIG_SND_SOC_SOF_FORCE_NOCODEC_MODE)) { 1028 1028 1029 1029 /* find machine */ 1030 - snd_sof_machine_select(sdev); 1031 - if (sof_pdata->machine) { 1032 - snd_sof_set_mach_params(sof_pdata->machine, sdev); 1030 + mach = snd_sof_machine_select(sdev); 1031 + if (mach) { 1032 + sof_pdata->machine = mach; 1033 + snd_sof_set_mach_params(mach, sdev); 1033 1034 return 0; 1034 1035 } 1035 1036 ··· 1052 1051 sof_pdata->tplg_filename = desc->nocodec_tplg_filename; 1053 1052 1054 1053 sof_pdata->machine = mach; 1055 - snd_sof_set_mach_params(sof_pdata->machine, sdev); 1054 + snd_sof_set_mach_params(mach, sdev); 1056 1055 1057 1056 return 0; 1058 1057 }
+2 -2
sound/soc/sof/sof-priv.h
··· 293 293 void *pdata); /* optional */ 294 294 void (*machine_unregister)(struct snd_sof_dev *sdev, 295 295 void *pdata); /* optional */ 296 - void (*machine_select)(struct snd_sof_dev *sdev); /* optional */ 297 - void (*set_mach_params)(const struct snd_soc_acpi_mach *mach, 296 + struct snd_soc_acpi_mach * (*machine_select)(struct snd_sof_dev *sdev); /* optional */ 297 + void (*set_mach_params)(struct snd_soc_acpi_mach *mach, 298 298 struct snd_sof_dev *sdev); /* optional */ 299 299 300 300 /* DAI ops */