Merge branch 'topic/pcm' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie...
authorMark Brown <broonie@kernel.org>
Thu, 10 Aug 2017 15:56:43 +0000 (16:56 +0100)
committerMark Brown <broonie@kernel.org>
Thu, 10 Aug 2017 15:56:43 +0000 (16:56 +0100)
1  2 
include/sound/soc.h
sound/soc/soc-pcm.c

diff --combined include/sound/soc.h
index 538e9880e010eecf55a0024c3a7d18b8a2a2ca64,230b8eedd9f2602251641ac2750df1c9fa584526..df819f76cbf69fe9acda79ff50f1a00616ae42cb
@@@ -469,10 -469,10 +469,10 @@@ int snd_soc_register_codec(struct devic
                struct snd_soc_dai_driver *dai_drv, int num_dai);
  void snd_soc_unregister_codec(struct device *dev);
  int snd_soc_register_component(struct device *dev,
 -                       const struct snd_soc_component_driver *cmpnt_drv,
 +                       const struct snd_soc_component_driver *component_driver,
                         struct snd_soc_dai_driver *dai_drv, int num_dai);
  int devm_snd_soc_register_component(struct device *dev,
 -                       const struct snd_soc_component_driver *cmpnt_drv,
 +                       const struct snd_soc_component_driver *component_driver,
                         struct snd_soc_dai_driver *dai_drv, int num_dai);
  void snd_soc_unregister_component(struct device *dev);
  int snd_soc_cache_init(struct snd_soc_codec *codec);
@@@ -886,18 -886,6 +886,18 @@@ struct snd_soc_component 
  #endif
  };
  
 +struct snd_soc_rtdcom_list {
 +      struct snd_soc_component *component;
 +      struct list_head list; /* rtd::component_list */
 +};
 +struct snd_soc_component*
 +snd_soc_rtdcom_lookup(struct snd_soc_pcm_runtime *rtd,
 +                     const char *driver_name);
 +#define for_each_rtdcom(rtd, rtdcom) \
 +      list_for_each_entry(rtdcom, &(rtd)->component_list, list)
 +#define for_each_rtdcom_safe(rtd, rtdcom1, rtdcom2) \
 +      list_for_each_entry_safe(rtdcom1, rtdcom2, &(rtd)->component_list, list)
 +
  /* SoC Audio Codec device */
  struct snd_soc_codec {
        struct device *dev;
        struct list_head list;
  
        /* runtime */
 -      unsigned int cache_bypass:1; /* Suppress access to the cache */
        unsigned int cache_init:1; /* codec cache has been initialized */
  
        /* codec IO */
  
        /* component */
        struct snd_soc_component component;
 -
 -#ifdef CONFIG_DEBUG_FS
 -      struct dentry *debugfs_reg;
 -#endif
  };
  
  /* codec driver */
@@@ -1237,7 -1230,7 +1237,7 @@@ struct snd_soc_pcm_runtime 
        struct snd_pcm *pcm;
        struct snd_compr *compr;
        struct snd_soc_codec *codec;
 -      struct snd_soc_platform *platform;
 +      struct snd_soc_platform *platform; /* will be removed */
        struct snd_soc_dai *codec_dai;
        struct snd_soc_dai *cpu_dai;
  
        struct delayed_work delayed_work;
  #ifdef CONFIG_DEBUG_FS
        struct dentry *debugfs_dpcm_root;
-       struct dentry *debugfs_dpcm_state;
  #endif
  
        unsigned int num; /* 0-based and monotonic increasing */
        struct list_head list; /* rtd list of the soc card */
 +      struct list_head component_list; /* list of connected components */
  
        /* bit field */
        unsigned int dev_registered:1;
