Skip to content

Commit a92c1cd

Browse files
committed
ASoC: SOF: couple of cleanups
Merge series from Pierre-Louis Bossart <[email protected]>: 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.
2 parents f7c7eca + 60ded27 commit a92c1cd

File tree

11 files changed

+66
-59
lines changed

11 files changed

+66
-59
lines changed

include/sound/sof/debug.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ enum sof_ipc_dbg_mem_zone {
1919
SOF_IPC_MEM_ZONE_SYS_RUNTIME = 1, /**< System-runtime zone */
2020
SOF_IPC_MEM_ZONE_RUNTIME = 2, /**< Runtime zone */
2121
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 */
2224
};
2325

2426
/** ABI3.18 */

sound/soc/sof/amd/renoir.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ static struct snd_soc_dai_driver renoir_sof_dai[] = {
104104
},
105105
};
106106

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)
108108
{
109109
struct snd_sof_pdata *sof_pdata = sdev->pdata;
110110
const struct sof_dev_desc *desc = sof_pdata->desc;
@@ -113,12 +113,13 @@ static void amd_sof_machine_select(struct snd_sof_dev *sdev)
113113
mach = snd_soc_acpi_find_machine(desc->machines);
114114
if (!mach) {
115115
dev_warn(sdev->dev, "No matching ASoC machine driver found\n");
116-
return;
116+
return NULL;
117117
}
118118

119119
sof_pdata->tplg_filename = mach->sof_tplg_filename;
120120
sof_pdata->fw_filename = mach->fw_filename;
121-
sof_pdata->machine = mach;
121+
122+
return mach;
122123
}
123124

124125
/* AMD Renoir DSP ops */

sound/soc/sof/intel/atom.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ static const char *fixup_tplg_name(struct snd_sof_dev *sdev,
293293
return tplg_filename;
294294
}
295295

296-
void atom_machine_select(struct snd_sof_dev *sdev)
296+
struct snd_soc_acpi_mach *atom_machine_select(struct snd_sof_dev *sdev)
297297
{
298298
struct snd_sof_pdata *sof_pdata = sdev->pdata;
299299
const struct sof_dev_desc *desc = sof_pdata->desc;
@@ -304,7 +304,7 @@ void atom_machine_select(struct snd_sof_dev *sdev)
304304
mach = snd_soc_acpi_find_machine(desc->machines);
305305
if (!mach) {
306306
dev_warn(sdev->dev, "warning: No matching ASoC machine driver found\n");
307-
return;
307+
return NULL;
308308
}
309309

310310
pdev = to_platform_device(sdev->dev);
@@ -322,12 +322,13 @@ void atom_machine_select(struct snd_sof_dev *sdev)
322322
if (!tplg_filename) {
323323
dev_dbg(sdev->dev,
324324
"error: no topology filename\n");
325-
return;
325+
return NULL;
326326
}
327327

328328
sof_pdata->tplg_filename = tplg_filename;
329329
mach->mach_params.acpi_ipc_irq_index = desc->irqindex_host_ipc;
330-
sof_pdata->machine = mach;
330+
331+
return mach;
331332
}
332333
EXPORT_SYMBOL_NS(atom_machine_select, SND_SOC_SOF_INTEL_ATOM_HIFI_EP);
333334

@@ -402,14 +403,14 @@ struct snd_soc_dai_driver atom_dai[] = {
402403
};
403404
EXPORT_SYMBOL_NS(atom_dai, SND_SOC_SOF_INTEL_ATOM_HIFI_EP);
404405

