Skip to content

Commit c1619ea

Browse files
committed
ASoC: SOF: sof-audio: Fixes for widget prepare and
Merge series from Peter Ujfalusi <[email protected]>: This series contains one fix (first patch) followed by a nice to have safety belts in case we get a widget from topology which is not handled by SOF and will not have corresponding swidget associated with.
2 parents fcc4348 + cc755b4 commit c1619ea

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

sound/soc/sof/sof-audio.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -271,16 +271,17 @@ sof_unprepare_widgets_in_path(struct snd_sof_dev *sdev, struct snd_soc_dapm_widg
271271
struct snd_sof_widget *swidget = widget->dobj.private;
272272
struct snd_soc_dapm_path *p;
273273

274-
/* return if the widget is in use or if it is already unprepared */
275-
if (!swidget->prepared || swidget->use_count > 1)
276-
return;
274+
/* skip if the widget is in use or if it is already unprepared */
275+
if (!swidget || !swidget->prepared || swidget->use_count > 0)
276+
goto sink_unprepare;
277277

278278
if (widget_ops[widget->id].ipc_unprepare)
279279
/* unprepare the source widget */
280280
widget_ops[widget->id].ipc_unprepare(swidget);
281281

282282
swidget->prepared = false;
283283

284+
sink_unprepare:
284285
/* unprepare all widgets in the sink paths */
285286
snd_soc_dapm_widget_for_each_sink_path(widget, p) {
286287
if (!p->walking && p->sink->dobj.private) {
@@ -303,7 +304,7 @@ sof_prepare_widgets_in_path(struct snd_sof_dev *sdev, struct snd_soc_dapm_widget
303304
struct snd_soc_dapm_path *p;
304305
int ret;
305306

306-
if (!widget_ops[widget->id].ipc_prepare || swidget->prepared)
307+
if (!swidget || !widget_ops[widget->id].ipc_prepare || swidget->prepared)
307308
goto sink_prepare;
308309

309310
/* prepare the source widget */

0 commit comments

Comments
 (0)