Skip to content

Commit 2b817a1

Browse files
committed
fixup! ASoC: SOF: Add support for dynamic pipelines
Fix the sof_widget_list_setup() to set up the pipeline widget for the pipeline that the widget belongs to first before setting up the widget. Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
1 parent 4d8e373 commit 2b817a1

File tree

1 file changed

+27
-24
lines changed

1 file changed

+27
-24
lines changed

sound/soc/sof/sof-audio.c

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,6 @@ int sof_widget_list_setup(struct snd_sof_dev *sdev, struct snd_sof_pcm *spcm, in
340340
{
341341
struct snd_soc_dapm_widget_list *list = spcm->stream[dir].list;
342342
struct snd_soc_dapm_widget *widget;
343-
int num_pipe_widgets = 0;
344343
int i, ret, num_widgets;
345344

346345
/* nothing to set up */
@@ -350,13 +349,30 @@ int sof_widget_list_setup(struct snd_sof_dev *sdev, struct snd_sof_pcm *spcm, in
350349
/* set up widgets in the list */
351350
for_each_dapm_widgets(list, num_widgets, widget) {
352351
struct snd_sof_widget *swidget = widget->dobj.private;
352+
struct snd_sof_widget *pipe_widget;
353353

354354
if (!swidget)
355355
continue;
356356

357-
ret = sof_widget_setup(sdev, swidget);
357+
/* set up the pipeline widget */
358+
pipe_widget = swidget->pipe_widget;
359+
if (!pipe_widget) {
360+
dev_err(sdev->dev, "error: no pipeline widget found for %s\n",
361+
swidget->widget->name);
362+
ret = -EINVAL;
363+
goto widget_free;
364+
}
365+
366+
ret = sof_widget_setup(sdev, pipe_widget);
358367
if (ret < 0)
359368
goto widget_free;
369+
370+
/* set up the widget */
371+
ret = sof_widget_setup(sdev, swidget);
372+
if (ret < 0) {
373+
sof_widget_free(sdev, pipe_widget);
374+
goto widget_free;
375+
}
360376
}
361377

362378
/*
@@ -367,7 +383,7 @@ int sof_widget_list_setup(struct snd_sof_dev *sdev, struct snd_sof_pcm *spcm, in
367383
if (ret < 0)
368384
goto widget_free;
369385

370-
/* setup pipeline widgets and complete pipelines */
386+
/* complete pipelines */
371387
for_each_dapm_widgets(list, i, widget) {
372388
struct snd_sof_widget *swidget = widget->dobj.private;
373389
struct snd_sof_widget *pipe_widget;
@@ -380,49 +396,36 @@ int sof_widget_list_setup(struct snd_sof_dev *sdev, struct snd_sof_pcm *spcm, in
380396
dev_err(sdev->dev, "error: no pipeline widget found for %s\n",
381397
swidget->widget->name);
382398
ret = -EINVAL;
383-
goto pipe_free;
399+
goto widget_free;
384400
}
385401

386-
ret = sof_widget_setup(sdev, pipe_widget);
387-
if (ret < 0)
388-
goto pipe_free;
389-
390-
num_pipe_widgets++;
391-
392402
if (pipe_widget->complete)
393403
continue;
394404

395405
pipe_widget->complete = snd_sof_complete_pipeline(sdev->dev, pipe_widget);
396406
if (pipe_widget->complete < 0) {
397407
ret = pipe_widget->complete;
398-
goto pipe_free;
408+
goto widget_free;
399409
}
400410
}
401411

402412
return 0;
403413

404-
pipe_free:
405-
/* free the pipe widgets that were set up successfully */
414+
widget_free:
415+
/* free all widgets that have been set up successfully */
406416
for_each_dapm_widgets(list, i, widget) {
407417
struct snd_sof_widget *swidget = widget->dobj.private;
418+
struct snd_sof_widget *pipe_widget;
408419

409420
if (!swidget)
410421
continue;
411422

412-
if (!num_pipe_widgets--)
413-
break;
414-
415-
sof_widget_free(sdev, swidget->pipe_widget);
416-
}
417-
418-
widget_free:
419-
/* free all widgets that have been set up successfully */
420-
for_each_dapm_widgets(list, i, widget) {
421423
if (!num_widgets--)
422424
break;
423425

424-
if (widget->dobj.private)
425-
sof_widget_free(sdev, widget->dobj.private);
426+
pipe_widget = swidget->pipe_widget;
427+
sof_widget_free(sdev, swidget);
428+
sof_widget_free(sdev, swidget->pipe_widget);
426429
}
427430

428431
return ret;

0 commit comments

Comments
 (0)