405-
void atom_set_mach_params(const struct snd_soc_acpi_mach *mach,
406+
void atom_set_mach_params(struct snd_soc_acpi_mach *mach,
406407
struct snd_sof_dev *sdev)
407408
{
408409
struct snd_sof_pdata *pdata = sdev->pdata;
409410
const struct sof_dev_desc *desc = pdata->desc;
410411
struct snd_soc_acpi_mach_params *mach_params;
411412

412-
mach_params = (struct snd_soc_acpi_mach_params *)&mach->mach_params;
413+
mach_params = &mach->mach_params;
413414
mach_params->platform = dev_name(sdev->dev);
414415
mach_params->num_dai_drivers = desc->ops->num_drv;
415416
mach_params->dai_drivers = desc->ops->drv;

sound/soc/sof/intel/atom.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ int atom_run(struct snd_sof_dev *sdev);
6565
int atom_reset(struct snd_sof_dev *sdev);
6666
void atom_dump(struct snd_sof_dev *sdev, u32 flags);
6767

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,
7070
struct snd_sof_dev *sdev);
7171

7272
extern struct snd_soc_dai_driver atom_dai[];

sound/soc/sof/intel/bdw.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ static int bdw_probe(struct snd_sof_dev *sdev)
509509
return ret;
510510
}
511511

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)
513513
{
514514
struct snd_sof_pdata *sof_pdata = sdev->pdata;
515515
const struct sof_dev_desc *desc = sof_pdata->desc;
@@ -518,22 +518,23 @@ static void bdw_machine_select(struct snd_sof_dev *sdev)
518518
mach = snd_soc_acpi_find_machine(desc->machines);
519519
if (!mach) {
520520
dev_warn(sdev->dev, "warning: No matching ASoC machine driver found\n");
521-
return;
521+
return NULL;
522522
}
523523

524524
sof_pdata->tplg_filename = mach->sof_tplg_filename;
525525
mach->mach_params.acpi_ipc_irq_index = desc->irqindex_host_ipc;
526-
sof_pdata->machine = mach;
526+
527+
return mach;
527528
}
528529

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,
530531
struct snd_sof_dev *sdev)
531532
{
532533
struct snd_sof_pdata *pdata = sdev->pdata;
533534
const struct sof_dev_desc *desc = pdata->desc;
534535
struct snd_soc_acpi_mach_params *mach_params;
535536

536-
mach_params = (struct snd_soc_acpi_mach_params *)&mach->mach_params;
537+
mach_params = &mach->mach_params;
537538
mach_params->platform = dev_name(sdev->dev);
538539
mach_params->num_dai_drivers = desc->ops->num_drv;
539540
mach_params->dai_drivers = desc->ops->drv;

sound/soc/sof/intel/hda.c

Lines changed: 29 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -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

14201418
int hda_pci_intel_probe(struct pci_dev *pci, const struct pci_device_id *pci_id)

sound/soc/sof/intel/hda.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -728,8 +728,8 @@ extern const struct sof_intel_dsp_desc jsl_chip_info;
728728
extern const struct sof_intel_dsp_desc adls_chip_info;
729729

730730
/* 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,
733733
struct snd_sof_dev *sdev);
734734

735735
/* PCI driver selection and probe */

sound/soc/sof/ipc.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,8 @@ static void ipc_period_elapsed(struct snd_sof_dev *sdev, u32 msg_id)
623623

624624
if (spcm->pcm.compress)
625625
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)
627628
/* only inform ALSA for period_wakeup mode */
628629
snd_sof_pcm_period_elapsed(stream->substream);
629630
}

sound/soc/sof/ops.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -557,15 +557,17 @@ snd_sof_machine_unregister(struct snd_sof_dev *sdev, void *pdata)
557557
sof_ops(sdev)->machine_unregister(sdev, pdata);
558558
}
559559

560-
static inline void
560+
static inline struct snd_soc_acpi_mach *
561561
snd_sof_machine_select(struct snd_sof_dev *sdev)
562562
{
563563
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;
565567
}
566568

567569
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,
569571
struct snd_sof_dev *sdev)
570572
{
571573
if (sof_ops(sdev) && sof_ops(sdev)->set_mach_params)

sound/soc/sof/sof-audio.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,9 +1027,10 @@ int sof_machine_check(struct snd_sof_dev *sdev)
10271027
if (!IS_ENABLED(CONFIG_SND_SOC_SOF_FORCE_NOCODEC_MODE)) {
10281028

10291029
/* 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);
10331034
return 0;
10341035
}
10351036

@@ -1051,7 +1052,7 @@ int sof_machine_check(struct snd_sof_dev *sdev)
10511052
sof_pdata->tplg_filename = desc->nocodec_tplg_filename;
10521053

10531054
sof_pdata->machine = mach;
1054-
snd_sof_set_mach_params(sof_pdata->machine, sdev);
1055+
snd_sof_set_mach_params(mach, sdev);
10551056

10561057
return 0;
10571058
}

0 commit comments

Comments
 (0)