aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/wm8776.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/codecs/wm8776.c')
-rw-r--r--sound/soc/codecs/wm8776.c35
1 files changed, 16 insertions, 19 deletions
diff --git a/sound/soc/codecs/wm8776.c b/sound/soc/codecs/wm8776.c
index d3b0a20744f1..33e97d1d8f46 100644
--- a/sound/soc/codecs/wm8776.c
+++ b/sound/soc/codecs/wm8776.c
@@ -19,7 +19,6 @@
19#include <linux/pm.h> 19#include <linux/pm.h>
20#include <linux/i2c.h> 20#include <linux/i2c.h>
21#include <linux/of_device.h> 21#include <linux/of_device.h>
22#include <linux/platform_device.h>
23#include <linux/spi/spi.h> 22#include <linux/spi/spi.h>
24#include <linux/slab.h> 23#include <linux/slab.h>
25#include <sound/core.h> 24#include <sound/core.h>
@@ -328,14 +327,14 @@ static int wm8776_set_bias_level(struct snd_soc_codec *codec,
328#define WM8776_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\ 327#define WM8776_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\
329 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE) 328 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE)
330 329
331static struct snd_soc_dai_ops wm8776_dac_ops = { 330static const struct snd_soc_dai_ops wm8776_dac_ops = {
332 .digital_mute = wm8776_mute, 331 .digital_mute = wm8776_mute,
333 .hw_params = wm8776_hw_params, 332 .hw_params = wm8776_hw_params,
334 .set_fmt = wm8776_set_fmt, 333 .set_fmt = wm8776_set_fmt,
335 .set_sysclk = wm8776_set_sysclk, 334 .set_sysclk = wm8776_set_sysclk,
336}; 335};
337 336
338static struct snd_soc_dai_ops wm8776_adc_ops = { 337static const struct snd_soc_dai_ops wm8776_adc_ops = {
339 .hw_params = wm8776_hw_params, 338 .hw_params = wm8776_hw_params,
340 .set_fmt = wm8776_set_fmt, 339 .set_fmt = wm8776_set_fmt,
341 .set_sysclk = wm8776_set_sysclk, 340 .set_sysclk = wm8776_set_sysclk,
@@ -373,7 +372,7 @@ static struct snd_soc_dai_driver wm8776_dai[] = {
373}; 372};
374 373
375#ifdef CONFIG_PM 374#ifdef CONFIG_PM
376static int wm8776_suspend(struct snd_soc_codec *codec, pm_message_t state) 375static int wm8776_suspend(struct snd_soc_codec *codec)
377{ 376{
378 wm8776_set_bias_level(codec, SND_SOC_BIAS_OFF); 377 wm8776_set_bias_level(codec, SND_SOC_BIAS_OFF);
379 378
@@ -393,7 +392,6 @@ static int wm8776_resume(struct snd_soc_codec *codec)
393static int wm8776_probe(struct snd_soc_codec *codec) 392static int wm8776_probe(struct snd_soc_codec *codec)
394{ 393{
395 struct wm8776_priv *wm8776 = snd_soc_codec_get_drvdata(codec); 394 struct wm8776_priv *wm8776 = snd_soc_codec_get_drvdata(codec);
396 struct snd_soc_dapm_context *dapm = &codec->dapm;
397 int ret = 0; 395 int ret = 0;
398 396
399 ret = snd_soc_codec_set_cache_io(codec, 7, 9, wm8776->control_type); 397 ret = snd_soc_codec_set_cache_io(codec, 7, 9, wm8776->control_type);
@@ -415,12 +413,6 @@ static int wm8776_probe(struct snd_soc_codec *codec)
415 snd_soc_update_bits(codec, WM8776_HPRVOL, 0x100, 0x100); 413 snd_soc_update_bits(codec, WM8776_HPRVOL, 0x100, 0x100);
416 snd_soc_update_bits(codec, WM8776_DACRVOL, 0x100, 0x100); 414 snd_soc_update_bits(codec, WM8776_DACRVOL, 0x100, 0x100);
417 415
418 snd_soc_add_controls(codec, wm8776_snd_controls,
419 ARRAY_SIZE(wm8776_snd_controls));
420 snd_soc_dapm_new_controls(dapm, wm8776_dapm_widgets,
421 ARRAY_SIZE(wm8776_dapm_widgets));
422 snd_soc_dapm_add_routes(dapm, routes, ARRAY_SIZE(routes));
423
424 return ret; 416 return ret;
425} 417}
426 418
@@ -440,6 +432,13 @@ static struct snd_soc_codec_driver soc_codec_dev_wm8776 = {
440 .reg_cache_size = ARRAY_SIZE(wm8776_reg), 432 .reg_cache_size = ARRAY_SIZE(wm8776_reg),
441 .reg_word_size = sizeof(u16), 433 .reg_word_size = sizeof(u16),
442 .reg_cache_default = wm8776_reg, 434 .reg_cache_default = wm8776_reg,
435
436 .controls = wm8776_snd_controls,
437 .num_controls = ARRAY_SIZE(wm8776_snd_controls),
438 .dapm_widgets = wm8776_dapm_widgets,
439 .num_dapm_widgets = ARRAY_SIZE(wm8776_dapm_widgets),
440 .dapm_routes = routes,
441 .num_dapm_routes = ARRAY_SIZE(routes),
443}; 442};
444 443
445static const struct of_device_id wm8776_of_match[] = { 444static const struct of_device_id wm8776_of_match[] = {
@@ -454,7 +453,8 @@ static int __devinit wm8776_spi_probe(struct spi_device *spi)
454 struct wm8776_priv *wm8776; 453 struct wm8776_priv *wm8776;
455 int ret; 454 int ret;
456 455
457 wm8776 = kzalloc(sizeof(struct wm8776_priv), GFP_KERNEL); 456 wm8776 = devm_kzalloc(&spi->dev, sizeof(struct wm8776_priv),
457 GFP_KERNEL);
458 if (wm8776 == NULL) 458 if (wm8776 == NULL)
459 return -ENOMEM; 459 return -ENOMEM;
460 460
@@ -463,15 +463,13 @@ static int __devinit wm8776_spi_probe(struct spi_device *spi)
463 463
464 ret = snd_soc_register_codec(&spi->dev, 464 ret = snd_soc_register_codec(&spi->dev,
465 &soc_codec_dev_wm8776, wm8776_dai, ARRAY_SIZE(wm8776_dai)); 465 &soc_codec_dev_wm8776, wm8776_dai, ARRAY_SIZE(wm8776_dai));
466 if (ret < 0) 466
467 kfree(wm8776);
468 return ret; 467 return ret;
469} 468}
470 469
471static int __devexit wm8776_spi_remove(struct spi_device *spi) 470static int __devexit wm8776_spi_remove(struct spi_device *spi)
472{ 471{
473 snd_soc_unregister_codec(&spi->dev); 472 snd_soc_unregister_codec(&spi->dev);
474 kfree(spi_get_drvdata(spi));
475 return 0; 473 return 0;
476} 474}
477 475
@@ -493,7 +491,8 @@ static __devinit int wm8776_i2c_probe(struct i2c_client *i2c,
493 struct wm8776_priv *wm8776; 491 struct wm8776_priv *wm8776;
494 int ret; 492 int ret;
495 493
496 wm8776 = kzalloc(sizeof(struct wm8776_priv), GFP_KERNEL); 494 wm8776 = devm_kzalloc(&i2c->dev, sizeof(struct wm8776_priv),
495 GFP_KERNEL);
497 if (wm8776 == NULL) 496 if (wm8776 == NULL)
498 return -ENOMEM; 497 return -ENOMEM;
499 498
@@ -502,15 +501,13 @@ static __devinit int wm8776_i2c_probe(struct i2c_client *i2c,
502 501
503 ret = snd_soc_register_codec(&i2c->dev, 502 ret = snd_soc_register_codec(&i2c->dev,
504 &soc_codec_dev_wm8776, wm8776_dai, ARRAY_SIZE(wm8776_dai)); 503 &soc_codec_dev_wm8776, wm8776_dai, ARRAY_SIZE(wm8776_dai));
505 if (ret < 0) 504
506 kfree(wm8776);
507 return ret; 505 return ret;
508} 506}
509 507
510static __devexit int wm8776_i2c_remove(struct i2c_client *client) 508static __devexit int wm8776_i2c_remove(struct i2c_client *client)
511{ 509{
512 snd_soc_unregister_codec(&client->dev); 510 snd_soc_unregister_codec(&client->dev);
513 kfree(i2c_get_clientdata(client));
514 return 0; 511 return 0;
515} 512}
516 513