aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/soc-ac97.c
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2014-11-10 16:41:47 -0500
committerMark Brown <broonie@kernel.org>2014-11-18 10:37:46 -0500
commiteda1a701fd9589b6ed15b109558bd4f6202e3829 (patch)
tree0741b263b8e99bb168181997704e9533635d1bc0 /sound/soc/soc-ac97.c
parent336b8423e285174ebecf02a743d69913b83bbc48 (diff)
ASoC: ac97: Use static ac97_bus
We always pass soc_ac97_ops to snd_soc_new_ac97_codec(). So instead of allocating a snd_ac97_bus in snd_soc_new_ac97_codec() just use a static one that gets initialized when snd_soc_set_ac97_ops() is called. Also drop the device number parameter from snd_soc_new_ac97_codec(). We currently only support one device per bus and all drivers pass 0 for the device number. And if we should ever support multiple devices per bus it wouldn't be up to individual AC'97 device drivers to pick their number, but rather either the AC'97 adapter driver or the core code will assign them. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Acked-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/soc-ac97.c')
-rw-r--r--sound/soc/soc-ac97.c22
1 files changed, 8 insertions, 14 deletions
diff --git a/sound/soc/soc-ac97.c b/sound/soc/soc-ac97.c
index da7b031a6eea..dbfca7e7dddb 100644
--- a/sound/soc/soc-ac97.c
+++ b/sound/soc/soc-ac97.c
@@ -38,6 +38,10 @@ struct snd_ac97_reset_cfg {
38 int gpio_reset; 38 int gpio_reset;
39}; 39};
40 40
41static struct snd_ac97_bus soc_ac97_bus = {
42 .ops = NULL, /* Gets initialized in snd_soc_set_ac97_ops() */
43};
44
41/* unregister ac97 codec */ 45/* unregister ac97 codec */
42static int soc_ac97_dev_unregister(struct snd_soc_codec *codec) 46static int soc_ac97_dev_unregister(struct snd_soc_codec *codec)
43{ 47{
@@ -140,27 +144,17 @@ static void soc_ac97_device_release(struct device *dev)
140/** 144/**
141 * snd_soc_new_ac97_codec - initailise AC97 device 145 * snd_soc_new_ac97_codec - initailise AC97 device
142 * @codec: audio codec 146 * @codec: audio codec
143 * @ops: AC97 bus operations
144 * @num: AC97 codec number
145 * 147 *
146 * Initialises AC97 codec resources for use by ad-hoc devices only. 148 * Initialises AC97 codec resources for use by ad-hoc devices only.
147 */ 149 */
148int snd_soc_new_ac97_codec(struct snd_soc_codec *codec, 150int snd_soc_new_ac97_codec(struct snd_soc_codec *codec)
149 struct snd_ac97_bus_ops *ops, int num)
150{ 151{
151 codec->ac97 = kzalloc(sizeof(struct snd_ac97), GFP_KERNEL); 152 codec->ac97 = kzalloc(sizeof(struct snd_ac97), GFP_KERNEL);
152 if (codec->ac97 == NULL) 153 if (codec->ac97 == NULL)
153 return -ENOMEM; 154 return -ENOMEM;
154 155
155 codec->ac97->bus = kzalloc(sizeof(struct snd_ac97_bus), GFP_KERNEL); 156 codec->ac97->bus = &soc_ac97_bus;
156 if (codec->ac97->bus == NULL) { 157 codec->ac97->num = 0;
157 kfree(codec->ac97);
158 codec->ac97 = NULL;
159 return -ENOMEM;
160 }
161
162 codec->ac97->bus->ops = ops;
163 codec->ac97->num = num;
164 codec->ac97->dev.release = soc_ac97_device_release; 158 codec->ac97->dev.release = soc_ac97_device_release;
165 159
166 /* 160 /*
@@ -183,7 +177,6 @@ EXPORT_SYMBOL_GPL(snd_soc_new_ac97_codec);
183void snd_soc_free_ac97_codec(struct snd_soc_codec *codec) 177void snd_soc_free_ac97_codec(struct snd_soc_codec *codec)
184{ 178{
185 soc_unregister_ac97_codec(codec); 179 soc_unregister_ac97_codec(codec);
186 kfree(codec->ac97->bus);
187 codec->ac97->bus = NULL; 180 codec->ac97->bus = NULL;
188 put_device(&codec->ac97->dev); 181 put_device(&codec->ac97->dev);
189 codec->ac97 = NULL; 182 codec->ac97 = NULL;
@@ -314,6 +307,7 @@ int snd_soc_set_ac97_ops(struct snd_ac97_bus_ops *ops)
314 return -EBUSY; 307 return -EBUSY;
315 308
316 soc_ac97_ops = ops; 309 soc_ac97_ops = ops;
310 soc_ac97_bus.ops = ops;
317 311
318 return 0; 312 return 0;
319} 313}