diff options
Diffstat (limited to 'sound/soc/codecs/ad1980.c')
-rw-r--r-- | sound/soc/codecs/ad1980.c | 33 |
1 files changed, 10 insertions, 23 deletions
diff --git a/sound/soc/codecs/ad1980.c b/sound/soc/codecs/ad1980.c index 73fdbb4d4a3d..ddb3b08ac23c 100644 --- a/sound/soc/codecs/ad1980.c +++ b/sound/soc/codecs/ad1980.c | |||
@@ -93,20 +93,6 @@ SOC_ENUM("Capture Source", ad1980_cap_src), | |||
93 | SOC_SINGLE("Mic Boost Switch", AC97_MIC, 6, 1, 0), | 93 | SOC_SINGLE("Mic Boost Switch", AC97_MIC, 6, 1, 0), |
94 | }; | 94 | }; |
95 | 95 | ||
96 | /* add non dapm controls */ | ||
97 | static int ad1980_add_controls(struct snd_soc_codec *codec) | ||
98 | { | ||
99 | int err, i; | ||
100 | |||
101 | for (i = 0; i < ARRAY_SIZE(ad1980_snd_ac97_controls); i++) { | ||
102 | err = snd_ctl_add(codec->card, snd_soc_cnew( | ||
103 | &ad1980_snd_ac97_controls[i], codec, NULL)); | ||
104 | if (err < 0) | ||
105 | return err; | ||
106 | } | ||
107 | return 0; | ||
108 | } | ||
109 | |||
110 | static unsigned int ac97_read(struct snd_soc_codec *codec, | 96 | static unsigned int ac97_read(struct snd_soc_codec *codec, |
111 | unsigned int reg) | 97 | unsigned int reg) |
112 | { | 98 | { |
@@ -123,7 +109,7 @@ static unsigned int ac97_read(struct snd_soc_codec *codec, | |||
123 | default: | 109 | default: |
124 | reg = reg >> 1; | 110 | reg = reg >> 1; |
125 | 111 | ||
126 | if (reg >= (ARRAY_SIZE(ad1980_reg))) | 112 | if (reg >= ARRAY_SIZE(ad1980_reg)) |
127 | return -EINVAL; | 113 | return -EINVAL; |
128 | 114 | ||
129 | return cache[reg]; | 115 | return cache[reg]; |
@@ -137,7 +123,7 @@ static int ac97_write(struct snd_soc_codec *codec, unsigned int reg, | |||
137 | 123 | ||
138 | soc_ac97_ops.write(codec->ac97, reg, val); | 124 | soc_ac97_ops.write(codec->ac97, reg, val); |
139 | reg = reg >> 1; | 125 | reg = reg >> 1; |
140 | if (reg < (ARRAY_SIZE(ad1980_reg))) | 126 | if (reg < ARRAY_SIZE(ad1980_reg)) |
141 | cache[reg] = val; | 127 | cache[reg] = val; |
142 | 128 | ||
143 | return 0; | 129 | return 0; |
@@ -200,10 +186,10 @@ static int ad1980_soc_probe(struct platform_device *pdev) | |||
200 | 186 | ||
201 | printk(KERN_INFO "AD1980 SoC Audio Codec\n"); | 187 | printk(KERN_INFO "AD1980 SoC Audio Codec\n"); |
202 | 188 | ||
203 | socdev->codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL); | 189 | socdev->card->codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL); |
204 | if (socdev->codec == NULL) | 190 | if (socdev->card->codec == NULL) |
205 | return -ENOMEM; | 191 | return -ENOMEM; |
206 | codec = socdev->codec; | 192 | codec = socdev->card->codec; |
207 | mutex_init(&codec->mutex); | 193 | mutex_init(&codec->mutex); |
208 | 194 | ||
209 | codec->reg_cache = | 195 | codec->reg_cache = |
@@ -269,7 +255,8 @@ static int ad1980_soc_probe(struct platform_device *pdev) | |||
269 | ext_status = ac97_read(codec, AC97_EXTENDED_STATUS); | 255 | ext_status = ac97_read(codec, AC97_EXTENDED_STATUS); |
270 | ac97_write(codec, AC97_EXTENDED_STATUS, ext_status&~0x3800); | 256 | ac97_write(codec, AC97_EXTENDED_STATUS, ext_status&~0x3800); |
271 | 257 | ||
272 | ad1980_add_controls(codec); | 258 | snd_soc_add_controls(codec, ad1980_snd_ac97_controls, |
259 | ARRAY_SIZE(ad1980_snd_ac97_controls)); | ||
273 | ret = snd_soc_init_card(socdev); | 260 | ret = snd_soc_init_card(socdev); |
274 | if (ret < 0) { | 261 | if (ret < 0) { |
275 | printk(KERN_ERR "ad1980: failed to register card\n"); | 262 | printk(KERN_ERR "ad1980: failed to register card\n"); |
@@ -288,15 +275,15 @@ codec_err: | |||
288 | kfree(codec->reg_cache); | 275 | kfree(codec->reg_cache); |
289 | 276 | ||
290 | cache_err: | 277 | cache_err: |
291 | kfree(socdev->codec); | 278 | kfree(socdev->card->codec); |
292 | socdev->codec = NULL; | 279 | socdev->card->codec = NULL; |
293 | return ret; | 280 | return ret; |
294 | } | 281 | } |
295 | 282 | ||
296 | static int ad1980_soc_remove(struct platform_device *pdev) | 283 | static int ad1980_soc_remove(struct platform_device *pdev) |
297 | { | 284 | { |
298 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); | 285 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); |
299 | struct snd_soc_codec *codec = socdev->codec; | 286 | struct snd_soc_codec *codec = socdev->card->codec; |
300 | 287 | ||
301 | if (codec == NULL) | 288 | if (codec == NULL) |
302 | return 0; | 289 | return 0; |