diff --combined sound/soc/soc-pcm.c
index aa4c02de9c61a6c07013c05dfb8bb825bf1d3856,2ddf6aae230ddbf13acddba0397690c49993239e..4b65aa91f64b4e177607605407df1992de0bb4f8
@@@ -450,8 -450,6 +450,8 @@@ static int soc_pcm_open(struct snd_pcm_
        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_component *component;
 +      struct snd_soc_rtdcom_list *rtdcom;
        struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
        struct snd_soc_dai *codec_dai;
        const char *codec_dai_name = "multicodec";
        pinctrl_pm_select_default_state(cpu_dai->dev);
        for (i = 0; i < rtd->num_codecs; i++)
                pinctrl_pm_select_default_state(rtd->codec_dais[i]->dev);
 -      pm_runtime_get_sync(cpu_dai->dev);
 -      for (i = 0; i < rtd->num_codecs; i++)
 -              pm_runtime_get_sync(rtd->codec_dais[i]->dev);
 -      pm_runtime_get_sync(platform->dev);
 +
 +      for_each_rtdcom(rtd, rtdcom) {
 +              component = rtdcom->component;
 +
 +              pm_runtime_get_sync(component->dev);
 +      }
  
        mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass);
  
@@@ -603,13 -599,15 +603,13 @@@ platform_err
  out:
        mutex_unlock(&rtd->pcm_mutex);
  
 -      pm_runtime_mark_last_busy(platform->dev);
 -      pm_runtime_put_autosuspend(platform->dev);
 -      for (i = 0; i < rtd->num_codecs; i++) {
 -              pm_runtime_mark_last_busy(rtd->codec_dais[i]->dev);
 -              pm_runtime_put_autosuspend(rtd->codec_dais[i]->dev);
 +      for_each_rtdcom(rtd, rtdcom) {
 +              component = rtdcom->component;
 +
 +              pm_runtime_mark_last_busy(component->dev);
 +              pm_runtime_put_autosuspend(component->dev);
        }
  
 -      pm_runtime_mark_last_busy(cpu_dai->dev);
 -      pm_runtime_put_autosuspend(cpu_dai->dev);
        for (i = 0; i < rtd->num_codecs; i++) {
                if (!rtd->codec_dais[i]->active)
                        pinctrl_pm_select_sleep_state(rtd->codec_dais[i]->dev);
@@@ -657,8 -655,6 +657,8 @@@ static int soc_pcm_close(struct snd_pcm
  {
        struct snd_soc_pcm_runtime *rtd = substream->private_data;
        struct snd_soc_platform *platform = rtd->platform;
 +      struct snd_soc_component *component;
 +      struct snd_soc_rtdcom_list *rtdcom;
        struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
        struct snd_soc_dai *codec_dai;
        int i;
  
        mutex_unlock(&rtd->pcm_mutex);
  
 -      pm_runtime_mark_last_busy(platform->dev);
 -      pm_runtime_put_autosuspend(platform->dev);
 +      for_each_rtdcom(rtd, rtdcom) {
 +              component = rtdcom->component;
  
 -      for (i = 0; i < rtd->num_codecs; i++) {
 -              pm_runtime_mark_last_busy(rtd->codec_dais[i]->dev);
 -              pm_runtime_put_autosuspend(rtd->codec_dais[i]->dev);
 +              pm_runtime_mark_last_busy(component->dev);
 +              pm_runtime_put_autosuspend(component->dev);
        }
  
 -      pm_runtime_mark_last_busy(cpu_dai->dev);
 -      pm_runtime_put_autosuspend(cpu_dai->dev);
 -
        for (i = 0; i < rtd->num_codecs; i++) {
                if (!rtd->codec_dais[i]->active)
                        pinctrl_pm_select_sleep_state(rtd->codec_dais[i]->dev);
@@@ -3010,8 -3010,7 +3010,7 @@@ void soc_dpcm_debugfs_add(struct snd_so
                return;
        }
  
-       rtd->debugfs_dpcm_state = debugfs_create_file("state", 0444,
-                                               rtd->debugfs_dpcm_root,
-                                               rtd, &dpcm_state_fops);
+       debugfs_create_file("state", 0444, rtd->debugfs_dpcm_root,
+                           rtd, &dpcm_state_fops);
  }
  #endif