ASoC: dapm: Use DAPM mutex for DAPM ops instead of codec mutex
[linux-2.6.git] / sound / soc / soc-core.c
index 3b3a377..db2e0f0 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/bitops.h>
 #include <linux/debugfs.h>
 #include <linux/platform_device.h>
+#include <linux/ctype.h>
 #include <linux/slab.h>
 #include <sound/ac97_codec.h>
 #include <sound/core.h>
@@ -44,7 +45,6 @@
 
 #define NAME_SIZE      32
 
-static DEFINE_MUTEX(pcm_mutex);
 static DECLARE_WAIT_QUEUE_HEAD(soc_pm_waitq);
 
 #ifdef CONFIG_DEBUG_FS
@@ -58,7 +58,7 @@ static LIST_HEAD(dai_list);
 static LIST_HEAD(platform_list);
 static LIST_HEAD(codec_list);
 
-static int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num);
+int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num);
 
 /*
  * This is a timeout to do a DAPM powerdown after a stream is closed().
@@ -242,7 +242,7 @@ static ssize_t codec_reg_write_file(struct file *file,
                const char __user *user_buf, size_t count, loff_t *ppos)
 {
        char buf[32];
-       int buf_size;
+       size_t buf_size;
        char *start = buf;
        unsigned long reg, value;
        int step = 1;
@@ -302,13 +302,7 @@ static void soc_init_codec_debugfs(struct snd_soc_codec *codec)
                printk(KERN_WARNING
                       "ASoC: Failed to create codec register debugfs file\n");
 
-       codec->dapm.debugfs_dapm = debugfs_create_dir("dapm",
-                                                codec->debugfs_codec_root);
-       if (!codec->dapm.debugfs_dapm)
-               printk(KERN_WARNING
-                      "Failed to create DAPM debugfs directory\n");
-
-       snd_soc_dapm_debugfs_init(&codec->dapm);
+       snd_soc_dapm_debugfs_init(&codec->dapm, codec->debugfs_codec_root);
 }
 
 static void soc_cleanup_codec_debugfs(struct snd_soc_codec *codec)
@@ -491,552 +485,6 @@ static int soc_ac97_dev_register(struct snd_soc_codec *codec)
 }
 #endif
 
-static int soc_pcm_apply_symmetry(struct snd_pcm_substream *substream)
-{
-       struct snd_soc_pcm_runtime *rtd = substream->private_data;
-       struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
-       struct snd_soc_dai *codec_dai = rtd->codec_dai;
-       int ret;
-
-       if (!codec_dai->driver->symmetric_rates &&
-           !cpu_dai->driver->symmetric_rates &&
-           !rtd->dai_link->symmetric_rates)
-               return 0;
-
-       /* This can happen if multiple streams are starting simultaneously -
-        * the second can need to get its constraints before the first has
-        * picked a rate.  Complain and allow the application to carry on.
-        */
-       if (!rtd->rate) {
-               dev_warn(&rtd->dev,
-                        "Not enforcing symmetric_rates due to race\n");
-               return 0;
-       }
-
-       dev_dbg(&rtd->dev, "Symmetry forces %dHz rate\n", rtd->rate);
-
-       ret = snd_pcm_hw_constraint_minmax(substream->runtime,
-                                          SNDRV_PCM_HW_PARAM_RATE,
-                                          rtd->rate, rtd->rate);
-       if (ret < 0) {
-               dev_err(&rtd->dev,
-                       "Unable to apply rate symmetry constraint: %d\n", ret);
-               return ret;
-       }
-
-       return 0;
-}
-
-/*
- * Called by ALSA when a PCM substream is opened, the runtime->hw record is
- * then initialized and any private data can be allocated. This also calls
- * startup for the cpu DAI, platform, machine and codec DAI.
- */
-static int soc_pcm_open(struct snd_pcm_substream *substream)
-{
-       struct snd_soc_pcm_runtime *rtd = substream->private_data;
-       struct snd_pcm_runtime *runtime = substream->runtime;
-       struct snd_soc_platform *platform = rtd->platform;
-       struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
-       struct snd_soc_dai *codec_dai = rtd->codec_dai;
-       struct snd_soc_dai_driver *cpu_dai_drv = cpu_dai->driver;
-       struct snd_soc_dai_driver *codec_dai_drv = codec_dai->driver;
-       int ret = 0;
-
-       mutex_lock(&pcm_mutex);
-
-       /* startup the audio subsystem */
-       if (cpu_dai->driver->ops->startup) {
-               ret = cpu_dai->driver->ops->startup(substream, cpu_dai);
-               if (ret < 0) {
-                       printk(KERN_ERR "asoc: can't open interface %s\n",
-                               cpu_dai->name);
-                       goto out;
-               }
-       }
-
-       if (platform->driver->ops->open) {
-               ret = platform->driver->ops->open(substream);
-               if (ret < 0) {
-                       printk(KERN_ERR "asoc: can't open platform %s\n", platform->name);
-                       goto platform_err;
-               }
-       }
-
-       if (codec_dai->driver->ops->startup) {
-               ret = codec_dai->driver->ops->startup(substream, codec_dai);
-               if (ret < 0) {
-                       printk(KERN_ERR "asoc: can't open codec %s\n",
-                               codec_dai->name);
-                       goto codec_dai_err;
-               }
-       }
-
-       if (rtd->dai_link->ops && rtd->dai_link->ops->startup) {
-               ret = rtd->dai_link->ops->startup(substream);
-               if (ret < 0) {
-                       printk(KERN_ERR "asoc: %s startup failed\n", rtd->dai_link->name);
-                       goto machine_err;
-               }
-       }
-
-       /* Check that the codec and cpu DAIs are compatible */
-       if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
-               runtime->hw.rate_min =
-                       max(codec_dai_drv->playback.rate_min,
-                           cpu_dai_drv->playback.rate_min);
-               runtime->hw.rate_max =
-                       min(codec_dai_drv->playback.rate_max,
-                           cpu_dai_drv->playback.rate_max);
-               runtime->hw.channels_min =
-                       max(codec_dai_drv->playback.channels_min,
-                               cpu_dai_drv->playback.channels_min);
-               runtime->hw.channels_max =
-                       min(codec_dai_drv->playback.channels_max,
-                               cpu_dai_drv->playback.channels_max);
-               runtime->hw.formats =
-                       codec_dai_drv->playback.formats & cpu_dai_drv->playback.formats;
-               runtime->hw.rates =
-                       codec_dai_drv->playback.rates & cpu_dai_drv->playback.rates;
-               if (codec_dai_drv->playback.rates
-                          & (SNDRV_PCM_RATE_KNOT | SNDRV_PCM_RATE_CONTINUOUS))
-                       runtime->hw.rates |= cpu_dai_drv->playback.rates;
-               if (cpu_dai_drv->playback.rates
-                          & (SNDRV_PCM_RATE_KNOT | SNDRV_PCM_RATE_CONTINUOUS))
-                       runtime->hw.rates |= codec_dai_drv->playback.rates;
-       } else {
-               runtime->hw.rate_min =
-                       max(codec_dai_drv->capture.rate_min,
-                           cpu_dai_drv->capture.rate_min);
-               runtime->hw.rate_max =
-                       min(codec_dai_drv->capture.rate_max,
-                           cpu_dai_drv->capture.rate_max);
-               runtime->hw.channels_min =
-                       max(codec_dai_drv->capture.channels_min,
-                               cpu_dai_drv->capture.channels_min);
-               runtime->hw.channels_max =
-                       min(codec_dai_drv->capture.channels_max,
-                               cpu_dai_drv->capture.channels_max);
-               runtime->hw.formats =
-                       codec_dai_drv->capture.formats & cpu_dai_drv->capture.formats;
-               runtime->hw.rates =
-                       codec_dai_drv->capture.rates & cpu_dai_drv->capture.rates;
-               if (codec_dai_drv->capture.rates
-                          & (SNDRV_PCM_RATE_KNOT | SNDRV_PCM_RATE_CONTINUOUS))
-                       runtime->hw.rates |= cpu_dai_drv->capture.rates;
-               if (cpu_dai_drv->capture.rates
-                          & (SNDRV_PCM_RATE_KNOT | SNDRV_PCM_RATE_CONTINUOUS))
-                       runtime->hw.rates |= codec_dai_drv->capture.rates;
-       }
-
-       ret = -EINVAL;
-       snd_pcm_limit_hw_rates(runtime);
-       if (!runtime->hw.rates) {
-               printk(KERN_ERR "asoc: %s <-> %s No matching rates\n",
-                       codec_dai->name, cpu_dai->name);
-               goto config_err;
-       }
-       if (!runtime->hw.formats) {
-               printk(KERN_ERR "asoc: %s <-> %s No matching formats\n",
-                       codec_dai->name, cpu_dai->name);
-               goto config_err;
-       }
-       if (!runtime->hw.channels_min || !runtime->hw.channels_max ||
-           runtime->hw.channels_min > runtime->hw.channels_max) {
-               printk(KERN_ERR "asoc: %s <-> %s No matching channels\n",
-                               codec_dai->name, cpu_dai->name);
-               goto config_err;
-       }
-
-       /* Symmetry only applies if we've already got an active stream. */
-       if (cpu_dai->active || codec_dai->active) {
-               ret = soc_pcm_apply_symmetry(substream);
-               if (ret != 0)
-                       goto config_err;
-       }
-
-       pr_debug("asoc: %s <-> %s info:\n",
-                       codec_dai->name, cpu_dai->name);
-       pr_debug("asoc: rate mask 0x%x\n", runtime->hw.rates);
-       pr_debug("asoc: min ch %d max ch %d\n", runtime->hw.channels_min,
-                runtime->hw.channels_max);
-       pr_debug("asoc: min rate %d max rate %d\n", runtime->hw.rate_min,
-                runtime->hw.rate_max);
-
-       if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
-               cpu_dai->playback_active++;
-               codec_dai->playback_active++;
-       } else {
-               cpu_dai->capture_active++;
-               codec_dai->capture_active++;
-       }
-       cpu_dai->active++;
-       codec_dai->active++;
-       rtd->codec->active++;
-       mutex_unlock(&pcm_mutex);
-       return 0;
-
-config_err:
-       if (rtd->dai_link->ops && rtd->dai_link->ops->shutdown)
-               rtd->dai_link->ops->shutdown(substream);
-
-machine_err:
-       if (codec_dai->driver->ops->shutdown)
-               codec_dai->driver->ops->shutdown(substream, codec_dai);
-
-codec_dai_err:
-       if (platform->driver->ops->close)
-               platform->driver->ops->close(substream);
-
-platform_err:
-       if (cpu_dai->driver->ops->shutdown)
-               cpu_dai->driver->ops->shutdown(substream, cpu_dai);
-out:
-       mutex_unlock(&pcm_mutex);
-       return ret;
-}
-
-/*
- * Power down the audio subsystem pmdown_time msecs after close is called.
- * This is to ensure there are no pops or clicks in between any music tracks
- * due to DAPM power cycling.
- */
-static void close_delayed_work(struct work_struct *work)
-{
-       struct snd_soc_pcm_runtime *rtd =
-                       container_of(work, struct snd_soc_pcm_runtime, delayed_work.work);
-       struct snd_soc_dai *codec_dai = rtd->codec_dai;
-
-       mutex_lock(&pcm_mutex);
-
-       pr_debug("pop wq checking: %s status: %s waiting: %s\n",
-                codec_dai->driver->playback.stream_name,
-                codec_dai->playback_active ? "active" : "inactive",
-                codec_dai->pop_wait ? "yes" : "no");
-
-       /* are we waiting on this codec DAI stream */
-       if (codec_dai->pop_wait == 1) {
-               codec_dai->pop_wait = 0;
-               snd_soc_dapm_stream_event(rtd,
-                       codec_dai->driver->playback.stream_name,
-                       SND_SOC_DAPM_STREAM_STOP);
-       }
-
-       mutex_unlock(&pcm_mutex);
-}
-
-/*
- * Called by ALSA when a PCM substream is closed. Private data can be
- * freed here. The cpu DAI, codec DAI, machine and platform are also
- * shutdown.
- */
-static int soc_codec_close(struct snd_pcm_substream *substream)
-{
-       struct snd_soc_pcm_runtime *rtd = substream->private_data;
-       struct snd_soc_platform *platform = rtd->platform;
-       struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
-       struct snd_soc_dai *codec_dai = rtd->codec_dai;
-       struct snd_soc_codec *codec = rtd->codec;
-
-       mutex_lock(&pcm_mutex);
-
-       if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
-               cpu_dai->playback_active--;
-               codec_dai->playback_active--;
-       } else {
-               cpu_dai->capture_active--;
-               codec_dai->capture_active--;
-       }
-
-       cpu_dai->active--;
-       codec_dai->active--;
-       codec->active--;
-
-       /* Muting the DAC suppresses artifacts caused during digital
-        * shutdown, for example from stopping clocks.
-        */
-       if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
-               snd_soc_dai_digital_mute(codec_dai, 1);
-
-       if (cpu_dai->driver->ops->shutdown)
-               cpu_dai->driver->ops->shutdown(substream, cpu_dai);
-
-       if (codec_dai->driver->ops->shutdown)
-               codec_dai->driver->ops->shutdown(substream, codec_dai);
-
-       if (rtd->dai_link->ops && rtd->dai_link->ops->shutdown)
-               rtd->dai_link->ops->shutdown(substream);
-
-       if (platform->driver->ops->close)
-               platform->driver->ops->close(substream);
-       cpu_dai->runtime = NULL;
-
-       if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
-               /* start delayed pop wq here for playback streams */
-               codec_dai->pop_wait = 1;
-               schedule_delayed_work(&rtd->delayed_work,
-                       msecs_to_jiffies(rtd->pmdown_time));
-       } else {
-               /* capture streams can be powered down now */
-               snd_soc_dapm_stream_event(rtd,
-                       codec_dai->driver->capture.stream_name,
-                       SND_SOC_DAPM_STREAM_STOP);
-       }
-
-       mutex_unlock(&pcm_mutex);
-       return 0;
-}
-
-/*
- * Called by ALSA when the PCM substream is prepared, can set format, sample
- * rate, etc.  This function is non atomic and can be called multiple times,
- * it can refer to the runtime info.
- */
-static int soc_pcm_prepare(struct snd_pcm_substream *substream)
-{
-       struct snd_soc_pcm_runtime *rtd = substream->private_data;
-       struct snd_soc_platform *platform = rtd->platform;
-       struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
-       struct snd_soc_dai *codec_dai = rtd->codec_dai;
-       int ret = 0;
-
-       mutex_lock(&pcm_mutex);
-
-       if (rtd->dai_link->ops && rtd->dai_link->ops->prepare) {
-               ret = rtd->dai_link->ops->prepare(substream);
-               if (ret < 0) {
-                       printk(KERN_ERR "asoc: machine prepare error\n");
-                       goto out;
-               }
-       }
-
-       if (platform->driver->ops->prepare) {
-               ret = platform->driver->ops->prepare(substream);
-               if (ret < 0) {
-                       printk(KERN_ERR "asoc: platform prepare error\n");
-                       goto out;
-               }
-       }
-
-       if (codec_dai->driver->ops->prepare) {
-               ret = codec_dai->driver->ops->prepare(substream, codec_dai);
-               if (ret < 0) {
-                       printk(KERN_ERR "asoc: codec DAI prepare error\n");
-                       goto out;
-               }
-       }
-
-       if (cpu_dai->driver->ops->prepare) {
-               ret = cpu_dai->driver->ops->prepare(substream, cpu_dai);
-               if (ret < 0) {
-                       printk(KERN_ERR "asoc: cpu DAI prepare error\n");
-                       goto out;
-               }
-       }
-
-       /* cancel any delayed stream shutdown that is pending */
-       if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK &&
-           codec_dai->pop_wait) {
-               codec_dai->pop_wait = 0;
-               cancel_delayed_work(&rtd->delayed_work);
-       }
-
-       if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
-               snd_soc_dapm_stream_event(rtd,
-                                         codec_dai->driver->playback.stream_name,
-                                         SND_SOC_DAPM_STREAM_START);
-       else
-               snd_soc_dapm_stream_event(rtd,
-                                         codec_dai->driver->capture.stream_name,
-                                         SND_SOC_DAPM_STREAM_START);
-
-       snd_soc_dai_digital_mute(codec_dai, 0);
-
-out:
-       mutex_unlock(&pcm_mutex);
-       return ret;
-}
-
-/*
- * Called by ALSA when the hardware params are set by application. This
- * function can also be called multiple times and can allocate buffers
- * (using snd_pcm_lib_* ). It's non-atomic.
- */
-static int soc_pcm_hw_params(struct snd_pcm_substream *substream,
-                               struct snd_pcm_hw_params *params)
-{
-       struct snd_soc_pcm_runtime *rtd = substream->private_data;
-       struct snd_soc_platform *platform = rtd->platform;
-       struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
-       struct snd_soc_dai *codec_dai = rtd->codec_dai;
-       int ret = 0;
-
-       mutex_lock(&pcm_mutex);
-
-       if (rtd->dai_link->ops && rtd->dai_link->ops->hw_params) {
-               ret = rtd->dai_link->ops->hw_params(substream, params);
-               if (ret < 0) {
-                       printk(KERN_ERR "asoc: machine hw_params failed\n");
-                       goto out;
-               }
-       }
-
-       if (codec_dai->driver->ops->hw_params) {
-               ret = codec_dai->driver->ops->hw_params(substream, params, codec_dai);
-               if (ret < 0) {
-                       printk(KERN_ERR "asoc: can't set codec %s hw params\n",
-                               codec_dai->name);
-                       goto codec_err;
-               }
-       }
-
-       if (cpu_dai->driver->ops->hw_params) {
-               ret = cpu_dai->driver->ops->hw_params(substream, params, cpu_dai);
-               if (ret < 0) {
-                       printk(KERN_ERR "asoc: interface %s hw params failed\n",
-                               cpu_dai->name);
-                       goto interface_err;
-               }
-       }
-
-       if (platform->driver->ops->hw_params) {
-               ret = platform->driver->ops->hw_params(substream, params);
-               if (ret < 0) {
-                       printk(KERN_ERR "asoc: platform %s hw params failed\n",
-                               platform->name);
-                       goto platform_err;
-               }
-       }
-
-       rtd->rate = params_rate(params);
-
-out:
-       mutex_unlock(&pcm_mutex);
-       return ret;
-
-platform_err:
-       if (cpu_dai->driver->ops->hw_free)
-               cpu_dai->driver->ops->hw_free(substream, cpu_dai);
-
-interface_err:
-       if (codec_dai->driver->ops->hw_free)
-               codec_dai->driver->ops->hw_free(substream, codec_dai);
-
-codec_err:
-       if (rtd->dai_link->ops && rtd->dai_link->ops->hw_free)
-               rtd->dai_link->ops->hw_free(substream);
-
-       mutex_unlock(&pcm_mutex);
-       return ret;
-}
-
-/*
- * Frees resources allocated by hw_params, can be called multiple times
- */
-static int soc_pcm_hw_free(struct snd_pcm_substream *substream)
-{
-       struct snd_soc_pcm_runtime *rtd = substream->private_data;
-       struct snd_soc_platform *platform = rtd->platform;
-       struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
-       struct snd_soc_dai *codec_dai = rtd->codec_dai;
-       struct snd_soc_codec *codec = rtd->codec;
-
-       mutex_lock(&pcm_mutex);
-
-       /* apply codec digital mute */
-       if (!codec->active)
-               snd_soc_dai_digital_mute(codec_dai, 1);
-
-       /* free any machine hw params */
-       if (rtd->dai_link->ops && rtd->dai_link->ops->hw_free)
-               rtd->dai_link->ops->hw_free(substream);
-
-       /* free any DMA resources */
-       if (platform->driver->ops->hw_free)
-               platform->driver->ops->hw_free(substream);
-
-       /* now free hw params for the DAIs  */
-       if (codec_dai->driver->ops->hw_free)
-               codec_dai->driver->ops->hw_free(substream, codec_dai);
-
-       if (cpu_dai->driver->ops->hw_free)
-               cpu_dai->driver->ops->hw_free(substream, cpu_dai);
-
-       mutex_unlock(&pcm_mutex);
-       return 0;
-}
-
-static int soc_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
-{
-       struct snd_soc_pcm_runtime *rtd = substream->private_data;
-       struct snd_soc_platform *platform = rtd->platform;
-       struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
-       struct snd_soc_dai *codec_dai = rtd->codec_dai;
-       int ret;
-
-       if (codec_dai->driver->ops->trigger) {
-               ret = codec_dai->driver->ops->trigger(substream, cmd, codec_dai);
-               if (ret < 0)
-                       return ret;
-       }
-
-       if (platform->driver->ops->trigger) {
-               ret = platform->driver->ops->trigger(substream, cmd);
-               if (ret < 0)
-                       return ret;
-       }
-
-       if (cpu_dai->driver->ops->trigger) {
-               ret = cpu_dai->driver->ops->trigger(substream, cmd, cpu_dai);
-               if (ret < 0)
-                       return ret;
-       }
-       return 0;
-}
-
-/*
- * soc level wrapper for pointer callback
- * If cpu_dai, codec_dai, platform driver has the delay callback, than
- * the runtime->delay will be updated accordingly.
- */
-static snd_pcm_uframes_t soc_pcm_pointer(struct snd_pcm_substream *substream)
-{
-       struct snd_soc_pcm_runtime *rtd = substream->private_data;
-       struct snd_soc_platform *platform = rtd->platform;
-       struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
-       struct snd_soc_dai *codec_dai = rtd->codec_dai;
-       struct snd_pcm_runtime *runtime = substream->runtime;
-       snd_pcm_uframes_t offset = 0;
-       snd_pcm_sframes_t delay = 0;
-
-       if (platform->driver->ops->pointer)
-               offset = platform->driver->ops->pointer(substream);
-
-       if (cpu_dai->driver->ops->delay)
-               delay += cpu_dai->driver->ops->delay(substream, cpu_dai);
-
-       if (codec_dai->driver->ops->delay)
-               delay += codec_dai->driver->ops->delay(substream, codec_dai);
-
-       if (platform->driver->delay)
-               delay += platform->driver->delay(substream, codec_dai);
-
-       runtime->delay = delay;
-
-       return offset;
-}
-
-/* ASoC PCM operations */
-static struct snd_pcm_ops soc_pcm_ops = {
-       .open           = soc_pcm_open,
-       .close          = soc_codec_close,
-       .hw_params      = soc_pcm_hw_params,
-       .hw_free        = soc_pcm_hw_free,
-       .prepare        = soc_pcm_prepare,
-       .trigger        = soc_pcm_trigger,
-       .pointer        = soc_pcm_pointer,
-};
-
 #ifdef CONFIG_PM_SLEEP
 /* powers down audio subsystem for suspend */
 int snd_soc_suspend(struct device *dev)
