diff options
author | Robert Jarzmik <robert.jarzmik@free.fr> | 2017-09-13 15:37:21 -0400 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2017-09-19 12:09:35 -0400 |
commit | c6e46e52b7b3301dda529830226e578cf773151c (patch) | |
tree | 5e5b363c185d8b3df8c03655c47c645515349fc6 | |
parent | 2ed1a8e0ce8db6d36f849526db61ce3c85a9f8d1 (diff) |
ASoC: wm9705: add private structure
Add a private data structure. This is a preparation for a codec which
would need an another data on top of snd_ac97, which will be the case
when an MFD wm97xx device will probe wm9705.
Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
Acked-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r-- | sound/soc/codecs/wm9705.c | 36 |
1 files changed, 24 insertions, 12 deletions
diff --git a/sound/soc/codecs/wm9705.c b/sound/soc/codecs/wm9705.c index f6d5c0f2aea5..08477d040028 100644 --- a/sound/soc/codecs/wm9705.c +++ b/sound/soc/codecs/wm9705.c | |||
@@ -24,6 +24,10 @@ | |||
24 | #define WM9705_VENDOR_ID 0x574d4c05 | 24 | #define WM9705_VENDOR_ID 0x574d4c05 |
25 | #define WM9705_VENDOR_ID_MASK 0xffffffff | 25 | #define WM9705_VENDOR_ID_MASK 0xffffffff |
26 | 26 | ||
27 | struct wm9705_priv { | ||
28 | struct snd_ac97 *ac97; | ||
29 | }; | ||
30 | |||
27 | static const struct reg_default wm9705_reg_defaults[] = { | 31 | static const struct reg_default wm9705_reg_defaults[] = { |
28 | { 0x02, 0x8000 }, | 32 | { 0x02, 0x8000 }, |
29 | { 0x04, 0x8000 }, | 33 | { 0x04, 0x8000 }, |
@@ -292,10 +296,10 @@ static int wm9705_soc_suspend(struct snd_soc_codec *codec) | |||
292 | 296 | ||
293 | static int wm9705_soc_resume(struct snd_soc_codec *codec) | 297 | static int wm9705_soc_resume(struct snd_soc_codec *codec) |
294 | { | 298 | { |
295 | struct snd_ac97 *ac97 = snd_soc_codec_get_drvdata(codec); | 299 | struct wm9705_priv *wm9705 = snd_soc_codec_get_drvdata(codec); |
296 | int ret; | 300 | int ret; |
297 | 301 | ||
298 | ret = snd_ac97_reset(ac97, true, WM9705_VENDOR_ID, | 302 | ret = snd_ac97_reset(wm9705->ac97, true, WM9705_VENDOR_ID, |
299 | WM9705_VENDOR_ID_MASK); | 303 | WM9705_VENDOR_ID_MASK); |
300 | if (ret < 0) | 304 | if (ret < 0) |
301 | return ret; | 305 | return ret; |
@@ -311,38 +315,38 @@ static int wm9705_soc_resume(struct snd_soc_codec *codec) | |||
311 | 315 | ||
312 | static int wm9705_soc_probe(struct snd_soc_codec *codec) | 316 | static int wm9705_soc_probe(struct snd_soc_codec *codec) |
313 | { | 317 | { |
314 | struct snd_ac97 *ac97; | 318 | struct wm9705_priv *wm9705 = snd_soc_codec_get_drvdata(codec); |
315 | struct regmap *regmap; | 319 | struct regmap *regmap; |
316 | int ret; | 320 | int ret; |
317 | 321 | ||
318 | ac97 = snd_soc_new_ac97_codec(codec, WM9705_VENDOR_ID, | 322 | wm9705->ac97 = snd_soc_new_ac97_codec(codec, WM9705_VENDOR_ID, |
319 | WM9705_VENDOR_ID_MASK); | 323 | WM9705_VENDOR_ID_MASK); |
320 | if (IS_ERR(ac97)) { | 324 | if (IS_ERR(wm9705->ac97)) { |
321 | dev_err(codec->dev, "Failed to register AC97 codec\n"); | 325 | dev_err(codec->dev, "Failed to register AC97 codec\n"); |
322 | return PTR_ERR(ac97); | 326 | return PTR_ERR(wm9705->ac97); |
323 | } | 327 | } |
324 | 328 | ||
325 | regmap = regmap_init_ac97(ac97, &wm9705_regmap_config); | 329 | regmap = regmap_init_ac97(wm9705->ac97, &wm9705_regmap_config); |
326 | if (IS_ERR(regmap)) { | 330 | if (IS_ERR(regmap)) { |
327 | ret = PTR_ERR(regmap); | 331 | ret = PTR_ERR(regmap); |
328 | goto err_free_ac97_codec; | 332 | goto err_free_ac97_codec; |
329 | } | 333 | } |
330 | 334 | ||
331 | snd_soc_codec_set_drvdata(codec, ac97); | 335 | snd_soc_codec_set_drvdata(codec, wm9705->ac97); |
332 | snd_soc_codec_init_regmap(codec, regmap); | 336 | snd_soc_codec_init_regmap(codec, regmap); |
333 | 337 | ||
334 | return 0; | 338 | return 0; |
335 | err_free_ac97_codec: | 339 | err_free_ac97_codec: |
336 | snd_soc_free_ac97_codec(ac97); | 340 | snd_soc_free_ac97_codec(wm9705->ac97); |
337 | return ret; | 341 | return ret; |
338 | } | 342 | } |
339 | 343 | ||
340 | static int wm9705_soc_remove(struct snd_soc_codec *codec) | 344 | static int wm9705_soc_remove(struct snd_soc_codec *codec) |
341 | { | 345 | { |
342 | struct snd_ac97 *ac97 = snd_soc_codec_get_drvdata(codec); | 346 | struct wm9705_priv *wm9705 = snd_soc_codec_get_drvdata(codec); |
343 | 347 | ||
344 | snd_soc_codec_exit_regmap(codec); | 348 | snd_soc_codec_exit_regmap(codec); |
345 | snd_soc_free_ac97_codec(ac97); | 349 | snd_soc_free_ac97_codec(wm9705->ac97); |
346 | return 0; | 350 | return 0; |
347 | } | 351 | } |
348 | 352 | ||
@@ -364,6 +368,14 @@ static const struct snd_soc_codec_driver soc_codec_dev_wm9705 = { | |||
364 | 368 | ||
365 | static int wm9705_probe(struct platform_device *pdev) | 369 | static int wm9705_probe(struct platform_device *pdev) |
366 | { | 370 | { |
371 | struct wm9705_priv *wm9705; | ||
372 | |||
373 | wm9705 = devm_kzalloc(&pdev->dev, sizeof(*wm9705), GFP_KERNEL); | ||
374 | if (wm9705 == NULL) | ||
375 | return -ENOMEM; | ||
376 | |||
377 | platform_set_drvdata(pdev, wm9705); | ||
378 | |||
367 | return snd_soc_register_codec(&pdev->dev, | 379 | return snd_soc_register_codec(&pdev->dev, |
368 | &soc_codec_dev_wm9705, wm9705_dai, ARRAY_SIZE(wm9705_dai)); | 380 | &soc_codec_dev_wm9705, wm9705_dai, ARRAY_SIZE(wm9705_dai)); |
369 | } | 381 | } |