]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
ASoC: ac97: Drop delayed device registration
authorLars-Peter Clausen <lars@metafoo.de>
Mon, 10 Nov 2014 21:41:50 +0000 (22:41 +0100)
committerMark Brown <broonie@kernel.org>
Tue, 18 Nov 2014 15:37:58 +0000 (15:37 +0000)
We have all the information and dependencies we need to initialize and
register the device available in snd_soc_new_ac97_codec(). So there is no
need to delay the device registration until after the card itself as been
registered.

This makes the code significantly simpler and also makes it possible to use
the AC'97 device in the CODECs probe function. The later will be required to
be able to convert the AC'97 CODEC drivers to regmap.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
include/sound/soc.h
sound/soc/soc-ac97.c
sound/soc/soc-core.c

index 5b4dec693ca52b03f5044b8ec46478535779d759..206cc8d6eefa8dff2333d8c22c07aa832ea60561 100644 (file)
@@ -507,15 +507,7 @@ int snd_soc_set_ac97_ops_of_reset(struct snd_ac97_bus_ops *ops,
                struct platform_device *pdev);
 
 extern struct snd_ac97_bus_ops *soc_ac97_ops;
-
-int snd_soc_ac97_register_dai_links(struct snd_soc_card *card);
 #else
-
-static inline int snd_soc_ac97_register_dai_links(struct snd_soc_card *card)
-{
-       return 0;
-}
-
 static inline int snd_soc_set_ac97_ops_of_reset(struct snd_ac97_bus_ops *ops,
        struct platform_device *pdev)
 {
@@ -808,8 +800,6 @@ struct snd_soc_codec {
        struct snd_ac97 *ac97;  /* for ad-hoc ac97 devices */
        unsigned int cache_bypass:1; /* Suppress access to the cache */
        unsigned int suspended:1; /* Codec is in suspend PM state */
-       unsigned int ac97_registered:1; /* Codec has been AC97 registered */
-       unsigned int ac97_created:1; /* Codec has been created by SoC */
        unsigned int cache_init:1; /* codec cache has been initialized */
        u32 cache_sync; /* Cache needs to be synced to hardware */
 
index f2ed77b5169a33506e29f7ef46cbb4ddf1bc09d9..920d76c4382700a1cd0b00c23e37331cac35c5fa 100644 (file)
@@ -42,80 +42,6 @@ static struct snd_ac97_bus soc_ac97_bus = {
        .ops = NULL, /* Gets initialized in snd_soc_set_ac97_ops() */
 };
 
-/* register ac97 codec to bus */
-static int soc_register_ac97_codec(struct snd_soc_codec *codec,
-       struct snd_soc_dai *codec_dai)
-{
-       int ret;
-
-       /* Only instantiate AC97 if not already done by the adaptor
-        * for the generic AC97 subsystem.
-        */
-       if (!codec_dai->driver->ac97_control || codec->ac97_registered)
-               return 0;
-
-       /*
-        * It is possible that the AC97 device is already registered to
-        * the device subsystem. This happens when the device is created
-        * via snd_ac97_mixer(). Currently only SoC codec that does so
-        * is the generic AC97 glue but others migh emerge.
-        *
-        * In those cases we don't try to register the device again.
-        */
-       if (!codec->ac97_created)
-               return 0;
-
-       codec->ac97->dev.bus = &ac97_bus_type;
-       codec->ac97->dev.parent = codec->component.card->dev;
-
-       dev_set_name(&codec->ac97->dev, "%d-%d:%s",
-                    codec->component.card->snd_card->number, 0,
-                    codec->component.name);
-       ret = device_add(&codec->ac97->dev);
-       if (ret < 0) {
-               dev_err(codec->dev, "ASoC: AC97 device register failed: %d\n",
-                       ret);
-               return ret;
-       }
-       codec->ac97_registered = 1;
-
-       return 0;
-}
-
-static void soc_unregister_ac97_codec(struct snd_soc_codec *codec)
-{
-       if (!codec->ac97_registered)
-               return;
-       device_del(&codec->ac97->dev);
-       codec->ac97_registered = 0;
-}
-
-static int soc_register_ac97_dai_link(struct snd_soc_pcm_runtime *rtd)
-{
-       int i, ret;
-
-       for (i = 0; i < rtd->num_codecs; i++) {
-               struct snd_soc_dai *codec_dai = rtd->codec_dais[i];
-
-               ret = soc_register_ac97_codec(codec_dai->codec, codec_dai);
-               if (ret) {
-                       while (--i >= 0)
-                               soc_unregister_ac97_codec(codec_dai->codec);
-                       return ret;
-               }
-       }
-
-       return 0;
-}
-
-static void soc_unregister_ac97_dai_link(struct snd_soc_pcm_runtime *rtd)
-{
-       int i;
-
-       for (i = 0; i < rtd->num_codecs; i++)
-               soc_unregister_ac97_codec(rtd->codec_dais[i]->codec);
-}
-
 static void soc_ac97_device_release(struct device *dev)
 {
        kfree(to_ac97_t(dev));
@@ -129,22 +55,28 @@ static void soc_ac97_device_release(struct device *dev)
  */
 int snd_soc_new_ac97_codec(struct snd_soc_codec *codec)
 {
+       int ret;
+
        codec->ac97 = kzalloc(sizeof(struct snd_ac97), GFP_KERNEL);
        if (codec->ac97 == NULL)
                return -ENOMEM;
 
        codec->ac97->bus = &soc_ac97_bus;
        codec->ac97->num = 0;
+
+       codec->ac97->dev.bus = &ac97_bus_type;
+       codec->ac97->dev.parent = codec->component.card->dev;
        codec->ac97->dev.release = soc_ac97_device_release;
 
-       /*
-        * Mark the AC97 device to be created by us. This way we ensure that the
-        * device will be registered with the device subsystem later on.
-        */
-       codec->ac97_created = 1;
-       device_initialize(&codec->ac97->dev);
+       dev_set_name(&codec->ac97->dev, "%d-%d:%s",
+                    codec->component.card->snd_card->number, 0,
+                    codec->component.name);
+
+       ret = device_register(&codec->ac97->dev);
+       if (ret)
+               put_device(&codec->ac97->dev);
 
-       return 0;
+       return ret;
 }
 EXPORT_SYMBOL_GPL(snd_soc_new_ac97_codec);
 
@@ -156,11 +88,10 @@ EXPORT_SYMBOL_GPL(snd_soc_new_ac97_codec);
  */
 void snd_soc_free_ac97_codec(struct snd_soc_codec *codec)
 {
-       soc_unregister_ac97_codec(codec);
+       device_del(&codec->ac97->dev);
        codec->ac97->bus = NULL;
        put_device(&codec->ac97->dev);
        codec->ac97 = NULL;
-       codec->ac97_created = 0;
 }
 EXPORT_SYMBOL_GPL(snd_soc_free_ac97_codec);
 
@@ -321,24 +252,3 @@ int snd_soc_set_ac97_ops_of_reset(struct snd_ac97_bus_ops *ops,
        return 0;
 }
 EXPORT_SYMBOL_GPL(snd_soc_set_ac97_ops_of_reset);
-
-int snd_soc_ac97_register_dai_links(struct snd_soc_card *card)
-{
-       int i;
-       int ret;
-
-       /* register any AC97 codecs */
-       for (i = 0; i < card->num_rtd; i++) {
-               ret = soc_register_ac97_dai_link(&card->rtd[i]);
-               if (ret < 0)
-                       goto err;
-       }
-
-       return 0;
-err:
-       dev_err(card->dev,
-               "ASoC: failed to register AC97: %d\n", ret);
-       while (--i >= 0)
-               soc_unregister_ac97_dai_link(&card->rtd[i]);
-       return ret;
-}
index d883b4ad03acd5231ba61fa4537c73b959dd339e..fba6e28e18d33e863065e1dc0f5eebc2e29af17a 100644 (file)
@@ -1671,10 +1671,6 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card)
                goto probe_aux_dev_err;
        }
 
-       ret = snd_soc_ac97_register_dai_links(card);
-       if (ret < 0)
-               goto probe_aux_dev_err;
-
        card->instantiated = 1;
        snd_soc_dapm_sync(&card->dapm);
        mutex_unlock(&card->mutex);