@@ -1130,6 +578,7 @@ int snd_soc_suspend(struct device *dev)
                        case SND_SOC_BIAS_OFF:
                                codec->driver->suspend(codec, PMSG_SUSPEND);
                                codec->suspended = 1;
+                               codec->cache_sync = 1;
                                break;
                        default:
                                dev_dbg(codec->dev, "CODEC is on over suspend\n");
@@ -1262,7 +711,7 @@ static void soc_resume_deferred(struct work_struct *work)
 int snd_soc_resume(struct device *dev)
 {
        struct snd_soc_card *card = dev_get_drvdata(dev);
-       int i;
+       int i, ac97_control = 0;
 
        /* AC97 devices might have other drivers hanging off them so
         * need to resume immediately.  Other drivers don't have that
@@ -1271,14 +720,15 @@ int snd_soc_resume(struct device *dev)
         */
        for (i = 0; i < card->num_rtd; i++) {
                struct snd_soc_dai *cpu_dai = card->rtd[i].cpu_dai;
-               if (cpu_dai->driver->ac97_control) {
-                       dev_dbg(dev, "Resuming AC97 immediately\n");
-                       soc_resume_deferred(&card->deferred_resume_work);
-               } else {
-                       dev_dbg(dev, "Scheduling resume work\n");
-                       if (!schedule_work(&card->deferred_resume_work))
-                               dev_err(dev, "resume work item may be lost\n");
-               }
+               ac97_control |= cpu_dai->driver->ac97_control;
+       }
+       if (ac97_control) {
+               dev_dbg(dev, "Resuming AC97 immediately\n");
+               soc_resume_deferred(&card->deferred_resume_work);
+       } else {
+               dev_dbg(dev, "Scheduling resume work\n");
+               if (!schedule_work(&card->deferred_resume_work))
+                       dev_err(dev, "resume work item may be lost\n");
        }
 
        return 0;
@@ -1299,6 +749,7 @@ static int soc_bind_dai_link(struct snd_soc_card *card, int num)
        struct snd_soc_codec *codec;
        struct snd_soc_platform *platform;
        struct snd_soc_dai *codec_dai, *cpu_dai;
+       const char *platform_name;
 
        if (rtd->complete)
                return 1;
@@ -1311,10 +762,6 @@ static int soc_bind_dai_link(struct snd_soc_card *card, int num)
        /* no, then find CPU DAI from registered DAIs*/
        list_for_each_entry(cpu_dai, &dai_list, list) {
                if (!strcmp(cpu_dai->name, dai_link->cpu_dai_name)) {
-
-                       if (!try_module_get(cpu_dai->dev->driver->owner))
-                               return -ENODEV;
-
                        rtd->cpu_dai = cpu_dai;
                        goto find_codec;
                }
@@ -1351,13 +798,18 @@ find_codec:
                        dai_link->codec_name);
 
 find_platform:
-       /* do we already have the CODEC DAI for this link ? */
-       if (rtd->platform) {
+       /* do we need a platform? */
+       if (rtd->platform)
                goto out;
-       }
-       /* no, then find CPU DAI from registered DAIs*/
+
+       /* if there's no platform we match on the empty platform */
+       platform_name = dai_link->platform_name;
+       if (!platform_name)
+               platform_name = "snd-soc-dummy";
+
+       /* no, then find one from the set of registered platforms */
        list_for_each_entry(platform, &platform_list, list) {
-               if (!strcmp(platform->name, dai_link->platform_name)) {
+               if (!strcmp(platform->name, platform_name)) {
                        rtd->platform = platform;
                        goto out;
                }
@@ -1397,7 +849,7 @@ static void soc_remove_codec(struct snd_soc_codec *codec)
        module_put(codec->dev->driver->owner);
 }
 
-static void soc_remove_dai_link(struct snd_soc_card *card, int num)
+static void soc_remove_dai_link(struct snd_soc_card *card, int num, int order)
 {
        struct snd_soc_pcm_runtime *rtd = &card->rtd[num];
        struct snd_soc_codec *codec = rtd->codec;
@@ -1414,7 +866,8 @@ static void soc_remove_dai_link(struct snd_soc_card *card, int num)
        }
 
        /* remove the CODEC DAI */
-       if (codec_dai && codec_dai->probed) {
+       if (codec_dai && codec_dai->probed &&
+                       codec_dai->driver->remove_order == order) {
                if (codec_dai->driver->remove) {
                        err = codec_dai->driver->remove(codec_dai);
                        if (err < 0)
@@ -1425,7 +878,8 @@ static void soc_remove_dai_link(struct snd_soc_card *card, int num)
        }
 
        /* remove the platform */
-       if (platform && platform->probed) {
+       if (platform && platform->probed &&
+                       platform->driver->remove_order == order) {
                if (platform->driver->remove) {
                        err = platform->driver->remove(platform);
                        if (err < 0)
@@ -1437,11 +891,13 @@ static void soc_remove_dai_link(struct snd_soc_card *card, int num)
        }
 
        /* remove the CODEC */
-       if (codec && codec->probed)
+       if (codec && codec->probed &&
+                       codec->driver->remove_order == order)
                soc_remove_codec(codec);
 
        /* remove the cpu_dai */
-       if (cpu_dai && cpu_dai->probed) {
+       if (cpu_dai && cpu_dai->probed &&
+                       cpu_dai->driver->remove_order == order) {
                if (cpu_dai->driver->remove) {
                        err = cpu_dai->driver->remove(cpu_dai);
                        if (err < 0)
@@ -1455,11 +911,13 @@ static void soc_remove_dai_link(struct snd_soc_card *card, int num)
 
 static void soc_remove_dai_links(struct snd_soc_card *card)
 {
-       int i;
-
-       for (i = 0; i < card->num_rtd; i++)
-               soc_remove_dai_link(card, i);
+       int dai, order;
 
+       for (order = SND_SOC_COMP_ORDER_FIRST; order <= SND_SOC_COMP_ORDER_LAST;
+                       order++) {
+               for (dai = 0; dai < card->num_rtd; dai++)
+                       soc_remove_dai_link(card, dai, order);
+       }
        card->num_rtd = 0;
 }
 
@@ -1493,6 +951,12 @@ static int soc_probe_codec(struct snd_soc_card *card,
        if (!try_module_get(codec->dev->driver->owner))
                return -ENODEV;
 
+       soc_init_codec_debugfs(codec);
+
+       if (driver->dapm_widgets)
+               snd_soc_dapm_new_controls(&codec->dapm, driver->dapm_widgets,
+                                         driver->num_dapm_widgets);
+
        if (driver->probe) {
                ret = driver->probe(codec);
                if (ret < 0) {
@@ -1506,15 +970,10 @@ static int soc_probe_codec(struct snd_soc_card *card,
        if (driver->controls)
                snd_soc_add_controls(codec, driver->controls,
                                     driver->num_controls);
-       if (driver->dapm_widgets)
-               snd_soc_dapm_new_controls(&codec->dapm, driver->dapm_widgets,
-                                         driver->num_dapm_widgets);
        if (driver->dapm_routes)
                snd_soc_dapm_add_routes(&codec->dapm, driver->dapm_routes,
                                        driver->num_dapm_routes);
 
-       soc_init_codec_debugfs(codec);
-
        /* mark codec as probed and add to card codec list */
        codec->probed = 1;
        list_add(&codec->card_list, &card->codec_dev_list);
@@ -1523,11 +982,58 @@ static int soc_probe_codec(struct snd_soc_card *card,
        return 0;
 
 err_probe:
+       soc_cleanup_codec_debugfs(codec);
        module_put(codec->dev->driver->owner);
 
        return ret;
 }
 
+static int soc_probe_platform(struct snd_soc_card *card,
+                          struct snd_soc_platform *platform)
+{
+       int ret = 0;
+       const struct snd_soc_platform_driver *driver = platform->driver;
+
+       platform->card = card;
+       platform->dapm.card = card;
+
+       if (!try_module_get(platform->dev->driver->owner))
+               return -ENODEV;
+
+       if (driver->dapm_widgets)
+               snd_soc_dapm_new_controls(&platform->dapm,
+                       driver->dapm_widgets, driver->num_dapm_widgets);
+
+       if (driver->probe) {
+               ret = driver->probe(platform);
+               if (ret < 0) {
+                       dev_err(platform->dev,
+                               "asoc: failed to probe platform %s: %d\n",
+                               platform->name, ret);
+                       goto err_probe;
+               }
+       }
+
+       if (driver->controls)
+               snd_soc_add_platform_controls(platform, driver->controls,
+                                    driver->num_controls);
+       if (driver->dapm_routes)
+               snd_soc_dapm_add_routes(&platform->dapm, driver->dapm_routes,
+                                       driver->num_dapm_routes);
+
+       /* mark platform as probed and add to card platform list */
+       platform->probed = 1;
+       list_add(&platform->card_list, &card->platform_dev_list);
+       list_add(&platform->dapm.list, &card->dapm_list);
+
+       return 0;
+
+err_probe:
+       module_put(platform->dev->driver->owner);
+
+       return ret;
+}
+
 static void rtd_release(struct device *dev) {}
 
 static int soc_post_component_init(struct snd_soc_card *card,
@@ -1574,6 +1080,7 @@ static int soc_post_component_init(struct snd_soc_card *card,
        rtd->dev.parent = card->dev;
        rtd->dev.release = rtd_release;
        rtd->dev.init_name = name;
+       mutex_init(&rtd->pcm_mutex);
        ret = device_register(&rtd->dev);
        if (ret < 0) {
                dev_err(card->dev,
@@ -1598,7 +1105,7 @@ static int soc_post_component_init(struct snd_soc_card *card,
        return 0;
 }
 
-static int soc_probe_dai_link(struct snd_soc_card *card, int num)
+static int soc_probe_dai_link(struct snd_soc_card *card, int num, int order)
 {
        struct snd_soc_dai_link *dai_link = &card->dai_link[num];
        struct snd_soc_pcm_runtime *rtd = &card->rtd[num];
@@ -1607,7 +1114,8 @@ static int soc_probe_dai_link(struct snd_soc_card *card, int num)
        struct snd_soc_dai *codec_dai = rtd->codec_dai, *cpu_dai = rtd->cpu_dai;
        int ret;
 
-       dev_dbg(card->dev, "probe %s dai link %d\n", card->name, num);
+       dev_dbg(card->dev, "probe %s dai link %d late %d\n",
+                       card->name, num, order);
 
        /* config components */
        codec_dai->codec = codec;
@@ -1619,48 +1127,43 @@ static int soc_probe_dai_link(struct snd_soc_card *card, int num)
        rtd->pmdown_time = pmdown_time;
 
        /* probe the cpu_dai */
-       if (!cpu_dai->probed) {
+       if (!cpu_dai->probed &&
+                       cpu_dai->driver->probe_order == order) {
+               if (!try_module_get(cpu_dai->dev->driver->owner))
+                       return -ENODEV;
+
                if (cpu_dai->driver->probe) {
                        ret = cpu_dai->driver->probe(cpu_dai);
                        if (ret < 0) {
                                printk(KERN_ERR "asoc: failed to probe CPU DAI %s\n",
                                                cpu_dai->name);
+                               module_put(cpu_dai->dev->driver->owner);
                                return ret;
                        }
                }
                cpu_dai->probed = 1;
-               /* mark cpu_dai as probed and add to card cpu_dai list */
+               /* mark cpu_dai as probed and add to card dai list */
                list_add(&cpu_dai->card_list, &card->dai_dev_list);
        }
 
        /* probe the CODEC */
-       if (!codec->probed) {
+       if (!codec->probed &&
+                       codec->driver->probe_order == order) {
                ret = soc_probe_codec(card, codec);
                if (ret < 0)
                        return ret;
        }
 
        /* probe the platform */
-       if (!platform->probed) {
-               if (!try_module_get(platform->dev->driver->owner))
-                       return -ENODEV;
-
-               if (platform->driver->probe) {
-                       ret = platform->driver->probe(platform);
-                       if (ret < 0) {
-                               printk(KERN_ERR "asoc: failed to probe platform %s\n",
-                                               platform->name);
-                               module_put(platform->dev->driver->owner);
-                               return ret;
-                       }
-               }
-               /* mark platform as probed and add to card platform list */
-               platform->probed = 1;
-               list_add(&platform->card_list, &card->platform_dev_list);
+       if (!platform->probed &&
+                       platform->driver->probe_order == order) {
+               ret = soc_probe_platform(card, platform);
+               if (ret < 0)
+                       return ret;
        }
 
        /* probe the CODEC DAI */
-       if (!codec_dai->probed) {
+       if (!codec_dai->probed && codec_dai->driver->probe_order == order) {
                if (codec_dai->driver->probe) {
                        ret = codec_dai->driver->probe(codec_dai);
                        if (ret < 0) {
@@ -1670,13 +1173,14 @@ static int soc_probe_dai_link(struct snd_soc_card *card, int num)
                        }
                }
 
-               /* mark cpu_dai as probed and add to card cpu_dai list */
+               /* mark codec_dai as probed and add to card dai list */
                codec_dai->probed = 1;
                list_add(&codec_dai->card_list, &card->dai_dev_list);
        }
 
-       /* DAPM dai link stream work */
-       INIT_DELAYED_WORK(&rtd->delayed_work, close_delayed_work);
+       /* complete DAI probe during last probe */
+       if (order != SND_SOC_COMP_ORDER_LAST)
+               return 0;
 
        ret = soc_post_component_init(card, codec, num, 0);
        if (ret)
@@ -1815,7 +1319,7 @@ static void snd_soc_instantiate_card(struct snd_soc_card *card)
        struct snd_soc_codec *codec;
        struct snd_soc_codec_conf *codec_conf;
        enum snd_soc_compress_type compress_type;
-       int ret, i;
+       int ret, i, order;
 
        mutex_lock(&card->mutex);
 
@@ -1873,6 +1377,10 @@ static void snd_soc_instantiate_card(struct snd_soc_card *card)
        card->dapm.card = card;
        list_add(&card->dapm.list, &card->dapm_list);
 
+#ifdef CONFIG_DEBUG_FS
+       snd_soc_dapm_debugfs_init(&card->dapm, card->debugfs_card_root);
+#endif
+
 #ifdef CONFIG_PM_SLEEP
        /* deferred resume work */
        INIT_WORK(&card->deferred_resume_work, soc_resume_deferred);
@@ -1889,12 +1397,16 @@ static void snd_soc_instantiate_card(struct snd_soc_card *card)
                        goto card_probe_error;
        }
 
-       for (i = 0; i < card->num_links; i++) {
-               ret = soc_probe_dai_link(card, i);
-               if (ret < 0) {
-                       pr_err("asoc: failed to instantiate card %s: %d\n",
+       /* early DAI link probe */
+       for (order = SND_SOC_COMP_ORDER_FIRST; order <= SND_SOC_COMP_ORDER_LAST;
+                       order++) {
+               for (i = 0; i < card->num_links; i++) {
+                       ret = soc_probe_dai_link(card, i, order);
+                       if (ret < 0) {
+                               pr_err("asoc: failed to instantiate card %s: %d\n",
                               card->name, ret);
-                       goto probe_dai_err;
+                               goto probe_dai_err;
+                       }
                }
        }
 
@@ -1919,20 +1431,24 @@ static void snd_soc_instantiate_card(struct snd_soc_card *card)
                snd_soc_dapm_add_routes(&card->dapm, card->dapm_routes,
                                        card->num_dapm_routes);
 
-#ifdef CONFIG_DEBUG_FS
-       card->dapm.debugfs_dapm = debugfs_create_dir("dapm",
-                                                    card->debugfs_card_root);
-       if (!card->dapm.debugfs_dapm)
-               printk(KERN_WARNING
-                      "Failed to create card DAPM debugfs directory\n");
-
-       snd_soc_dapm_debugfs_init(&card->dapm);
-#endif
-
        snprintf(card->snd_card->shortname, sizeof(card->snd_card->shortname),
-                "%s",  card->name);
-       snprintf(card->snd_card->longname, sizeof(card->snd_card->longname),
                 "%s", card->name);
+       snprintf(card->snd_card->longname, sizeof(card->snd_card->longname),
+                "%s", card->long_name ? card->long_name : card->name);
+       snprintf(card->snd_card->driver, sizeof(card->snd_card->driver),
+                "%s", card->driver_name ? card->driver_name : card->name);
+       for (i = 0; i < ARRAY_SIZE(card->snd_card->driver); i++) {
+               switch (card->snd_card->driver[i]) {
+               case '_':
+               case '-':
+               case '\0':
+                       break;
+               default:
+                       if (!isalnum(card->snd_card->driver[i]))
+                               card->snd_card->driver[i] = '_';
+                       break;
+               }
+       }
 
        if (card->late_probe) {
                ret = card->late_probe(card);
@@ -2041,6 +1557,8 @@ static int soc_cleanup_card_resources(struct snd_soc_card *card)
        if (card->remove)
                card->remove(card);
 
+       snd_soc_dapm_free(&card->dapm);
+
        kfree(card->rtd);
        snd_card_free(card->snd_card);
        return 0;
@@ -2095,62 +1613,6 @@ static struct platform_driver soc_driver = {
        .remove         = soc_remove,
 };
 
-/* create a new pcm */
-static int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num)
-{
-       struct snd_soc_codec *codec = rtd->codec;
-       struct snd_soc_platform *platform = rtd->platform;
-       struct snd_soc_dai *codec_dai = rtd->codec_dai;
-       struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
-       struct snd_pcm *pcm;
-       char new_name[64];
-       int ret = 0, playback = 0, capture = 0;
-
-       /* check client and interface hw capabilities */
-       snprintf(new_name, sizeof(new_name), "%s %s-%d",
-                       rtd->dai_link->stream_name, codec_dai->name, num);
-
-       if (codec_dai->driver->playback.channels_min)
-               playback = 1;
-       if (codec_dai->driver->capture.channels_min)
-               capture = 1;
-
-       dev_dbg(rtd->card->dev, "registered pcm #%d %s\n",num,new_name);
-       ret = snd_pcm_new(rtd->card->snd_card, new_name,
-                       num, playback, capture, &pcm);
-       if (ret < 0) {
-               printk(KERN_ERR "asoc: can't create pcm for codec %s\n", codec->name);
-               return ret;
-       }
-
-       rtd->pcm = pcm;
-       pcm->private_data = rtd;
-       soc_pcm_ops.mmap = platform->driver->ops->mmap;
-       soc_pcm_ops.pointer = platform->driver->ops->pointer;
-       soc_pcm_ops.ioctl = platform->driver->ops->ioctl;
-       soc_pcm_ops.copy = platform->driver->ops->copy;
-       soc_pcm_ops.silence = platform->driver->ops->silence;
-       soc_pcm_ops.ack = platform->driver->ops->ack;
-       soc_pcm_ops.page = platform->driver->ops->page;
-
-       if (playback)
-               snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &soc_pcm_ops);
-
-       if (capture)
-               snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &soc_pcm_ops);
-
-       ret = platform->driver->pcm_new(rtd->card->snd_card, codec_dai, pcm);
-       if (ret < 0) {
-               printk(KERN_ERR "asoc: platform pcm constructor failed\n");
-               return ret;
-       }
-
-       pcm->private_free = platform->driver->pcm_free;
-       printk(KERN_INFO "asoc: %s <-> %s mapping ok\n", codec_dai->name,
-               cpu_dai->name);
-       return ret;
-}
-
 /**
  * snd_soc_codec_volatile_register: Report if a register is volatile.
  *
@@ -2183,7 +1645,7 @@ int snd_soc_codec_readable_register(struct snd_soc_codec *codec,
        if (codec->readable_register)
                return codec->readable_register(codec, reg);
        else
-               return 0;
+               return 1;
 }
 EXPORT_SYMBOL_GPL(snd_soc_codec_readable_register);
 
@@ -2201,10 +1663,42 @@ int snd_soc_codec_writable_register(struct snd_soc_codec *codec,
        if (codec->writable_register)
                return codec->writable_register(codec, reg);
        else
-               return 0;
+               return 1;
 }
 EXPORT_SYMBOL_GPL(snd_soc_codec_writable_register);
 
+int snd_soc_platform_read(struct snd_soc_platform *platform,
+                                       unsigned int reg)
+{
+       unsigned int ret;
+
+       if (!platform->driver->read) {
+               dev_err(platform->dev, "platform has no read back\n");
+               return -1;
+       }
+
+       ret = platform->driver->read(platform, reg);
+       dev_dbg(platform->dev, "read %x => %x\n", reg, ret);
+       trace_snd_soc_preg_read(platform, reg, ret);
+
+       return ret;
+}
+EXPORT_SYMBOL_GPL(snd_soc_platform_read);
+
+int snd_soc_platform_write(struct snd_soc_platform *platform,
+                                        unsigned int reg, unsigned int val)
+{
+       if (!platform->driver->write) {
+               dev_err(platform->dev, "platform has no write back\n");
+               return -1;
+       }
+
+       dev_dbg(platform->dev, "write %x = %x\n", reg, val);
+       trace_snd_soc_preg_write(platform, reg, val);
+       return platform->driver->write(platform, reg, val);
+}
+EXPORT_SYMBOL_GPL(snd_soc_platform_write);
+
 /**
  * snd_soc_new_ac97_codec - initailise AC97 device
  * @codec: audio codec
@@ -2317,7 +1811,7 @@ int snd_soc_update_bits(struct snd_soc_codec *codec, unsigned short reg,
                return ret;
 
        old = ret;
-       new = (old & ~mask) | value;
+       new = (old & ~mask) | (value & mask);
        change = old != new;
        if (change) {
                ret = snd_soc_write(codec, reg, new);
@@ -2431,7 +1925,7 @@ struct snd_kcontrol *snd_soc_cnew(const struct snd_kcontrol_new *_template,
 
        if (prefix) {
                name_len = strlen(long_name) + strlen(prefix) + 2;
-               name = kmalloc(name_len, GFP_ATOMIC);
+               name = kmalloc(name_len, GFP_KERNEL);
                if (!name)
                        return NULL;
 
@@ -2484,6 +1978,36 @@ int snd_soc_add_controls(struct snd_soc_codec *codec,
 EXPORT_SYMBOL_GPL(snd_soc_add_controls);
 
 /**
+ * snd_soc_add_platform_controls - add an array of controls to a platform.
+ * Convienience function to add a list of controls.
+ *
+ * @platform: platform to add controls to
+ * @controls: array of controls to add
+ * @num_controls: number of elements in the array
+ *
+ * Return 0 for success, else error.
+ */
+int snd_soc_add_platform_controls(struct snd_soc_platform *platform,
+       const struct snd_kcontrol_new *controls, int num_controls)
+{
+       struct snd_card *card = platform->card->snd_card;
+       int err, i;
+
+       for (i = 0; i < num_controls; i++) {
+               const struct snd_kcontrol_new *control = &controls[i];
+               err = snd_ctl_add(card, snd_soc_cnew(control, platform,
+                               control->name, NULL));
+               if (err < 0) {
+                       dev_err(platform->dev, "Failed to add %s %d\n",control->name, err);
+                       return err;
+               }
+       }
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(snd_soc_add_platform_controls);
+
+/**
  * snd_soc_info_enum_double - enumerated double mixer info callback
  * @kcontrol: mixer control
  * @uinfo: control element information
@@ -3354,6 +2878,8 @@ int snd_soc_register_card(struct snd_soc_card *card)
        if (!card->name || !card->dev)
                return -EINVAL;
 
+       dev_set_drvdata(card->dev, card);
+
        snd_soc_initialize_card_lists(card);
 
        soc_init_card_debugfs(card);
@@ -3371,6 +2897,7 @@ int snd_soc_register_card(struct snd_soc_card *card)
        INIT_LIST_HEAD(&card->list);
        card->instantiated = 0;
        mutex_init(&card->mutex);
+       mutex_init(&card->dapm_mutex);
 
        mutex_lock(&client_mutex);
        list_add(&card->list, &card_list);
@@ -3475,7 +3002,7 @@ int snd_soc_register_dai(struct device *dev,
 
        dai = kzalloc(sizeof(struct snd_soc_dai), GFP_KERNEL);
        if (dai == NULL)
-                       return -ENOMEM;
+               return -ENOMEM;
 
        /* create DAI component name */
        dai->name = fmt_single_name(dev, &dai->id);
@@ -3614,7 +3141,7 @@ int snd_soc_register_platform(struct device *dev,
 
        platform = kzalloc(sizeof(struct snd_soc_platform), GFP_KERNEL);
        if (platform == NULL)
-                       return -ENOMEM;
+               return -ENOMEM;
 
        /* create platform component name */
        platform->name = fmt_single_name(dev, &platform->id);
@@ -3625,6 +3152,8 @@ int snd_soc_register_platform(struct device *dev,
 
        platform->dev = dev;
        platform->driver = platform_drv;
+       platform->dapm.dev = dev;
+       platform->dapm.platform = platform;
 
        mutex_lock(&client_mutex);
        list_add(&platform->list, &platform_list);
@@ -3857,12 +3386,16 @@ static int __init snd_soc_init(void)
                pr_warn("ASoC: Failed to create platform list debugfs file\n");
 #endif
 
+       snd_soc_util_init();
+
        return platform_driver_register(&soc_driver);
 }
 module_init(snd_soc_init);
 
 static void __exit snd_soc_exit(void)
 {
+       snd_soc_util_exit();
+
 #ifdef CONFIG_DEBUG_FS
        debugfs_remove_recursive(snd_soc_debugfs_root);
 #endif