diff options
author | Lars-Peter Clausen <lars@metafoo.de> | 2014-10-30 21:01:09 +0100 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2014-10-31 17:34:00 +0000 |
commit | 5efe89d9525f24f607079307d2d9510e30ba8590 (patch) | |
tree | 1d83e09474a4c44a37adf54c9fcae91609ee739f | |
parent | c1359ca303ee5125827c0d2a65f0c86d491dc993 (diff) | |
download | op-kernel-dev-5efe89d9525f24f607079307d2d9510e30ba8590.zip op-kernel-dev-5efe89d9525f24f607079307d2d9510e30ba8590.tar.gz |
ASoC: wm9713: Move driver state struct allocation to driver probe
Resources for the device should be allocated in the device driver probe
callback, rather than in the ASoC CODEC probe callback.
E.g. one advantage is that we can use device managed allocations.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r-- | sound/soc/codecs/wm9713.c | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/sound/soc/codecs/wm9713.c b/sound/soc/codecs/wm9713.c index ba8c276..2704783 100644 --- a/sound/soc/codecs/wm9713.c +++ b/sound/soc/codecs/wm9713.c @@ -1191,17 +1191,11 @@ static int wm9713_soc_resume(struct snd_soc_codec *codec) static int wm9713_soc_probe(struct snd_soc_codec *codec) { - struct wm9713_priv *wm9713; int ret = 0, reg; - wm9713 = kzalloc(sizeof(struct wm9713_priv), GFP_KERNEL); - if (wm9713 == NULL) - return -ENOMEM; - snd_soc_codec_set_drvdata(codec, wm9713); - ret = snd_soc_new_ac97_codec(codec, soc_ac97_ops, 0); if (ret < 0) - goto codec_err; + return ret; /* do a cold reset for the controller and then try * a warm reset followed by an optional cold reset for codec */ @@ -1220,16 +1214,12 @@ static int wm9713_soc_probe(struct snd_soc_codec *codec) reset_err: snd_soc_free_ac97_codec(codec); -codec_err: - kfree(wm9713); return ret; } static int wm9713_soc_remove(struct snd_soc_codec *codec) { - struct wm9713_priv *wm9713 = snd_soc_codec_get_drvdata(codec); snd_soc_free_ac97_codec(codec); - kfree(wm9713); return 0; } @@ -1256,6 +1246,14 @@ static struct snd_soc_codec_driver soc_codec_dev_wm9713 = { static int wm9713_probe(struct platform_device *pdev) { + struct wm9713_priv *wm9713; + + wm9713 = devm_kzalloc(&pdev->dev, sizeof(*wm9713), GFP_KERNEL); + if (wm9713 == NULL) + return -ENOMEM; + + platform_set_drvdata(pdev, wm9713); + return snd_soc_register_codec(&pdev->dev, &soc_codec_dev_wm9713, wm9713_dai, ARRAY_SIZE(wm9713_dai)); } |