LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Daniel Baluta <daniel.baluta@oss.nxp.com>
To: broonie@kernel.org
Cc: pierre-louis.bossart@linux.intel.com, lgirdwood@gmail.com,
	ranjani.sridharan@linux.intel.com, kai.vehmanen@linux.intel.com,
	alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org,
	daniel.baluta@nxp.com,
	Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Subject: [PATCH v2 01/12] ASoC: topology: change the complete op in snd_soc_tplg_ops to return int
Date: Fri, 17 Sep 2021 17:36:48 +0300	[thread overview]
Message-ID: <20210917143659.401102-2-daniel.baluta@oss.nxp.com> (raw)
In-Reply-To: <20210917143659.401102-1-daniel.baluta@oss.nxp.com>

From: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>

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: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
---
 include/sound/soc-topology.h           |  2 +-
 sound/soc/intel/skylake/skl-topology.c |  6 ++++--
 sound/soc/soc-topology.c               | 10 ++++++----
 sound/soc/sof/topology.c               | 12 ++++++++----
 4 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/include/sound/soc-topology.h b/include/sound/soc-topology.h
index 4afd667e124c..7f33de8ffd95 100644
--- a/include/sound/soc-topology.h
+++ b/include/sound/soc-topology.h
@@ -151,7 +151,7 @@ struct snd_soc_tplg_ops {
 		struct snd_soc_tplg_hdr *);
 
 	/* 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 */
 	int (*manifest)(struct snd_soc_component *, int index,
diff --git a/sound/soc/intel/skylake/skl-topology.c b/sound/soc/intel/skylake/skl-topology.c
index b036852d6889..89e4231304dd 100644
--- a/sound/soc/intel/skylake/skl-topology.c
+++ b/sound/soc/intel/skylake/skl-topology.c
@@ -3637,7 +3637,7 @@ static int skl_manifest_load(struct snd_soc_component *cmpnt, int index,
 	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_acpi_mach *mach;
@@ -3646,7 +3646,7 @@ static void skl_tplg_complete(struct snd_soc_component *component)
 
 	val = kmalloc(sizeof(*val), GFP_KERNEL);
 	if (!val)
-		return;
+		return -ENOMEM;
 
 	mach = dev_get_platdata(component->card->dev);
 	list_for_each_entry(dobj, &component->dobj_list, list) {
@@ -3671,7 +3671,9 @@ static void skl_tplg_complete(struct snd_soc_component *component)
 			}
 		}
 	}
+
 	kfree(val);
+	return 0;
 }
 
 static struct snd_soc_tplg_ops skl_tplg_ops  = {
diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c
index 73e1b7b48ce9..88f849b119da 100644
--- a/sound/soc/soc-topology.c
+++ b/sound/soc/soc-topology.c
@@ -78,7 +78,7 @@ struct soc_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 */
 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,
 }
 
 /* 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)
-		tplg->ops->complete(tplg->comp);
+		return tplg->ops->complete(tplg->comp);
+
+	return 0;
 }
 
 /* add a dynamic kcontrol */
@@ -2625,7 +2627,7 @@ static int soc_tplg_load(struct soc_tplg *tplg)
 
 	ret = soc_tplg_process_headers(tplg);
 	if (ret == 0)
-		soc_tplg_complete(tplg);
+		return soc_tplg_complete(tplg);
 
 	return ret;
 }
diff --git a/sound/soc/sof/topology.c b/sound/soc/sof/topology.c
index cc9585bfa4e9..96b8791f7cc1 100644
--- a/sound/soc/sof/topology.c
+++ b/sound/soc/sof/topology.c
@@ -3567,10 +3567,11 @@ int snd_sof_complete_pipeline(struct device *dev,
 }
 
 /* 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_widget *swidget;
+	int ret;
 
 	/* some widget types require completion notificattion */
 	list_for_each_entry(swidget, &sdev->widget_list, list) {
@@ -3579,8 +3580,11 @@ static void sof_complete(struct snd_soc_component *scomp)
 
 		switch (swidget->id) {
 		case snd_soc_dapm_scheduler:
-			swidget->complete =
-				snd_sof_complete_pipeline(scomp->dev, swidget);
+			ret = snd_sof_complete_pipeline(scomp->dev, swidget);
+			if (ret < 0)
+				return ret;
+
+			swidget->complete = ret;
 			break;
 		default:
 			break;
@@ -3590,7 +3594,7 @@ static void sof_complete(struct snd_soc_component *scomp)
 	 * cache initial values of SOF kcontrols by reading DSP value over
 	 * 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 */
-- 
2.27.0


  reply	other threads:[~2021-09-17 14:37 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-17 14:36 [PATCH v2 00/12] Add support for on demand pipeline setup/destroy Daniel Baluta
2021-09-17 14:36 ` Daniel Baluta [this message]
2021-09-17 14:36 ` [PATCH v2 02/12] ASoC: SOF: control: Add access field in struct snd_sof_control Daniel Baluta
2021-09-17 14:36 ` [PATCH v2 03/12] ASoC: SOF: topology: Add new token for dynamic pipeline Daniel Baluta
2021-09-17 14:36 ` [PATCH v2 04/12] ASoC: SOF: sof-audio: add helpers for widgets, kcontrols and dai config set up Daniel Baluta
2021-09-17 14:36 ` [PATCH v2 05/12] AsoC: dapm: export a couple of functions Daniel Baluta
2021-09-17 14:36 ` [PATCH v2 06/12] ASoC: SOF: Add new fields to snd_sof_route Daniel Baluta
2021-09-17 14:36 ` [PATCH v2 07/12] ASoC: SOF: restore kcontrols for widget during set up Daniel Baluta
2021-09-17 14:36 ` [PATCH v2 08/12] ASoC: SOF: Don't set up widgets during topology parsing Daniel Baluta
2021-09-17 14:36 ` [PATCH v2 09/12] ASoC: SOF: Introduce widget use_count Daniel Baluta
2021-09-17 14:36 ` [PATCH v2 10/12] ASoC: SOF: Intel: hda: make sure DAI widget is set up before IPC Daniel Baluta
     [not found]   ` <203bf6cd-6407-f01d-52c3-e399d06cb3f6@linux.intel.com>
2021-09-23 12:58     ` Pierre-Louis Bossart
2021-09-23 13:00       ` Péter Ujfalusi
2021-09-24  7:42         ` Daniel Baluta
2021-09-27  9:09           ` Péter Ujfalusi
2021-09-17 14:36 ` [PATCH v2 11/12] ASoC: SOF: Add support for dynamic pipelines Daniel Baluta
2021-09-17 14:36 ` [PATCH v2 12/12] ASoC: SOF: topology: Add kernel parameter for topology verification Daniel Baluta

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210917143659.401102-2-daniel.baluta@oss.nxp.com \
    --to=daniel.baluta@oss.nxp.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=daniel.baluta@nxp.com \
    --cc=guennadi.liakhovetski@linux.intel.com \
    --cc=kai.vehmanen@linux.intel.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=ranjani.sridharan@linux.intel.com \
    --subject='Re: [PATCH v2 01/12] ASoC: topology: change the complete op in snd_soc_tplg_ops to return int' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).