alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
From: Lars-Peter Clausen <lars@metafoo.de>
To: Mark Brown <broonie@kernel.org>, Liam Girdwood <lgirdwood@gmail.com>
Cc: Vinod Koul <vinod.koul@intel.com>,
	alsa-devel@alsa-project.org, Lars-Peter Clausen <lars@metafoo.de>,
	"Subhransu S. Prusty" <subhransu.s.prusty@intel.com>
Subject: [PATCH 2/4] ASoC: sst-haswell-pcm: Alloc state struct in driver probe()
Date: Wed, 20 Aug 2014 13:08:47 +0200	[thread overview]
Message-ID: <1408532929-26978-3-git-send-email-lars@metafoo.de> (raw)
In-Reply-To: <1408532929-26978-1-git-send-email-lars@metafoo.de>

Resource allocations should happen in driver probe callback rather than in
snd_soc_platform probe functions. Especially if the resource is device
managed. The snd_soc_* probe/remove functions are mainly intended to be used
for things that require the component to be already bound to a card.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 sound/soc/intel/sst-haswell-pcm.c | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/sound/soc/intel/sst-haswell-pcm.c b/sound/soc/intel/sst-haswell-pcm.c
index 61bf6da..1de0958 100644
--- a/sound/soc/intel/sst-haswell-pcm.c
+++ b/sound/soc/intel/sst-haswell-pcm.c
@@ -778,20 +778,11 @@ static const struct snd_soc_dapm_route graph[] = {
 
 static int hsw_pcm_probe(struct snd_soc_platform *platform)
 {
+	struct hsw_priv_data *priv_data = snd_soc_platform_get_drvdata(platform);
 	struct sst_pdata *pdata = dev_get_platdata(platform->dev);
-	struct hsw_priv_data *priv_data;
-	struct device *dma_dev;
+	struct device *dma_dev = pdata->dma_dev;
 	int i, ret = 0;
 
-	if (!pdata)
-		return -ENODEV;
-
-	dma_dev = pdata->dma_dev;
-
-	priv_data = devm_kzalloc(platform->dev, sizeof(*priv_data), GFP_KERNEL);
-	priv_data->hsw = pdata->dsp;
-	snd_soc_platform_set_drvdata(platform, priv_data);
-
 	/* allocate DSP buffer page tables */
 	for (i = 0; i < ARRAY_SIZE(hsw_dais); i++) {
 
@@ -863,12 +854,23 @@ static const struct snd_soc_component_driver hsw_dai_component = {
 static int hsw_pcm_dev_probe(struct platform_device *pdev)
 {
 	struct sst_pdata *sst_pdata = dev_get_platdata(&pdev->dev);
+	struct hsw_priv_data *priv_data;
 	int ret;
 
+	if (!sst_pdata)
+		return -EINVAL;
+
+	priv_data = devm_kzalloc(&pdev->dev, sizeof(*priv_data), GFP_KERNEL);
+	if (!priv_data)
+		return -ENOMEM;
+
 	ret = sst_hsw_dsp_init(&pdev->dev, sst_pdata);
 	if (ret < 0)
 		return -ENODEV;
 
+	priv_data->hsw = sst_pdata->dsp;
+	platform_set_drvdata(pdev, priv_data);
+
 	ret = snd_soc_register_platform(&pdev->dev, &hsw_soc_platform);
 	if (ret < 0)
 		goto err_plat;
-- 
1.8.0

  parent reply	other threads:[~2014-08-20 11:08 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-20 11:08 [PATCH 0/4] ASoC: sst-haswell-pcm: Move controls and DAPM elements to component Lars-Peter Clausen
2014-08-20 11:08 ` [PATCH 1/4] ASoC: Add snd_soc_component_{get, set}_drvdata() Lars-Peter Clausen
2014-09-03 12:22   ` Vinod Koul
2014-09-03 19:06     ` Lars-Peter Clausen
2014-09-04  6:33       ` Vinod Koul
2014-08-20 11:08 ` Lars-Peter Clausen [this message]
2014-08-20 11:08 ` [PATCH 3/4] ASoC: sst-haswell-pcm: Move controls and DAPM elements to component Lars-Peter Clausen
2014-08-20 11:08 ` [PATCH 4/4] ASoC: Remove table based DAPM/control setup support from snd_soc_platform_driver Lars-Peter Clausen
2014-09-06 13:48 ` [PATCH 0/4] ASoC: sst-haswell-pcm: Move controls and DAPM elements to component 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=1408532929-26978-3-git-send-email-lars@metafoo.de \
    --to=lars@metafoo.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=subhransu.s.prusty@intel.com \
    --cc=vinod.koul@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;
as well as URLs for NNTP newsgroup(s).