aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/wm8750.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/codecs/wm8750.c')
-rw-r--r--sound/soc/codecs/wm8750.c40
1 files changed, 14 insertions, 26 deletions
diff --git a/sound/soc/codecs/wm8750.c b/sound/soc/codecs/wm8750.c
index ca75a818070..e4c50ce7d9c 100644
--- a/sound/soc/codecs/wm8750.c
+++ b/sound/soc/codecs/wm8750.c
@@ -18,7 +18,6 @@
18#include <linux/delay.h> 18#include <linux/delay.h>
19#include <linux/pm.h> 19#include <linux/pm.h>
20#include <linux/i2c.h> 20#include <linux/i2c.h>
21#include <linux/platform_device.h>
22#include <linux/spi/spi.h> 21#include <linux/spi/spi.h>
23#include <linux/slab.h> 22#include <linux/slab.h>
24#include <linux/of_device.h> 23#include <linux/of_device.h>
@@ -302,7 +301,7 @@ static const struct snd_soc_dapm_widget wm8750_dapm_widgets[] = {
302 SND_SOC_DAPM_INPUT("RINPUT3"), 301 SND_SOC_DAPM_INPUT("RINPUT3"),
303}; 302};
304 303
305static const struct snd_soc_dapm_route audio_map[] = { 304static const struct snd_soc_dapm_route wm8750_dapm_routes[] = {
306 /* left mixer */ 305 /* left mixer */
307 {"Left Mixer", "Playback Switch", "Left DAC"}, 306 {"Left Mixer", "Playback Switch", "Left DAC"},
308 {"Left Mixer", "Left Bypass Switch", "Left Line Mux"}, 307 {"Left Mixer", "Left Bypass Switch", "Left Line Mux"},
@@ -396,17 +395,6 @@ static const struct snd_soc_dapm_route audio_map[] = {
396 {"Right ADC", NULL, "Right ADC Mux"}, 395 {"Right ADC", NULL, "Right ADC Mux"},
397}; 396};
398 397
399static int wm8750_add_widgets(struct snd_soc_codec *codec)
400{
401 struct snd_soc_dapm_context *dapm = &codec->dapm;
402
403 snd_soc_dapm_new_controls(dapm, wm8750_dapm_widgets,
404 ARRAY_SIZE(wm8750_dapm_widgets));
405 snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map));
406
407 return 0;
408}
409
410struct _coeff_div { 398struct _coeff_div {
411 u32 mclk; 399 u32 mclk;
412 u32 rate; 400 u32 rate;
@@ -643,7 +631,7 @@ static int wm8750_set_bias_level(struct snd_soc_codec *codec,
643#define WM8750_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\ 631#define WM8750_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\
644 SNDRV_PCM_FMTBIT_S24_LE) 632 SNDRV_PCM_FMTBIT_S24_LE)
645 633
646static struct snd_soc_dai_ops wm8750_dai_ops = { 634static const struct snd_soc_dai_ops wm8750_dai_ops = {
647 .hw_params = wm8750_pcm_hw_params, 635 .hw_params = wm8750_pcm_hw_params,
648 .digital_mute = wm8750_mute, 636 .digital_mute = wm8750_mute,
649 .set_fmt = wm8750_set_dai_fmt, 637 .set_fmt = wm8750_set_dai_fmt,
@@ -667,7 +655,7 @@ static struct snd_soc_dai_driver wm8750_dai = {
667 .ops = &wm8750_dai_ops, 655 .ops = &wm8750_dai_ops,
668}; 656};
669 657
670static int wm8750_suspend(struct snd_soc_codec *codec, pm_message_t state) 658static int wm8750_suspend(struct snd_soc_codec *codec)
671{ 659{
672 wm8750_set_bias_level(codec, SND_SOC_BIAS_OFF); 660 wm8750_set_bias_level(codec, SND_SOC_BIAS_OFF);
673 return 0; 661 return 0;
@@ -709,9 +697,6 @@ static int wm8750_probe(struct snd_soc_codec *codec)
709 snd_soc_update_bits(codec, WM8750_LINVOL, 0x0100, 0x0100); 697 snd_soc_update_bits(codec, WM8750_LINVOL, 0x0100, 0x0100);
710 snd_soc_update_bits(codec, WM8750_RINVOL, 0x0100, 0x0100); 698 snd_soc_update_bits(codec, WM8750_RINVOL, 0x0100, 0x0100);
711 699
712 snd_soc_add_controls(codec, wm8750_snd_controls,
713 ARRAY_SIZE(wm8750_snd_controls));
714 wm8750_add_widgets(codec);
715 return ret; 700 return ret;
716} 701}
717 702
@@ -730,6 +715,13 @@ static struct snd_soc_codec_driver soc_codec_dev_wm8750 = {
730 .reg_cache_size = ARRAY_SIZE(wm8750_reg), 715 .reg_cache_size = ARRAY_SIZE(wm8750_reg),
731 .reg_word_size = sizeof(u16), 716 .reg_word_size = sizeof(u16),
732 .reg_cache_default = wm8750_reg, 717 .reg_cache_default = wm8750_reg,
718
719 .controls = wm8750_snd_controls,
720 .num_controls = ARRAY_SIZE(wm8750_snd_controls),
721 .dapm_widgets = wm8750_dapm_widgets,
722 .num_dapm_widgets = ARRAY_SIZE(wm8750_dapm_widgets),
723 .dapm_routes = wm8750_dapm_routes,
724 .num_dapm_routes = ARRAY_SIZE(wm8750_dapm_routes),
733}; 725};
734 726
735static const struct of_device_id wm8750_of_match[] = { 727static const struct of_device_id wm8750_of_match[] = {
@@ -745,7 +737,8 @@ static int __devinit wm8750_spi_probe(struct spi_device *spi)
745 struct wm8750_priv *wm8750; 737 struct wm8750_priv *wm8750;
746 int ret; 738 int ret;
747 739
748 wm8750 = kzalloc(sizeof(struct wm8750_priv), GFP_KERNEL); 740 wm8750 = devm_kzalloc(&spi->dev, sizeof(struct wm8750_priv),
741 GFP_KERNEL);
749 if (wm8750 == NULL) 742 if (wm8750 == NULL)
750 return -ENOMEM; 743 return -ENOMEM;
751 744
@@ -754,15 +747,12 @@ static int __devinit wm8750_spi_probe(struct spi_device *spi)
754 747
755 ret = snd_soc_register_codec(&spi->dev, 748 ret = snd_soc_register_codec(&spi->dev,
756 &soc_codec_dev_wm8750, &wm8750_dai, 1); 749 &soc_codec_dev_wm8750, &wm8750_dai, 1);
757 if (ret < 0)
758 kfree(wm8750);
759 return ret; 750 return ret;
760} 751}
761 752
762static int __devexit wm8750_spi_remove(struct spi_device *spi) 753static int __devexit wm8750_spi_remove(struct spi_device *spi)
763{ 754{
764 snd_soc_unregister_codec(&spi->dev); 755 snd_soc_unregister_codec(&spi->dev);
765 kfree(spi_get_drvdata(spi));
766 return 0; 756 return 0;
767} 757}
768 758
@@ -792,7 +782,8 @@ static __devinit int wm8750_i2c_probe(struct i2c_client *i2c,
792 struct wm8750_priv *wm8750; 782 struct wm8750_priv *wm8750;
793 int ret; 783 int ret;
794 784
795 wm8750 = kzalloc(sizeof(struct wm8750_priv), GFP_KERNEL); 785 wm8750 = devm_kzalloc(&i2c->dev, sizeof(struct wm8750_priv),
786 GFP_KERNEL);
796 if (wm8750 == NULL) 787 if (wm8750 == NULL)
797 return -ENOMEM; 788 return -ENOMEM;
798 789
@@ -801,15 +792,12 @@ static __devinit int wm8750_i2c_probe(struct i2c_client *i2c,
801 792
802 ret = snd_soc_register_codec(&i2c->dev, 793 ret = snd_soc_register_codec(&i2c->dev,
803 &soc_codec_dev_wm8750, &wm8750_dai, 1); 794 &soc_codec_dev_wm8750, &wm8750_dai, 1);
804 if (ret < 0)
805 kfree(wm8750);
806 return ret; 795 return ret;
807} 796}
808 797
809static __devexit int wm8750_i2c_remove(struct i2c_client *client) 798static __devexit int wm8750_i2c_remove(struct i2c_client *client)
810{ 799{
811 snd_soc_unregister_codec(&client->dev); 800 snd_soc_unregister_codec(&client->dev);
812 kfree(i2c_get_clientdata(client));
813 return 0; 801 return 0;
814} 802}
815 803