diff options
Diffstat (limited to 'sound/soc/codecs/wm8971.c')
-rw-r--r-- | sound/soc/codecs/wm8971.c | 37 |
1 files changed, 11 insertions, 26 deletions
diff --git a/sound/soc/codecs/wm8971.c b/sound/soc/codecs/wm8971.c index 4af893601f00..28fe59e3ce01 100644 --- a/sound/soc/codecs/wm8971.c +++ b/sound/soc/codecs/wm8971.c | |||
@@ -252,7 +252,7 @@ static const struct snd_soc_dapm_widget wm8971_dapm_widgets[] = { | |||
252 | SND_SOC_DAPM_INPUT("MIC"), | 252 | SND_SOC_DAPM_INPUT("MIC"), |
253 | }; | 253 | }; |
254 | 254 | ||
255 | static const struct snd_soc_dapm_route audio_map[] = { | 255 | static const struct snd_soc_dapm_route wm8971_dapm_routes[] = { |
256 | /* left mixer */ | 256 | /* left mixer */ |
257 | {"Left Mixer", "Playback Switch", "Left DAC"}, | 257 | {"Left Mixer", "Playback Switch", "Left DAC"}, |
258 | {"Left Mixer", "Left Bypass Switch", "Left Line Mux"}, | 258 | {"Left Mixer", "Left Bypass Switch", "Left Line Mux"}, |
@@ -329,17 +329,6 @@ static const struct snd_soc_dapm_route audio_map[] = { | |||
329 | {"Right ADC", NULL, "Right ADC Mux"}, | 329 | {"Right ADC", NULL, "Right ADC Mux"}, |
330 | }; | 330 | }; |
331 | 331 | ||
332 | static int wm8971_add_widgets(struct snd_soc_codec *codec) | ||
333 | { | ||
334 | struct snd_soc_dapm_context *dapm = &codec->dapm; | ||
335 | |||
336 | snd_soc_dapm_new_controls(dapm, wm8971_dapm_widgets, | ||
337 | ARRAY_SIZE(wm8971_dapm_widgets)); | ||
338 | snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map)); | ||
339 | |||
340 | return 0; | ||
341 | } | ||
342 | |||
343 | struct _coeff_div { | 332 | struct _coeff_div { |
344 | u32 mclk; | 333 | u32 mclk; |
345 | u32 rate; | 334 | u32 rate; |
@@ -659,10 +648,6 @@ static int wm8971_probe(struct snd_soc_codec *codec) | |||
659 | snd_soc_update_bits(codec, WM8971_LINVOL, 0x0100, 0x0100); | 648 | snd_soc_update_bits(codec, WM8971_LINVOL, 0x0100, 0x0100); |
660 | snd_soc_update_bits(codec, WM8971_RINVOL, 0x0100, 0x0100); | 649 | snd_soc_update_bits(codec, WM8971_RINVOL, 0x0100, 0x0100); |
661 | 650 | ||
662 | snd_soc_add_controls(codec, wm8971_snd_controls, | ||
663 | ARRAY_SIZE(wm8971_snd_controls)); | ||
664 | wm8971_add_widgets(codec); | ||
665 | |||
666 | return ret; | 651 | return ret; |
667 | } | 652 | } |
668 | 653 | ||
@@ -686,16 +671,23 @@ static struct snd_soc_codec_driver soc_codec_dev_wm8971 = { | |||
686 | .reg_cache_size = ARRAY_SIZE(wm8971_reg), | 671 | .reg_cache_size = ARRAY_SIZE(wm8971_reg), |
687 | .reg_word_size = sizeof(u16), | 672 | .reg_word_size = sizeof(u16), |
688 | .reg_cache_default = wm8971_reg, | 673 | .reg_cache_default = wm8971_reg, |
674 | |||
675 | .controls = wm8971_snd_controls, | ||
676 | .num_controls = ARRAY_SIZE(wm8971_snd_controls), | ||
677 | .dapm_widgets = wm8971_dapm_widgets, | ||
678 | .num_dapm_widgets = ARRAY_SIZE(wm8971_dapm_widgets), | ||
679 | .dapm_routes = wm8971_dapm_routes, | ||
680 | .num_dapm_routes = ARRAY_SIZE(wm8971_dapm_routes), | ||
689 | }; | 681 | }; |
690 | 682 | ||
691 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | ||
692 | static __devinit int wm8971_i2c_probe(struct i2c_client *i2c, | 683 | static __devinit int wm8971_i2c_probe(struct i2c_client *i2c, |
693 | const struct i2c_device_id *id) | 684 | const struct i2c_device_id *id) |
694 | { | 685 | { |
695 | struct wm8971_priv *wm8971; | 686 | struct wm8971_priv *wm8971; |
696 | int ret; | 687 | int ret; |
697 | 688 | ||
698 | wm8971 = kzalloc(sizeof(struct wm8971_priv), GFP_KERNEL); | 689 | wm8971 = devm_kzalloc(&i2c->dev, sizeof(struct wm8971_priv), |
690 | GFP_KERNEL); | ||
699 | if (wm8971 == NULL) | 691 | if (wm8971 == NULL) |
700 | return -ENOMEM; | 692 | return -ENOMEM; |
701 | 693 | ||
@@ -704,15 +696,13 @@ static __devinit int wm8971_i2c_probe(struct i2c_client *i2c, | |||
704 | 696 | ||
705 | ret = snd_soc_register_codec(&i2c->dev, | 697 | ret = snd_soc_register_codec(&i2c->dev, |
706 | &soc_codec_dev_wm8971, &wm8971_dai, 1); | 698 | &soc_codec_dev_wm8971, &wm8971_dai, 1); |
707 | if (ret < 0) | 699 | |
708 | kfree(wm8971); | ||
709 | return ret; | 700 | return ret; |
710 | } | 701 | } |
711 | 702 | ||
712 | static __devexit int wm8971_i2c_remove(struct i2c_client *client) | 703 | static __devexit int wm8971_i2c_remove(struct i2c_client *client) |
713 | { | 704 | { |
714 | snd_soc_unregister_codec(&client->dev); | 705 | snd_soc_unregister_codec(&client->dev); |
715 | kfree(i2c_get_clientdata(client)); | ||
716 | return 0; | 706 | return 0; |
717 | } | 707 | } |
718 | 708 | ||
@@ -731,27 +721,22 @@ static struct i2c_driver wm8971_i2c_driver = { | |||
731 | .remove = __devexit_p(wm8971_i2c_remove), | 721 | .remove = __devexit_p(wm8971_i2c_remove), |
732 | .id_table = wm8971_i2c_id, | 722 | .id_table = wm8971_i2c_id, |
733 | }; | 723 | }; |
734 | #endif | ||
735 | 724 | ||
736 | static int __init wm8971_modinit(void) | 725 | static int __init wm8971_modinit(void) |
737 | { | 726 | { |
738 | int ret = 0; | 727 | int ret = 0; |
739 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | ||
740 | ret = i2c_add_driver(&wm8971_i2c_driver); | 728 | ret = i2c_add_driver(&wm8971_i2c_driver); |
741 | if (ret != 0) { | 729 | if (ret != 0) { |
742 | printk(KERN_ERR "Failed to register WM8971 I2C driver: %d\n", | 730 | printk(KERN_ERR "Failed to register WM8971 I2C driver: %d\n", |
743 | ret); | 731 | ret); |
744 | } | 732 | } |
745 | #endif | ||
746 | return ret; | 733 | return ret; |
747 | } | 734 | } |
748 | module_init(wm8971_modinit); | 735 | module_init(wm8971_modinit); |
749 | 736 | ||
750 | static void __exit wm8971_exit(void) | 737 | static void __exit wm8971_exit(void) |
751 | { | 738 | { |
752 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | ||
753 | i2c_del_driver(&wm8971_i2c_driver); | 739 | i2c_del_driver(&wm8971_i2c_driver); |
754 | #endif | ||
755 | } | 740 | } |
756 | module_exit(wm8971_exit); | 741 | module_exit(wm8971_exit); |
757 | 742 | ||