diff options
author | Lars-Peter Clausen <lars@metafoo.de> | 2014-08-20 07:08:47 -0400 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2014-09-06 09:44:33 -0400 |
commit | bd033808e2b160bab61cfe18b0ecb4ccc7809516 (patch) | |
tree | a64a0e538a06a411c65952813a8d600b816475f6 /sound/soc/intel/sst-haswell-pcm.c | |
parent | 1ee0beb985e097aa07fa7feab4e11ecf251d763c (diff) |
ASoC: sst-haswell-pcm: Alloc state struct in driver probe()
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>
Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'sound/soc/intel/sst-haswell-pcm.c')
-rw-r--r-- | sound/soc/intel/sst-haswell-pcm.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/sound/soc/intel/sst-haswell-pcm.c b/sound/soc/intel/sst-haswell-pcm.c index 61bf6da4bb02..1de095876857 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[] = { | |||
778 | 778 | ||
779 | static int hsw_pcm_probe(struct snd_soc_platform *platform) | 779 | static int hsw_pcm_probe(struct snd_soc_platform *platform) |
780 | { | 780 | { |
781 | struct hsw_priv_data *priv_data = snd_soc_platform_get_drvdata(platform); | ||
781 | struct sst_pdata *pdata = dev_get_platdata(platform->dev); | 782 | struct sst_pdata *pdata = dev_get_platdata(platform->dev); |
782 | struct hsw_priv_data *priv_data; | 783 | struct device *dma_dev = pdata->dma_dev; |
783 | struct device *dma_dev; | ||
784 | int i, ret = 0; | 784 | int i, ret = 0; |
785 | 785 | ||
786 | if (!pdata) | ||
787 | return -ENODEV; | ||
788 | |||
789 | dma_dev = pdata->dma_dev; | ||
790 | |||
791 | priv_data = devm_kzalloc(platform->dev, sizeof(*priv_data), GFP_KERNEL); | ||
792 | priv_data->hsw = pdata->dsp; | ||
793 | snd_soc_platform_set_drvdata(platform, priv_data); | ||
794 | |||
795 | /* allocate DSP buffer page tables */ | 786 | /* allocate DSP buffer page tables */ |
796 | for (i = 0; i < ARRAY_SIZE(hsw_dais); i++) { | 787 | for (i = 0; i < ARRAY_SIZE(hsw_dais); i++) { |
797 | 788 | ||
@@ -863,12 +854,23 @@ static const struct snd_soc_component_driver hsw_dai_component = { | |||
863 | static int hsw_pcm_dev_probe(struct platform_device *pdev) | 854 | static int hsw_pcm_dev_probe(struct platform_device *pdev) |
864 | { | 855 | { |
865 | struct sst_pdata *sst_pdata = dev_get_platdata(&pdev->dev); | 856 | struct sst_pdata *sst_pdata = dev_get_platdata(&pdev->dev); |
857 | struct hsw_priv_data *priv_data; | ||
866 | int ret; | 858 | int ret; |
867 | 859 | ||
860 | if (!sst_pdata) | ||
861 | return -EINVAL; | ||
862 | |||
863 | priv_data = devm_kzalloc(&pdev->dev, sizeof(*priv_data), GFP_KERNEL); | ||
864 | if (!priv_data) | ||
865 | return -ENOMEM; | ||
866 | |||
868 | ret = sst_hsw_dsp_init(&pdev->dev, sst_pdata); | 867 | ret = sst_hsw_dsp_init(&pdev->dev, sst_pdata); |
869 | if (ret < 0) | 868 | if (ret < 0) |
870 | return -ENODEV; | 869 | return -ENODEV; |
871 | 870 | ||
871 | priv_data->hsw = sst_pdata->dsp; | ||
872 | platform_set_drvdata(pdev, priv_data); | ||
873 | |||
872 | ret = snd_soc_register_platform(&pdev->dev, &hsw_soc_platform); | 874 | ret = snd_soc_register_platform(&pdev->dev, &hsw_soc_platform); |
873 | if (ret < 0) | 875 | if (ret < 0) |
874 | goto err_plat; | 876 | goto err_plat; |