]> git.karo-electronics.de Git - linux-beck.git/commitdiff
ASoC: ac97: Use static ac97_bus
authorLars-Peter Clausen <lars@metafoo.de>
Mon, 10 Nov 2014 21:41:47 +0000 (22:41 +0100)
committerMark Brown <broonie@kernel.org>
Tue, 18 Nov 2014 15:37:46 +0000 (15:37 +0000)
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>
include/sound/soc.h
sound/soc/codecs/ad1980.c
sound/soc/codecs/stac9766.c
sound/soc/codecs/wm9705.c
sound/soc/codecs/wm9712.c
sound/soc/codecs/wm9713.c
sound/soc/soc-ac97.c

index adef34fa5209138fad4d2a62a8549d5b7b7a580e..44b3ce531fd6e11e6b739579119335ccdd6c04cd 100644 (file)
@@ -499,8 +499,7 @@ int snd_soc_test_bits(struct snd_soc_codec *codec, unsigned int reg,
                                unsigned int mask, unsigned int value);
 
 #ifdef CONFIG_SND_SOC_AC97_BUS
-int snd_soc_new_ac97_codec(struct snd_soc_codec *codec,
-       struct snd_ac97_bus_ops *ops, int num);
+int snd_soc_new_ac97_codec(struct snd_soc_codec *codec);
 void snd_soc_free_ac97_codec(struct snd_soc_codec *codec);
 
 int snd_soc_set_ac97_ops(struct snd_ac97_bus_ops *ops);
index 9ed4e12c26d1c217dc7c3923a73aa98e73a0f102..f71cc21e67d44e264386a59b73c6a41e58703b9a 100644 (file)
@@ -220,7 +220,7 @@ static int ad1980_soc_probe(struct snd_soc_codec *codec)
        u16 vendor_id2;
        u16 ext_status;
 
-       ret = snd_soc_new_ac97_codec(codec, soc_ac97_ops, 0);
+       ret = snd_soc_new_ac97_codec(codec);
        if (ret < 0) {
                dev_err(codec->dev, "Failed to register AC97 codec\n");
                return ret;
index 53b810d23feac4ce2530a7af6170044e22d4268a..45ac4a71ecff967cb4fbed57a3d6f5c7359a5646 100644 (file)
@@ -336,7 +336,7 @@ static int stac9766_codec_probe(struct snd_soc_codec *codec)
 {
        int ret = 0;
 
-       ret = snd_soc_new_ac97_codec(codec, soc_ac97_ops, 0);
+       ret = snd_soc_new_ac97_codec(codec);
        if (ret < 0)
                goto codec_err;
 
index 1650195f6c8467517a9dcae68382af27f5cfbb1f..2cb8a31819fa27b3b957b8034f355f3b50b64fe2 100644 (file)
@@ -337,7 +337,7 @@ static int wm9705_soc_probe(struct snd_soc_codec *codec)
 {
        int ret = 0;
 
-       ret = snd_soc_new_ac97_codec(codec, soc_ac97_ops, 0);
+       ret = snd_soc_new_ac97_codec(codec);
        if (ret < 0) {
                dev_err(codec->dev, "Failed to register AC97 codec\n");
                return ret;
index 3fad37e0d33d532b9008d218af9b77e2d4ad34ed..6b36223fd24702f40335b1df4d5a68fbb29c3bf1 100644 (file)
@@ -666,7 +666,7 @@ static int wm9712_soc_probe(struct snd_soc_codec *codec)
 {
        int ret = 0;
 
-       ret = snd_soc_new_ac97_codec(codec, soc_ac97_ops, 0);
+       ret = snd_soc_new_ac97_codec(codec);
        if (ret < 0) {
                dev_err(codec->dev, "Failed to register AC97 codec\n");
                return ret;
index 998e4c7b6b12e7b896b5411834e181ec97c0f3cb..2071df707e88bb20adeca69d9c3dd4c9500539c2 100644 (file)
@@ -1219,7 +1219,7 @@ static int wm9713_soc_probe(struct snd_soc_codec *codec)
 {
        int ret = 0, reg;
 
-       ret = snd_soc_new_ac97_codec(codec, soc_ac97_ops, 0);
+       ret = snd_soc_new_ac97_codec(codec);
        if (ret < 0)
                return ret;
 
index da7b031a6eeaa88b992e0551499886042ffdeda8..dbfca7e7dddb572fd6167e86e0a92eb2b6ee0cf7 100644 (file)
@@ -38,6 +38,10 @@ struct snd_ac97_reset_cfg {
        int gpio_reset;
 };
 
+static struct snd_ac97_bus soc_ac97_bus = {
+       .ops = NULL, /* Gets initialized in snd_soc_set_ac97_ops() */
+};
+
 /* unregister ac97 codec */
 static int soc_ac97_dev_unregister(struct snd_soc_codec *codec)
 {
@@ -140,27 +144,17 @@ static void soc_ac97_device_release(struct device *dev)
 /**
  * snd_soc_new_ac97_codec - initailise AC97 device
  * @codec: audio codec
- * @ops: AC97 bus operations
- * @num: AC97 codec number
  *
  * Initialises AC97 codec resources for use by ad-hoc devices only.
  */
-int snd_soc_new_ac97_codec(struct snd_soc_codec *codec,
-       struct snd_ac97_bus_ops *ops, int num)
+int snd_soc_new_ac97_codec(struct snd_soc_codec *codec)
 {
        codec->ac97 = kzalloc(sizeof(struct snd_ac97), GFP_KERNEL);
        if (codec->ac97 == NULL)
                return -ENOMEM;
 
-       codec->ac97->bus = kzalloc(sizeof(struct snd_ac97_bus), GFP_KERNEL);
-       if (codec->ac97->bus == NULL) {
-               kfree(codec->ac97);
-               codec->ac97 = NULL;
-               return -ENOMEM;
-       }
-
-       codec->ac97->bus->ops = ops;
-       codec->ac97->num = num;
+       codec->ac97->bus = &soc_ac97_bus;
+       codec->ac97->num = 0;
        codec->ac97->dev.release = soc_ac97_device_release;
 
        /*
@@ -183,7 +177,6 @@ EXPORT_SYMBOL_GPL(snd_soc_new_ac97_codec);
 void snd_soc_free_ac97_codec(struct snd_soc_codec *codec)
 {
        soc_unregister_ac97_codec(codec);
-       kfree(codec->ac97->bus);
        codec->ac97->bus = NULL;
        put_device(&codec->ac97->dev);
        codec->ac97 = NULL;
@@ -314,6 +307,7 @@ int snd_soc_set_ac97_ops(struct snd_ac97_bus_ops *ops)
                return -EBUSY;
 
        soc_ac97_ops = ops;
+       soc_ac97_bus.ops = ops;
 
        return 0;
 }