Commit 415717e1 authored by Ranjani Sridharan's avatar Ranjani Sridharan Committed by Mark Brown

ASoC: topology: change the complete op in snd_soc_tplg_ops to return int

In the SOF driver, the operations performed in the complete callback
can fail and therefore topology loading should return an error in
such cases. So, change the signature of the complete op
in struct snd_soc_tplg_ops to return an int to return the error.

Also, amend the complete callback functions in the SOF driver and
the SKL driver to conform with the new signature.
Signed-off-by: default avatarRanjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: default avatarGuennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Reviewed-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: default avatarKai Vehmanen <kai.vehmanen@linux.intel.com>
Signed-off-by: default avatarDaniel Baluta <daniel.baluta@nxp.com>
Signed-off-by: default avatarPeter Ujfalusi <peter.ujfalusi@linux.intel.com>
Link: https://lore.kernel.org/r/20210927120517.20505-2-peter.ujfalusi@linux.intel.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 57589f82
...@@ -151,7 +151,7 @@ struct snd_soc_tplg_ops { ...@@ -151,7 +151,7 @@ struct snd_soc_tplg_ops {
struct snd_soc_tplg_hdr *); struct snd_soc_tplg_hdr *);
/* completion - called at completion of firmware loading */ /* completion - called at completion of firmware loading */
void (*complete)(struct snd_soc_component *); int (*complete)(struct snd_soc_component *comp);
/* manifest - optional to inform component of manifest */ /* manifest - optional to inform component of manifest */
int (*manifest)(struct snd_soc_component *, int index, int (*manifest)(struct snd_soc_component *, int index,
......
...@@ -3637,7 +3637,7 @@ static int skl_manifest_load(struct snd_soc_component *cmpnt, int index, ...@@ -3637,7 +3637,7 @@ static int skl_manifest_load(struct snd_soc_component *cmpnt, int index,
return 0; return 0;
} }
static void skl_tplg_complete(struct snd_soc_component *component) static int skl_tplg_complete(struct snd_soc_component *component)
{ {
struct snd_soc_dobj *dobj; struct snd_soc_dobj *dobj;
struct snd_soc_acpi_mach *mach; struct snd_soc_acpi_mach *mach;
...@@ -3646,7 +3646,7 @@ static void skl_tplg_complete(struct snd_soc_component *component) ...@@ -3646,7 +3646,7 @@ static void skl_tplg_complete(struct snd_soc_component *component)
val = kmalloc(sizeof(*val), GFP_KERNEL); val = kmalloc(sizeof(*val), GFP_KERNEL);
if (!val) if (!val)
return; return -ENOMEM;
mach = dev_get_platdata(component->card->dev); mach = dev_get_platdata(component->card->dev);
list_for_each_entry(dobj, &component->dobj_list, list) { list_for_each_entry(dobj, &component->dobj_list, list) {
...@@ -3671,7 +3671,9 @@ static void skl_tplg_complete(struct snd_soc_component *component) ...@@ -3671,7 +3671,9 @@ static void skl_tplg_complete(struct snd_soc_component *component)
} }
} }
} }
kfree(val); kfree(val);
return 0;
} }
static struct snd_soc_tplg_ops skl_tplg_ops = { static struct snd_soc_tplg_ops skl_tplg_ops = {
......
...@@ -78,7 +78,7 @@ struct soc_tplg { ...@@ -78,7 +78,7 @@ struct soc_tplg {
}; };
static int soc_tplg_process_headers(struct soc_tplg *tplg); static int soc_tplg_process_headers(struct soc_tplg *tplg);
static void soc_tplg_complete(struct soc_tplg *tplg); static int soc_tplg_complete(struct soc_tplg *tplg);
/* check we dont overflow the data for this control chunk */ /* check we dont overflow the data for this control chunk */
static int soc_tplg_check_elem_count(struct soc_tplg *tplg, size_t elem_size, static int soc_tplg_check_elem_count(struct soc_tplg *tplg, size_t elem_size,
...@@ -312,10 +312,12 @@ static int soc_tplg_dai_link_load(struct soc_tplg *tplg, ...@@ -312,10 +312,12 @@ static int soc_tplg_dai_link_load(struct soc_tplg *tplg,
} }
/* tell the component driver that all firmware has been loaded in this request */ /* tell the component driver that all firmware has been loaded in this request */
static void soc_tplg_complete(struct soc_tplg *tplg) static int soc_tplg_complete(struct soc_tplg *tplg)
{ {
if (tplg->ops && tplg->ops->complete) if (tplg->ops && tplg->ops->complete)
tplg->ops->complete(tplg->comp); return tplg->ops->complete(tplg->comp);
return 0;
} }
/* add a dynamic kcontrol */ /* add a dynamic kcontrol */
...@@ -2625,7 +2627,7 @@ static int soc_tplg_load(struct soc_tplg *tplg) ...@@ -2625,7 +2627,7 @@ static int soc_tplg_load(struct soc_tplg *tplg)
ret = soc_tplg_process_headers(tplg); ret = soc_tplg_process_headers(tplg);
if (ret == 0) if (ret == 0)
soc_tplg_complete(tplg); return soc_tplg_complete(tplg);
return ret; return ret;
} }
......
...@@ -3567,10 +3567,11 @@ int snd_sof_complete_pipeline(struct device *dev, ...@@ -3567,10 +3567,11 @@ int snd_sof_complete_pipeline(struct device *dev,
} }
/* completion - called at completion of firmware loading */ /* completion - called at completion of firmware loading */
static void sof_complete(struct snd_soc_component *scomp) static int sof_complete(struct snd_soc_component *scomp)
{ {
struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp); struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp);
struct snd_sof_widget *swidget; struct snd_sof_widget *swidget;
int ret;
/* some widget types require completion notificattion */ /* some widget types require completion notificattion */
list_for_each_entry(swidget, &sdev->widget_list, list) { list_for_each_entry(swidget, &sdev->widget_list, list) {
...@@ -3579,8 +3580,11 @@ static void sof_complete(struct snd_soc_component *scomp) ...@@ -3579,8 +3580,11 @@ static void sof_complete(struct snd_soc_component *scomp)
switch (swidget->id) { switch (swidget->id) {
case snd_soc_dapm_scheduler: case snd_soc_dapm_scheduler:
swidget->complete = ret = snd_sof_complete_pipeline(scomp->dev, swidget);
snd_sof_complete_pipeline(scomp->dev, swidget); if (ret < 0)
return ret;
swidget->complete = ret;
break; break;
default: default:
break; break;
...@@ -3590,7 +3594,7 @@ static void sof_complete(struct snd_soc_component *scomp) ...@@ -3590,7 +3594,7 @@ static void sof_complete(struct snd_soc_component *scomp)
* cache initial values of SOF kcontrols by reading DSP value over * cache initial values of SOF kcontrols by reading DSP value over
* IPC. It may be overwritten by alsa-mixer after booting up * IPC. It may be overwritten by alsa-mixer after booting up
*/ */
snd_sof_cache_kcontrol_val(scomp); return snd_sof_cache_kcontrol_val(scomp);
} }
/* manifest - optional to inform component of manifest */ /* manifest - optional to inform component of manifest */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment