public inbox for linux-sound@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
To: lgirdwood@gmail.com, broonie@kernel.org
Cc: alsa-devel@alsa-project.org, linux-sound@vger.kernel.org,
	pierre-louis.bossart@linux.intel.com,
	kai.vehmanen@linux.intel.com, ranjani.sridharan@linux.intel.com
Subject: [PATCH 11/13] ASoC: SOF: core: Add helper for initialization of paths, ops
Date: Wed, 29 Nov 2023 14:53:25 +0200	[thread overview]
Message-ID: <20231129125327.23708-12-peter.ujfalusi@linux.intel.com> (raw)
In-Reply-To: <20231129125327.23708-1-peter.ujfalusi@linux.intel.com>

Add sof_init_environment() as a helper function to contain path and ops
initialization.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
---
 sound/soc/sof/core.c | 56 +++++++++++++++++++++++++++-----------------
 1 file changed, 34 insertions(+), 22 deletions(-)

diff --git a/sound/soc/sof/core.c b/sound/soc/sof/core.c
index f1a083de9f9e..a2e9506e0f85 100644
--- a/sound/soc/sof/core.c
+++ b/sound/soc/sof/core.c
@@ -265,6 +265,38 @@ static int sof_select_ipc_and_paths(struct snd_sof_dev *sdev)
 	return 0;
 }
 
+static int sof_init_environment(struct snd_sof_dev *sdev)
+{
+	int ret;
+
+	ret = sof_select_ipc_and_paths(sdev);
+	if (ret)
+		return ret;
+
+	/* init ops, if necessary */
+	ret = sof_ops_init(sdev);
+	if (ret < 0)
+		return ret;
+
+	/* check all mandatory ops */
+	if (!sof_ops(sdev) || !sof_ops(sdev)->probe) {
+		dev_err(sdev->dev, "missing mandatory ops\n");
+		sof_ops_free(sdev);
+		return -EINVAL;
+	}
+
+	if (!sdev->dspless_mode_selected &&
+	    (!sof_ops(sdev)->run || !sof_ops(sdev)->block_read ||
+	     !sof_ops(sdev)->block_write || !sof_ops(sdev)->send_msg ||
+	     !sof_ops(sdev)->load_firmware || !sof_ops(sdev)->ipc_msg_data)) {
+		dev_err(sdev->dev, "missing mandatory DSP ops\n");
+		sof_ops_free(sdev);
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
 /*
  *			FW Boot State Transition Diagram
  *
@@ -503,31 +535,11 @@ int snd_sof_device_probe(struct device *dev, struct snd_sof_pdata *plat_data)
 		}
 	}
 
-	ret = sof_select_ipc_and_paths(sdev);
+	/* Initialize loadable file paths and check the environment validity */
+	ret = sof_init_environment(sdev);
 	if (ret)
 		return ret;
 
-	/* init ops, if necessary */
-	ret = sof_ops_init(sdev);
-	if (ret < 0)
-		return ret;
-
-	/* check all mandatory ops */
-	if (!sof_ops(sdev) || !sof_ops(sdev)->probe) {
-		sof_ops_free(sdev);
-		dev_err(dev, "missing mandatory ops\n");
-		return -EINVAL;
-	}
-
-	if (!sdev->dspless_mode_selected &&
-	    (!sof_ops(sdev)->run || !sof_ops(sdev)->block_read ||
-	     !sof_ops(sdev)->block_write || !sof_ops(sdev)->send_msg ||
-	     !sof_ops(sdev)->load_firmware || !sof_ops(sdev)->ipc_msg_data)) {
-		sof_ops_free(sdev);
-		dev_err(dev, "missing mandatory DSP ops\n");
-		return -EINVAL;
-	}
-
 	INIT_LIST_HEAD(&sdev->pcm_list);
 	INIT_LIST_HEAD(&sdev->kcontrol_list);
 	INIT_LIST_HEAD(&sdev->widget_list);
-- 
2.43.0


  parent reply	other threads:[~2023-11-29 12:53 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-29 12:53 [PATCH 00/13] ASoC: SOF: IPC path handling and fallback support Peter Ujfalusi
2023-11-29 12:53 ` [PATCH 01/13] ASoC: SOF: Move sof_of_machine_select() to sof-of-dev.c from sof-audio.c Peter Ujfalusi
2023-11-29 12:53 ` [PATCH 02/13] ASoC: SOF: Move sof_machine_* functions from sof-audio.c to core.c Peter Ujfalusi
2023-11-29 12:53 ` [PATCH 03/13] ASoC: SOF: Add placeholder for platform IPC type and path overrides Peter Ujfalusi
2023-11-29 12:53 ` [PATCH 04/13] ASoC: SOF: sof-acpi-dev: Save the default " Peter Ujfalusi
2023-11-29 12:53 ` [PATCH 05/13] ASoC: SOF: sof-of-dev: " Peter Ujfalusi
2023-11-29 12:53 ` [PATCH 06/13] ASoC: SOF: sof-pci-dev: " Peter Ujfalusi
2023-11-29 12:53 ` [PATCH 07/13] ASoC: SOF: core: Implement firmware, topology path setup in core Peter Ujfalusi
2023-11-29 12:53 ` [PATCH 08/13] ASoC: SOF: sof-acpi-dev: Rely on core to create the file paths Peter Ujfalusi
2023-11-29 12:53 ` [PATCH 09/13] ASoC: SOF: sof-of-dev: " Peter Ujfalusi
2023-11-29 12:53 ` [PATCH 10/13] ASoC: SOF: sof-pci-dev: " Peter Ujfalusi
2023-11-29 12:53 ` Peter Ujfalusi [this message]
2023-11-29 12:53 ` [PATCH 12/13] ASoC: SOF: Intel: Do not use resource managed allocation for ipc4_data Peter Ujfalusi
2023-11-29 12:53 ` [PATCH 13/13] ASoC: SOF: core: Implement IPC version fallback if firmware files are missing Peter Ujfalusi
2023-11-30 14:19 ` [PATCH 00/13] ASoC: SOF: IPC path handling and fallback support Mark Brown

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=20231129125327.23708-12-peter.ujfalusi@linux.intel.com \
    --to=peter.ujfalusi@linux.intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=kai.vehmanen@linux.intel.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-sound@vger.kernel.org \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=ranjani.sridharan@linux.intel.com \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox