Merge branch 'topic/component' of git://git.kernel.org/pub/scm/linux/kernel/git/broon...
authorMark Brown <broonie@linaro.org>
Wed, 7 May 2014 09:21:22 +0000 (10:21 +0100)
committerMark Brown <broonie@linaro.org>
Wed, 7 May 2014 09:21:22 +0000 (10:21 +0100)
1  2 
include/sound/soc.h
sound/soc/soc-core.c

diff --combined include/sound/soc.h
index 3da5f2328ff3da134aa06a3b3fc6849c62386d64,c0b65fc90783b8fa1998f5252367492d2d3820c2..e84f22f89765fe4c9446b9bd55377035cd922092
                {.base = xbase, .num_regs = xregs,            \
                 .mask = xmask }) }
  
 +#define SND_SOC_BYTES_EXT(xname, xcount, xhandler_get, xhandler_put) \
 +{     .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
 +      .info = snd_soc_bytes_info_ext, \
 +      .get = xhandler_get, .put = xhandler_put, \
 +      .private_value = (unsigned long)&(struct soc_bytes_ext) \
 +              {.max = xcount} }
 +
  #define SOC_SINGLE_XR_SX(xname, xregbase, xregcount, xnbits, \
                xmin, xmax, xinvert) \
  {     .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
@@@ -400,8 -393,6 +400,6 @@@ int devm_snd_soc_register_component(str
                         const struct snd_soc_component_driver *cmpnt_drv,
                         struct snd_soc_dai_driver *dai_drv, int num_dai);
  void snd_soc_unregister_component(struct device *dev);
- int snd_soc_codec_set_cache_io(struct snd_soc_codec *codec,
-                              struct regmap *regmap);
  int snd_soc_cache_sync(struct snd_soc_codec *codec);
  int snd_soc_cache_init(struct snd_soc_codec *codec);
  int snd_soc_cache_exit(struct snd_soc_codec *codec);
@@@ -541,8 -532,6 +539,8 @@@ int snd_soc_bytes_get(struct snd_kcontr
                      struct snd_ctl_elem_value *ucontrol);
  int snd_soc_bytes_put(struct snd_kcontrol *kcontrol,
                      struct snd_ctl_elem_value *ucontrol);
 +int snd_soc_bytes_info_ext(struct snd_kcontrol *kcontrol,
 +      struct snd_ctl_elem_info *ucontrol);
  int snd_soc_info_xr_sx(struct snd_kcontrol *kcontrol,
        struct snd_ctl_elem_info *uinfo);
  int snd_soc_get_xr_sx(struct snd_kcontrol *kcontrol,
@@@ -681,6 -670,14 +679,14 @@@ struct snd_soc_component 
        const struct snd_soc_component_driver *driver;
  
        struct list_head dai_list;
+       int (*read)(struct snd_soc_component *, unsigned int, unsigned int *);
+       int (*write)(struct snd_soc_component *, unsigned int, unsigned int);
+       struct regmap *regmap;
+       int val_bytes;
+       struct mutex io_mutex;
  };
  
  /* SoC Audio Codec device */
@@@ -705,18 -702,14 +711,14 @@@ struct snd_soc_codec 
        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 */
-       unsigned int using_regmap:1; /* using regmap access */
        u32 cache_only;  /* Suppress writes to hardware */
        u32 cache_sync; /* Cache needs to be synced to hardware */
  
        /* codec IO */
        void *control_data; /* codec control (i2c/3wire) data */
        hw_write_t hw_write;
-       unsigned int (*read)(struct snd_soc_codec *, unsigned int);
-       int (*write)(struct snd_soc_codec *, unsigned int, unsigned int);
        void *reg_cache;
        struct mutex cache_rw_mutex;
-       int val_bytes;
  
        /* component */
        struct snd_soc_component component;
@@@ -755,6 -748,7 +757,7 @@@ struct snd_soc_codec_driver 
                unsigned int freq_in, unsigned int freq_out);
  
        /* codec IO */
+       struct regmap *(*get_regmap)(struct device *);
        unsigned int (*read)(struct snd_soc_codec *, unsigned int);
        int (*write)(struct snd_soc_codec *, unsigned int, unsigned int);
        unsigned int reg_cache_size;
@@@ -832,7 -826,6 +835,6 @@@ struct snd_soc_platform 
        int id;
        struct device *dev;
        const struct snd_soc_platform_driver *driver;
-       struct mutex mutex;
  
        unsigned int suspended:1; /* platform is suspended */
        unsigned int probed:1;
@@@ -1089,10 -1082,6 +1091,10 @@@ struct soc_bytes 
        u32 mask;
  };
  
 +struct soc_bytes_ext {
 +      int max;
 +};
 +
  /* multi register control */
  struct soc_mreg_control {
        long min, max;
@@@ -1141,6 -1130,22 +1143,22 @@@ unsigned int snd_soc_read(struct snd_so
  int snd_soc_write(struct snd_soc_codec *codec, unsigned int reg,
        unsigned int val);
  
+ /* component IO */
+ int snd_soc_component_read(struct snd_soc_component *component,
+       unsigned int reg, unsigned int *val);
+ int snd_soc_component_write(struct snd_soc_component *component,
+       unsigned int reg, unsigned int val);
+ int snd_soc_component_update_bits(struct snd_soc_component *component,
+       unsigned int reg, unsigned int mask, unsigned int val);
+ int snd_soc_component_update_bits_async(struct snd_soc_component *component,
+       unsigned int reg, unsigned int mask, unsigned int val);
+ void snd_soc_component_async_complete(struct snd_soc_component *component);
+ int snd_soc_component_test_bits(struct snd_soc_component *component,
+       unsigned int reg, unsigned int mask, unsigned int value);
+ int snd_soc_component_init_io(struct snd_soc_component *component,
+       struct regmap *regmap);
  /* device driver data */
  
  static inline void snd_soc_card_set_drvdata(struct snd_soc_card *card,
@@@ -1244,6 -1249,22 +1262,22 @@@ static inline bool snd_soc_codec_is_act
        return snd_soc_component_is_active(&codec->component);
  }
  
+ /**
+  * snd_soc_kcontrol_component() - Returns the component that registered the
+  *  control
+  * @kcontrol: The control for which to get the component
+  *
+  * Note: This function will work correctly if the control has been registered
+  * for a component. Either with snd_soc_add_codec_controls() or
+  * snd_soc_add_platform_controls() or via  table based setup for either a
+  * CODEC, a platform or component driver. Otherwise the behavior is undefined.
+  */
+ static inline struct snd_soc_component *snd_soc_kcontrol_component(
+       struct snd_kcontrol *kcontrol)
+ {
+       return snd_kcontrol_chip(kcontrol);
+ }
  /**
   * snd_soc_kcontrol_codec() - Returns the CODEC that registered the control
   * @kcontrol: The control for which to get the CODEC
  static inline struct snd_soc_codec *snd_soc_kcontrol_codec(
        struct snd_kcontrol *kcontrol)
  {
-       return snd_kcontrol_chip(kcontrol);
+       return snd_soc_component_to_codec(snd_soc_kcontrol_component(kcontrol));
  }
  
  /**
   * registered with snd_soc_add_platform_controls() or via table based setup of
   * a snd_soc_platform_driver. Otherwise the behavior is undefined.
   */
- static inline struct snd_soc_codec *snd_soc_kcontrol_platform(
+ static inline struct snd_soc_platform *snd_soc_kcontrol_platform(
        struct snd_kcontrol *kcontrol)
  {
-       return snd_kcontrol_chip(kcontrol);
+       return snd_soc_component_to_platform(snd_soc_kcontrol_component(kcontrol));
  }
  
  int snd_soc_util_init(void);
diff --combined sound/soc/soc-core.c
index 7fa3b4a04bd3678a63deb7442c7aac788229b020,4a381b307b084880540cb7b9e2a9e71befe2a781..520d2489d23cf62d0da6fe2fbb07948429b6cb78
@@@ -656,8 -656,8 +656,8 @@@ int snd_soc_suspend(struct device *dev
                                codec->driver->suspend(codec);
                                codec->suspended = 1;
                                codec->cache_sync = 1;
-                               if (codec->using_regmap)
-                                       regcache_mark_dirty(codec->control_data);
+                               if (codec->component.regmap)
+                                       regcache_mark_dirty(codec->component.regmap);
                                /* deactivate pins to sleep state */
                                pinctrl_pm_select_sleep_state(codec->dev);
                                break;
@@@ -847,14 -847,47 +847,47 @@@ EXPORT_SYMBOL_GPL(snd_soc_resume)
  static const struct snd_soc_dai_ops null_dai_ops = {
  };
  
+ static struct snd_soc_codec *soc_find_codec(const struct device_node *codec_of_node,
+                                           const char *codec_name)
+ {
+       struct snd_soc_codec *codec;
+       list_for_each_entry(codec, &codec_list, list) {
+               if (codec_of_node) {
+                       if (codec->dev->of_node != codec_of_node)
+                               continue;
+               } else {
+                       if (strcmp(codec->name, codec_name))
+                               continue;
+               }
+               return codec;
+       }
+       return NULL;
+ }
+ static struct snd_soc_dai *soc_find_codec_dai(struct snd_soc_codec *codec,
+                                             const char *codec_dai_name)
+ {
+       struct snd_soc_dai *codec_dai;
+       list_for_each_entry(codec_dai, &codec->component.dai_list, list) {
+               if (!strcmp(codec_dai->name, codec_dai_name)) {
+                       return codec_dai;
+               }
+       }
+       return NULL;
+ }
  static int soc_bind_dai_link(struct snd_soc_card *card, int num)
  {
        struct snd_soc_dai_link *dai_link = &card->dai_link[num];
        struct snd_soc_pcm_runtime *rtd = &card->rtd[num];
        struct snd_soc_component *component;
-       struct snd_soc_codec *codec;
        struct snd_soc_platform *platform;
-       struct snd_soc_dai *codec_dai, *cpu_dai;
+       struct snd_soc_dai *cpu_dai;
        const char *platform_name;
  
        dev_dbg(card->dev, "ASoC: binding %s at idx %d\n", dai_link->name, num);
                return -EPROBE_DEFER;
        }
  
-       /* Find CODEC from registered CODECs */
-       list_for_each_entry(codec, &codec_list, list) {
-               if (dai_link->codec_of_node) {
-                       if (codec->dev->of_node != dai_link->codec_of_node)
-                               continue;
-               } else {
-                       if (strcmp(codec->name, dai_link->codec_name))
-                               continue;
-               }
-               rtd->codec = codec;
-               /*
-                * CODEC found, so find CODEC DAI from registered DAIs from
-                * this CODEC
-                */
-               list_for_each_entry(codec_dai, &codec->component.dai_list, list) {
-                       if (!strcmp(codec_dai->name, dai_link->codec_dai_name)) {
-                               rtd->codec_dai = codec_dai;
-                               break;
-                       }
-               }
-               if (!rtd->codec_dai) {
-                       dev_err(card->dev, "ASoC: CODEC DAI %s not registered\n",
-                               dai_link->codec_dai_name);
-                       return -EPROBE_DEFER;
-               }
-       }
+       /* Find CODEC from registered list */
+       rtd->codec = soc_find_codec(dai_link->codec_of_node,
+                                   dai_link->codec_name);
        if (!rtd->codec) {
                dev_err(card->dev, "ASoC: CODEC %s not registered\n",
                        dai_link->codec_name);
                return -EPROBE_DEFER;
        }
  
+       /* Find CODEC DAI from registered list */
+       rtd->codec_dai = soc_find_codec_dai(rtd->codec,
+                                           dai_link->codec_dai_name);
+       if (!rtd->codec_dai) {
+               dev_err(card->dev, "ASoC: CODEC DAI %s not registered\n",
+                       dai_link->codec_dai_name);
+               return -EPROBE_DEFER;
+       }
        /* if there's no platform we match on the empty platform */
        platform_name = dai_link->platform_name;
        if (!platform_name && !dai_link->platform_of_node)
@@@ -988,21 -1003,10 +1003,10 @@@ static void soc_remove_codec(struct snd
        module_put(codec->dev->driver->owner);
  }
  
- static void soc_remove_link_dais(struct snd_soc_card *card, int num, int order)
+ static void soc_remove_codec_dai(struct snd_soc_dai *codec_dai, int order)
  {
-       struct snd_soc_pcm_runtime *rtd = &card->rtd[num];
-       struct snd_soc_dai *codec_dai = rtd->codec_dai, *cpu_dai = rtd->cpu_dai;
        int err;
  
-       /* unregister the rtd device */
-       if (rtd->dev_registered) {
-               device_remove_file(rtd->dev, &dev_attr_pmdown_time);
-               device_remove_file(rtd->dev, &dev_attr_codec_reg);
-               device_unregister(rtd->dev);
-               rtd->dev_registered = 0;
-       }
-       /* remove the CODEC DAI */
        if (codec_dai && codec_dai->probed &&
                        codec_dai->driver->remove_order == order) {
                if (codec_dai->driver->remove) {
                codec_dai->probed = 0;
                list_del(&codec_dai->card_list);
        }
+ }
+ static void soc_remove_link_dais(struct snd_soc_card *card, int num, int order)
+ {
+       struct snd_soc_pcm_runtime *rtd = &card->rtd[num];
+       struct snd_soc_dai *codec_dai = rtd->codec_dai, *cpu_dai = rtd->cpu_dai;
+       int err;
+       /* unregister the rtd device */
+       if (rtd->dev_registered) {
+               device_remove_file(rtd->dev, &dev_attr_pmdown_time);
+               device_remove_file(rtd->dev, &dev_attr_codec_reg);
+               device_unregister(rtd->dev);
+               rtd->dev_registered = 0;
+       }
+       /* remove the CODEC DAI */
+       soc_remove_codec_dai(codec_dai, order);
  
        /* remove the cpu_dai */
        if (cpu_dai && cpu_dai->probed &&
@@@ -1145,16 -1167,6 +1167,6 @@@ static int soc_probe_codec(struct snd_s
  
        codec->dapm.idle_bias_off = driver->idle_bias_off;
  
-       if (!codec->write && dev_get_regmap(codec->dev, NULL)) {
-               /* Set the default I/O up try regmap */
-               ret = snd_soc_codec_set_cache_io(codec, NULL);
-               if (ret < 0) {
-                       dev_err(codec->dev,
-                               "Failed to set cache I/O: %d\n", ret);
-                       goto err_probe;
-               }
-       }
        if (driver->probe) {
                ret = driver->probe(codec);
                if (ret < 0) {
@@@ -1374,6 -1386,67 +1386,67 @@@ static int soc_probe_link_components(st
        return 0;
  }
  
+ static int soc_probe_codec_dai(struct snd_soc_card *card,
+                              struct snd_soc_dai *codec_dai,
+                              int order)
+ {
+       int ret;
+       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) {
+                               dev_err(codec_dai->dev,
+                                       "ASoC: failed to probe CODEC DAI %s: %d\n",
+                                       codec_dai->name, ret);
+                               return ret;
+                       }
+               }
+               /* 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);
+       }
+       return 0;
+ }
+ static int soc_link_dai_widgets(struct snd_soc_card *card,
+                               struct snd_soc_dai_link *dai_link,
+                               struct snd_soc_dai *cpu_dai,
+                               struct snd_soc_dai *codec_dai)
+ {
+       struct snd_soc_dapm_widget *play_w, *capture_w;
+       int ret;
+       /* link the DAI widgets */
+       play_w = codec_dai->playback_widget;
+       capture_w = cpu_dai->capture_widget;
+       if (play_w && capture_w) {
+               ret = snd_soc_dapm_new_pcm(card, dai_link->params,
+                                          capture_w, play_w);
+               if (ret != 0) {
+                       dev_err(card->dev, "ASoC: Can't link %s to %s: %d\n",
+                               play_w->name, capture_w->name, ret);
+                       return ret;
+               }
+       }
+       play_w = cpu_dai->playback_widget;
+       capture_w = codec_dai->capture_widget;
+       if (play_w && capture_w) {
+               ret = snd_soc_dapm_new_pcm(card, dai_link->params,
+                                          capture_w, play_w);
+               if (ret != 0) {
+                       dev_err(card->dev, "ASoC: Can't link %s to %s: %d\n",
+                               play_w->name, capture_w->name, ret);
+                       return ret;
+               }
+       }
+       return 0;
+ }
  static int soc_probe_link_dais(struct snd_soc_card *card, int num, int order)
  {
        struct snd_soc_dai_link *dai_link = &card->dai_link[num];
        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_soc_dapm_widget *play_w, *capture_w;
        int ret;
  
        dev_dbg(card->dev, "ASoC: probe %s dai link %d late %d\n",
        }
  
        /* probe the CODEC DAI */
-       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) {
-                               dev_err(codec_dai->dev,
-                                       "ASoC: failed to probe CODEC DAI %s: %d\n",
-                                       codec_dai->name, ret);
-                               return ret;
-                       }
-               }
-               /* 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);
-       }
+       ret = soc_probe_codec_dai(card, codec_dai, order);
+       if (ret)
+               return ret;
  
        /* complete DAI probe during last probe */
        if (order != SND_SOC_COMP_ORDER_LAST)
                                                codec2codec_close_delayed_work);
  
                        /* link the DAI widgets */
-                       play_w = codec_dai->playback_widget;
-                       capture_w = cpu_dai->capture_widget;
-                       if (play_w && capture_w) {
-                               ret = snd_soc_dapm_new_pcm(card, dai_link->params,
-                                                  capture_w, play_w);
-                               if (ret != 0) {
-                                       dev_err(card->dev, "ASoC: Can't link %s to %s: %d\n",
-                                               play_w->name, capture_w->name, ret);
-                                       return ret;
-                               }
-                       }
-                       play_w = cpu_dai->playback_widget;
-                       capture_w = codec_dai->capture_widget;
-                       if (play_w && capture_w) {
-                               ret = snd_soc_dapm_new_pcm(card, dai_link->params,
-                                                  capture_w, play_w);
-                               if (ret != 0) {
-                                       dev_err(card->dev, "ASoC: Can't link %s to %s: %d\n",
-                                               play_w->name, capture_w->name, ret);
-                                       return ret;
-                               }
-                       }
+                       ret = soc_link_dai_widgets(card, dai_link,
+                                       cpu_dai, codec_dai);
+                       if (ret)
+                               return ret;
                }
        }
  
  }
  
  #ifdef CONFIG_SND_SOC_AC97_BUS
- static int soc_register_ac97_dai_link(struct snd_soc_pcm_runtime *rtd)
+ 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 (rtd->codec_dai->driver->ac97_control && !rtd->codec->ac97_registered) {
+       if (codec_dai->driver->ac97_control && !codec->ac97_registered) {
                /*
                 * It is possible that the AC97 device is already registered to
                 * the device subsystem. This happens when the device is created
                 *
                 * In those cases we don't try to register the device again.
                 */
-               if (!rtd->codec->ac97_created)
+               if (!codec->ac97_created)
                        return 0;
  
-               ret = soc_ac97_dev_register(rtd->codec);
+               ret = soc_ac97_dev_register(codec);
                if (ret < 0) {
-                       dev_err(rtd->codec->dev,
+                       dev_err(codec->dev,
                                "ASoC: AC97 device register failed: %d\n", ret);
                        return ret;
                }
  
-               rtd->codec->ac97_registered = 1;
+               codec->ac97_registered = 1;
        }
        return 0;
  }
  
- static void soc_unregister_ac97_dai_link(struct snd_soc_codec *codec)
+ static int soc_register_ac97_dai_link(struct snd_soc_pcm_runtime *rtd)
+ {
+       return soc_register_ac97_codec(rtd->codec, rtd->codec_dai);
+ }
+ static void soc_unregister_ac97_codec(struct snd_soc_codec *codec)
  {
        if (codec->ac97_registered) {
                soc_ac97_dev_unregister(codec);
                codec->ac97_registered = 0;
        }
  }
+ static void soc_unregister_ac97_dai_link(struct snd_soc_pcm_runtime *rtd)
+ {
+       soc_unregister_ac97_codec(rtd->codec);
+ }
  #endif
  
  static int soc_check_aux_dev(struct snd_soc_card *card, int num)
@@@ -1845,7 -1897,7 +1897,7 @@@ static int snd_soc_instantiate_card(str
                        dev_err(card->dev,
                                "ASoC: failed to register AC97: %d\n", ret);
                        while (--i >= 0)
-                               soc_unregister_ac97_dai_link(card->rtd[i].codec);
+                               soc_unregister_ac97_dai_link(&card->rtd[i]);
                        goto probe_aux_dev_err;
                }
        }
@@@ -2195,7 -2247,7 +2247,7 @@@ void snd_soc_free_ac97_codec(struct snd
  {
        mutex_lock(&codec->mutex);
  #ifdef CONFIG_SND_SOC_AC97_BUS
-       soc_unregister_ac97_dai_link(codec);
+       soc_unregister_ac97_codec(codec);
  #endif
        kfree(codec->ac97->bus);
        kfree(codec->ac97);
@@@ -2301,7 -2353,7 +2353,7 @@@ int snd_soc_add_codec_controls(struct s
        struct snd_card *card = codec->card->snd_card;
  
        return snd_soc_add_controls(card, codec->dev, controls, num_controls,
-                       codec->name_prefix, codec);
+                       codec->name_prefix, &codec->component);
  }
  EXPORT_SYMBOL_GPL(snd_soc_add_codec_controls);
  
@@@ -2321,7 -2373,7 +2373,7 @@@ int snd_soc_add_platform_controls(struc
        struct snd_card *card = platform->card->snd_card;
  
        return snd_soc_add_controls(card, platform->dev, controls, num_controls,
-                       NULL, platform);
+                       NULL, &platform->component);
  }
  EXPORT_SYMBOL_GPL(snd_soc_add_platform_controls);
  
@@@ -2405,12 -2457,15 +2457,15 @@@ EXPORT_SYMBOL_GPL(snd_soc_info_enum_dou
  int snd_soc_get_enum_double(struct snd_kcontrol *kcontrol,
        struct snd_ctl_elem_value *ucontrol)
  {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
        struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
        unsigned int val, item;
        unsigned int reg_val;
+       int ret;
  
-       reg_val = snd_soc_read(codec, e->reg);
+       ret = snd_soc_component_read(component, e->reg, &reg_val);
+       if (ret)
+               return ret;
        val = (reg_val >> e->shift_l) & e->mask;
        item = snd_soc_enum_val_to_item(e, val);
        ucontrol->value.enumerated.item[0] = item;
@@@ -2436,7 -2491,7 +2491,7 @@@ EXPORT_SYMBOL_GPL(snd_soc_get_enum_doub
  int snd_soc_put_enum_double(struct snd_kcontrol *kcontrol,
        struct snd_ctl_elem_value *ucontrol)
  {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
        struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
        unsigned int *item = ucontrol->value.enumerated.item;
        unsigned int val;
                mask |= e->mask << e->shift_r;
        }
  
-       return snd_soc_update_bits_locked(codec, e->reg, mask, val);
+       return snd_soc_component_update_bits(component, e->reg, mask, val);
  }
  EXPORT_SYMBOL_GPL(snd_soc_put_enum_double);
  
  /**
   * snd_soc_read_signed - Read a codec register and interprete as signed value
-  * @codec: codec
+  * @component: component
   * @reg: Register to read
   * @mask: Mask to use after shifting the register value
   * @shift: Right shift of register value
   * @sign_bit: Bit that describes if a number is negative or not.
+  * @signed_val: Pointer to where the read value should be stored
   *
   * This functions reads a codec register. The register value is shifted right
   * by 'shift' bits and masked with the given 'mask'. Afterwards it translates
   * the given registervalue into a signed integer if sign_bit is non-zero.
   *
-  * Returns the register value as signed int.
+  * Returns 0 on sucess, otherwise an error value
   */
- static int snd_soc_read_signed(struct snd_soc_codec *codec, unsigned int reg,
-               unsigned int mask, unsigned int shift, unsigned int sign_bit)
+ static int snd_soc_read_signed(struct snd_soc_component *component,
+       unsigned int reg, unsigned int mask, unsigned int shift,
+       unsigned int sign_bit, int *signed_val)
  {
        int ret;
        unsigned int val;
  
-       val = (snd_soc_read(codec, reg) >> shift) & mask;
+       ret = snd_soc_component_read(component, reg, &val);
+       if (ret < 0)
+               return ret;
+       val = (val >> shift) & mask;
  
-       if (!sign_bit)
-               return val;
+       if (!sign_bit) {
+               *signed_val = val;
+               return 0;
+       }
  
        /* non-negative number */
-       if (!(val & BIT(sign_bit)))
-               return val;
+       if (!(val & BIT(sign_bit))) {
+               *signed_val = val;
+               return 0;
+       }
  
        ret = val;
  
         */
        ret |= ~((int)(BIT(sign_bit) - 1));
  
-       return ret;
+       *signed_val = ret;
+       return 0;
  }
  
  /**
@@@ -2545,9 -2612,9 +2612,9 @@@ EXPORT_SYMBOL_GPL(snd_soc_info_volsw)
  int snd_soc_get_volsw(struct snd_kcontrol *kcontrol,
        struct snd_ctl_elem_value *ucontrol)
  {
+       struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
        struct soc_mixer_control *mc =
                (struct soc_mixer_control *)kcontrol->private_value;
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
        unsigned int reg = mc->reg;
        unsigned int reg2 = mc->rreg;
        unsigned int shift = mc->shift;
        int sign_bit = mc->sign_bit;
        unsigned int mask = (1 << fls(max)) - 1;
        unsigned int invert = mc->invert;
+       int val;
+       int ret;
  
        if (sign_bit)
                mask = BIT(sign_bit + 1) - 1;
  
-       ucontrol->value.integer.value[0] = snd_soc_read_signed(codec, reg, mask,
-                       shift, sign_bit) - min;
+       ret = snd_soc_read_signed(component, reg, mask, shift, sign_bit, &val);
+       if (ret)
+               return ret;
+       ucontrol->value.integer.value[0] = val - min;
        if (invert)
                ucontrol->value.integer.value[0] =
                        max - ucontrol->value.integer.value[0];
  
        if (snd_soc_volsw_is_stereo(mc)) {
                if (reg == reg2)
-                       ucontrol->value.integer.value[1] =
-                               snd_soc_read_signed(codec, reg, mask, rshift,
-                                               sign_bit) - min;
+                       ret = snd_soc_read_signed(component, reg, mask, rshift,
+                               sign_bit, &val);
                else
-                       ucontrol->value.integer.value[1] =
-                               snd_soc_read_signed(codec, reg2, mask, shift,
-                                               sign_bit) - min;
+                       ret = snd_soc_read_signed(component, reg2, mask, shift,
+                               sign_bit, &val);
+               if (ret)
+                       return ret;
+               ucontrol->value.integer.value[1] = val - min;
                if (invert)
                        ucontrol->value.integer.value[1] =
                                max - ucontrol->value.integer.value[1];
@@@ -2598,9 -2672,9 +2672,9 @@@ EXPORT_SYMBOL_GPL(snd_soc_get_volsw)
  int snd_soc_put_volsw(struct snd_kcontrol *kcontrol,
        struct snd_ctl_elem_value *ucontrol)
  {
+       struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
        struct soc_mixer_control *mc =
                (struct soc_mixer_control *)kcontrol->private_value;
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
        unsigned int reg = mc->reg;
        unsigned int reg2 = mc->rreg;
        unsigned int shift = mc->shift;
                        type_2r = true;
                }
        }
-       err = snd_soc_update_bits_locked(codec, reg, val_mask, val);
+       err = snd_soc_component_update_bits(component, reg, val_mask, val);
        if (err < 0)
                return err;
  
        if (type_2r)
-               err = snd_soc_update_bits_locked(codec, reg2, val_mask, val2);
+               err = snd_soc_component_update_bits(component, reg2, val_mask,
+                       val2);
  
        return err;
  }
@@@ -2659,10 -2734,9 +2734,9 @@@ EXPORT_SYMBOL_GPL(snd_soc_put_volsw)
  int snd_soc_get_volsw_sx(struct snd_kcontrol *kcontrol,
                      struct snd_ctl_elem_value *ucontrol)
  {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
        struct soc_mixer_control *mc =
            (struct soc_mixer_control *)kcontrol->private_value;
        unsigned int reg = mc->reg;
        unsigned int reg2 = mc->rreg;
        unsigned int shift = mc->shift;
        int max = mc->max;
        int min = mc->min;
        int mask = (1 << (fls(min + max) - 1)) - 1;
+       unsigned int val;
+       int ret;
  
-       ucontrol->value.integer.value[0] =
-           ((snd_soc_read(codec, reg) >> shift) - min) & mask;
+       ret = snd_soc_component_read(component, reg, &val);
+       if (ret < 0)
+               return ret;
  
-       if (snd_soc_volsw_is_stereo(mc))
-               ucontrol->value.integer.value[1] =
-                       ((snd_soc_read(codec, reg2) >> rshift) - min) & mask;
+       ucontrol->value.integer.value[0] = ((val >> shift) - min) & mask;
+       if (snd_soc_volsw_is_stereo(mc)) {
+               ret = snd_soc_component_read(component, reg2, &val);
+               if (ret < 0)
+                       return ret;
+               val = ((val >> rshift) - min) & mask;
+               ucontrol->value.integer.value[1] = val;
+       }
  
        return 0;
  }
@@@ -2694,7 -2778,7 +2778,7 @@@ EXPORT_SYMBOL_GPL(snd_soc_get_volsw_sx)
  int snd_soc_put_volsw_sx(struct snd_kcontrol *kcontrol,
                         struct snd_ctl_elem_value *ucontrol)
  {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
        struct soc_mixer_control *mc =
            (struct soc_mixer_control *)kcontrol->private_value;
  
        val = (ucontrol->value.integer.value[0] + min) & mask;
        val = val << shift;
  
-       err = snd_soc_update_bits_locked(codec, reg, val_mask, val);
+       err = snd_soc_component_update_bits(component, reg, val_mask, val);
        if (err < 0)
                return err;
  
                val2 = (ucontrol->value.integer.value[1] + min) & mask;
                val2 = val2 << rshift;
  
-               if (snd_soc_update_bits_locked(codec, reg2, val_mask, val2))
-                       return err;
+               err = snd_soc_component_update_bits(component, reg2, val_mask,
+                       val2);
        }
-       return 0;
+       return err;
  }
  EXPORT_SYMBOL_GPL(snd_soc_put_volsw_sx);
  
@@@ -2771,10 -2855,15 +2855,15 @@@ int snd_soc_get_volsw_s8(struct snd_kco
  {
        struct soc_mixer_control *mc =
                (struct soc_mixer_control *)kcontrol->private_value;
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
        unsigned int reg = mc->reg;
+       unsigned int val;
        int min = mc->min;
-       int val = snd_soc_read(codec, reg);
+       int ret;
+       ret = snd_soc_component_read(component, reg, &val);
+       if (ret)
+               return ret;
  
        ucontrol->value.integer.value[0] =
                ((signed char)(val & 0xff))-min;
@@@ -2798,7 -2887,7 +2887,7 @@@ int snd_soc_put_volsw_s8(struct snd_kco
  {
        struct soc_mixer_control *mc =
                (struct soc_mixer_control *)kcontrol->private_value;
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
        unsigned int reg = mc->reg;
        int min = mc->min;
        unsigned int val;
        val = (ucontrol->value.integer.value[0]+min) & 0xff;
        val |= ((ucontrol->value.integer.value[1]+min) & 0xff) << 8;
  
-       return snd_soc_update_bits_locked(codec, reg, 0xffff, val);
+       return snd_soc_component_update_bits(component, reg, 0xffff, val);
  }
  EXPORT_SYMBOL_GPL(snd_soc_put_volsw_s8);
  
@@@ -2855,7 -2944,7 +2944,7 @@@ int snd_soc_put_volsw_range(struct snd_
  {
        struct soc_mixer_control *mc =
                (struct soc_mixer_control *)kcontrol->private_value;
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
        unsigned int reg = mc->reg;
        unsigned int rreg = mc->rreg;
        unsigned int shift = mc->shift;
        val_mask = mask << shift;
        val = val << shift;
  
-       ret = snd_soc_update_bits_locked(codec, reg, val_mask, val);
+       ret = snd_soc_component_update_bits(component, reg, val_mask, val);
        if (ret < 0)
                return ret;
  
                val_mask = mask << shift;
                val = val << shift;
  
-               ret = snd_soc_update_bits_locked(codec, rreg, val_mask, val);
+               ret = snd_soc_component_update_bits(component, rreg, val_mask,
+                       val);
        }
  
        return ret;
@@@ -2902,9 -2992,9 +2992,9 @@@ EXPORT_SYMBOL_GPL(snd_soc_put_volsw_ran
  int snd_soc_get_volsw_range(struct snd_kcontrol *kcontrol,
        struct snd_ctl_elem_value *ucontrol)
  {
+       struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
        struct soc_mixer_control *mc =
                (struct soc_mixer_control *)kcontrol->private_value;
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
        unsigned int reg = mc->reg;
        unsigned int rreg = mc->rreg;
        unsigned int shift = mc->shift;
        int max = mc->max;
        unsigned int mask = (1 << fls(max)) - 1;
        unsigned int invert = mc->invert;
+       unsigned int val;
+       int ret;
  
-       ucontrol->value.integer.value[0] =
-               (snd_soc_read(codec, reg) >> shift) & mask;
+       ret = snd_soc_component_read(component, reg, &val);
+       if (ret)
+               return ret;
+       ucontrol->value.integer.value[0] = (val >> shift) & mask;
        if (invert)
                ucontrol->value.integer.value[0] =
                        max - ucontrol->value.integer.value[0];
                ucontrol->value.integer.value[0] - min;
  
        if (snd_soc_volsw_is_stereo(mc)) {
-               ucontrol->value.integer.value[1] =
-                       (snd_soc_read(codec, rreg) >> shift) & mask;
+               ret = snd_soc_component_read(component, rreg, &val);
+               if (ret)
+                       return ret;
+               ucontrol->value.integer.value[1] = (val >> shift) & mask;
                if (invert)
                        ucontrol->value.integer.value[1] =
                                max - ucontrol->value.integer.value[1];
@@@ -2977,11 -3075,11 +3075,11 @@@ EXPORT_SYMBOL_GPL(snd_soc_limit_volume)
  int snd_soc_bytes_info(struct snd_kcontrol *kcontrol,
                       struct snd_ctl_elem_info *uinfo)
  {
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+       struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
        struct soc_bytes *params = (void *)kcontrol->private_value;
  
        uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES;
-       uinfo->count = params->num_regs * codec->val_bytes;
+       uinfo->count = params->num_regs * component->val_bytes;
  
        return 0;
  }
@@@ -2990,20 -3088,20 +3088,20 @@@ EXPORT_SYMBOL_GPL(snd_soc_bytes_info)
  int snd_soc_bytes_get(struct snd_kcontrol *kcontrol,
                      struct snd_ctl_elem_value *ucontrol)
  {
+       struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
        struct soc_bytes *params = (void *)kcontrol->private_value;
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
        int ret;
  
-       if (codec->using_regmap)
-               ret = regmap_raw_read(codec->control_data, params->base,
+       if (component->regmap)
+               ret = regmap_raw_read(component->regmap, params->base,
                                      ucontrol->value.bytes.data,
-                                     params->num_regs * codec->val_bytes);
+                                     params->num_regs * component->val_bytes);
        else
                ret = -EINVAL;
  
        /* Hide any masked bytes to ensure consistent data reporting */
        if (ret == 0 && params->mask) {
-               switch (codec->val_bytes) {
+               switch (component->val_bytes) {
                case 1:
                        ucontrol->value.bytes.data[0] &= ~params->mask;
                        break;
@@@ -3027,16 -3125,16 +3125,16 @@@ EXPORT_SYMBOL_GPL(snd_soc_bytes_get)
  int snd_soc_bytes_put(struct snd_kcontrol *kcontrol,
                      struct snd_ctl_elem_value *ucontrol)
  {
+       struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
        struct soc_bytes *params = (void *)kcontrol->private_value;
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
        int ret, len;
        unsigned int val, mask;
        void *data;
  
-       if (!codec->using_regmap)
+       if (!component->regmap)
                return -EINVAL;
  
-       len = params->num_regs * codec->val_bytes;
+       len = params->num_regs * component->val_bytes;
  
        data = kmemdup(ucontrol->value.bytes.data, len, GFP_KERNEL | GFP_DMA);
        if (!data)
         * copy.
         */
        if (params->mask) {
-               ret = regmap_read(codec->control_data, params->base, &val);
+               ret = regmap_read(component->regmap, params->base, &val);
                if (ret != 0)
                        goto out;
  
                val &= params->mask;
  
-               switch (codec->val_bytes) {
+               switch (component->val_bytes) {
                case 1:
                        ((u8 *)data)[0] &= ~params->mask;
                        ((u8 *)data)[0] |= val;
                        break;
                case 2:
                        mask = ~params->mask;
-                       ret = regmap_parse_val(codec->control_data,
+                       ret = regmap_parse_val(component->regmap,
                                                        &mask, &mask);
                        if (ret != 0)
                                goto out;
  
                        ((u16 *)data)[0] &= mask;
  
-                       ret = regmap_parse_val(codec->control_data,
+                       ret = regmap_parse_val(component->regmap,
                                                        &val, &val);
                        if (ret != 0)
                                goto out;
                        break;
                case 4:
                        mask = ~params->mask;
-                       ret = regmap_parse_val(codec->control_data,
+                       ret = regmap_parse_val(component->regmap,
                                                        &mask, &mask);
                        if (ret != 0)
                                goto out;
  
                        ((u32 *)data)[0] &= mask;
  
-                       ret = regmap_parse_val(codec->control_data,
+                       ret = regmap_parse_val(component->regmap,
                                                        &val, &val);
                        if (ret != 0)
                                goto out;
                }
        }
  
-       ret = regmap_raw_write(codec->control_data, params->base,
+       ret = regmap_raw_write(component->regmap, params->base,
                               data, len);
  
  out:
  }
  EXPORT_SYMBOL_GPL(snd_soc_bytes_put);
  
 +int snd_soc_bytes_info_ext(struct snd_kcontrol *kcontrol,
 +                      struct snd_ctl_elem_info *ucontrol)
 +{
 +      struct soc_bytes_ext *params = (void *)kcontrol->private_value;
 +
 +      ucontrol->type = SNDRV_CTL_ELEM_TYPE_BYTES;
 +      ucontrol->count = params->max;
 +
 +      return 0;
 +}
 +EXPORT_SYMBOL_GPL(snd_soc_bytes_info_ext);
 +
  /**
   * snd_soc_info_xr_sx - signed multi register info callback
   * @kcontrol: mreg control
@@@ -3160,24 -3246,27 +3258,27 @@@ EXPORT_SYMBOL_GPL(snd_soc_info_xr_sx)
  int snd_soc_get_xr_sx(struct snd_kcontrol *kcontrol,
        struct snd_ctl_elem_value *ucontrol)
  {
+       struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
        struct soc_mreg_control *mc =
                (struct soc_mreg_control *)kcontrol->private_value;
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
        unsigned int regbase = mc->regbase;
        unsigned int regcount = mc->regcount;
-       unsigned int regwshift = codec->val_bytes * BITS_PER_BYTE;
+       unsigned int regwshift = component->val_bytes * BITS_PER_BYTE;
        unsigned int regwmask = (1<<regwshift)-1;
        unsigned int invert = mc->invert;
        unsigned long mask = (1UL<<mc->nbits)-1;
        long min = mc->min;
        long max = mc->max;
        long val = 0;
-       unsigned long regval;
+       unsigned int regval;
        unsigned int i;
+       int ret;
  
        for (i = 0; i < regcount; i++) {
-               regval = snd_soc_read(codec, regbase+i) & regwmask;
-               val |= regval << (regwshift*(regcount-i-1));
+               ret = snd_soc_component_read(component, regbase+i, &regval);
+               if (ret)
+                       return ret;
+               val |= (regval & regwmask) << (regwshift*(regcount-i-1));
        }
        val &= mask;
        if (min < 0 && val > max)
@@@ -3206,12 -3295,12 +3307,12 @@@ EXPORT_SYMBOL_GPL(snd_soc_get_xr_sx)
  int snd_soc_put_xr_sx(struct snd_kcontrol *kcontrol,
        struct snd_ctl_elem_value *ucontrol)
  {
+       struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
        struct soc_mreg_control *mc =
                (struct soc_mreg_control *)kcontrol->private_value;
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
        unsigned int regbase = mc->regbase;
        unsigned int regcount = mc->regcount;
-       unsigned int regwshift = codec->val_bytes * BITS_PER_BYTE;
+       unsigned int regwshift = component->val_bytes * BITS_PER_BYTE;
        unsigned int regwmask = (1<<regwshift)-1;
        unsigned int invert = mc->invert;
        unsigned long mask = (1UL<<mc->nbits)-1;
        for (i = 0; i < regcount; i++) {
                regval = (val >> (regwshift*(regcount-i-1))) & regwmask;
                regmask = (mask >> (regwshift*(regcount-i-1))) & regwmask;
-               err = snd_soc_update_bits_locked(codec, regbase+i,
+               err = snd_soc_component_update_bits(component, regbase+i,
                                regmask, regval);
                if (err < 0)
                        return err;
@@@ -3248,14 -3337,21 +3349,21 @@@ EXPORT_SYMBOL_GPL(snd_soc_put_xr_sx)
  int snd_soc_get_strobe(struct snd_kcontrol *kcontrol,
        struct snd_ctl_elem_value *ucontrol)
  {
+       struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
        struct soc_mixer_control *mc =
                (struct soc_mixer_control *)kcontrol->private_value;
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
        unsigned int reg = mc->reg;
        unsigned int shift = mc->shift;
        unsigned int mask = 1 << shift;
        unsigned int invert = mc->invert != 0;
-       unsigned int val = snd_soc_read(codec, reg) & mask;
+       unsigned int val;
+       int ret;
+       ret = snd_soc_component_read(component, reg, &val);
+       if (ret)
+               return ret;
+       val &= mask;
  
        if (shift != 0 && val != 0)
                val = val >> shift;
@@@ -3278,9 -3374,9 +3386,9 @@@ EXPORT_SYMBOL_GPL(snd_soc_get_strobe)
  int snd_soc_put_strobe(struct snd_kcontrol *kcontrol,
        struct snd_ctl_elem_value *ucontrol)
  {
+       struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
        struct soc_mixer_control *mc =
                (struct soc_mixer_control *)kcontrol->private_value;
-       struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
        unsigned int reg = mc->reg;
        unsigned int shift = mc->shift;
        unsigned int mask = 1 << shift;
        unsigned int val2 = (strobe ^ invert) ? 0 : mask;
        int err;
  
-       err = snd_soc_update_bits_locked(codec, reg, mask, val1);
+       err = snd_soc_component_update_bits(component, reg, mask, val1);
        if (err < 0)
                return err;
  
-       err = snd_soc_update_bits_locked(codec, reg, mask, val2);
-       return err;
+       return snd_soc_component_update_bits(component, reg, mask, val2);
  }
  EXPORT_SYMBOL_GPL(snd_soc_put_strobe);
  
@@@ -3859,6 -3954,8 +3966,8 @@@ __snd_soc_register_component(struct dev
                return -ENOMEM;
        }
  
+       mutex_init(&cmpnt->io_mutex);
        cmpnt->name = fmt_single_name(dev, &cmpnt->id);
        if (!cmpnt->name) {
                dev_err(dev, "ASoC: Failed to simplifying name\n");
@@@ -3913,6 -4010,18 +4022,18 @@@ int snd_soc_register_component(struct d
  }
  EXPORT_SYMBOL_GPL(snd_soc_register_component);
  
+ static void __snd_soc_unregister_component(struct snd_soc_component *cmpnt)
+ {
+       snd_soc_unregister_dais(cmpnt);
+       mutex_lock(&client_mutex);
+       list_del(&cmpnt->list);
+       mutex_unlock(&client_mutex);
+       dev_dbg(cmpnt->dev, "ASoC: Unregistered component '%s'\n", cmpnt->name);
+       kfree(cmpnt->name);
+ }
  /**
   * snd_soc_unregister_component - Unregister a component from the ASoC core
   *
@@@ -3928,16 -4037,27 +4049,27 @@@ void snd_soc_unregister_component(struc
        return;
  
  found:
-       snd_soc_unregister_dais(cmpnt);
+       __snd_soc_unregister_component(cmpnt);
+ }
+ EXPORT_SYMBOL_GPL(snd_soc_unregister_component);
  
-       mutex_lock(&client_mutex);
-       list_del(&cmpnt->list);
-       mutex_unlock(&client_mutex);
+ static int snd_soc_platform_drv_write(struct snd_soc_component *component,
+       unsigned int reg, unsigned int val)
+ {
+       struct snd_soc_platform *platform = snd_soc_component_to_platform(component);
  
-       dev_dbg(dev, "ASoC: Unregistered component '%s'\n", cmpnt->name);
-       kfree(cmpnt->name);
+       return platform->driver->write(platform, reg, val);
+ }
+ static int snd_soc_platform_drv_read(struct snd_soc_component *component,
+       unsigned int reg, unsigned int *val)
+ {
+       struct snd_soc_platform *platform = snd_soc_component_to_platform(component);
+       *val = platform->driver->read(platform, reg);
+       return 0;
  }
- EXPORT_SYMBOL_GPL(snd_soc_unregister_component);
  
  /**
   * snd_soc_add_platform - Add a platform to the ASoC core
@@@ -3959,8 -4079,12 +4091,12 @@@ int snd_soc_add_platform(struct device 
        platform->driver = platform_drv;
        platform->dapm.dev = dev;
        platform->dapm.platform = platform;
+       platform->dapm.component = &platform->component;
        platform->dapm.stream_event = platform_drv->stream_event;
-       mutex_init(&platform->mutex);
+       if (platform_drv->write)
+               platform->component.write = snd_soc_platform_drv_write;
+       if (platform_drv->read)
+               platform->component.read = snd_soc_platform_drv_read;
  
        /* register component */
        ret = __snd_soc_register_component(dev, &platform->component,
@@@ -4013,7 -4137,7 +4149,7 @@@ EXPORT_SYMBOL_GPL(snd_soc_register_plat
   */
  void snd_soc_remove_platform(struct snd_soc_platform *platform)
  {
-       snd_soc_unregister_component(platform->dev);
+       __snd_soc_unregister_component(&platform->component);
  
        mutex_lock(&client_mutex);
        list_del(&platform->list);
@@@ -4089,6 -4213,24 +4225,24 @@@ static void fixup_codec_formats(struct 
                        stream->formats |= codec_format_map[i];
  }
  
+ static int snd_soc_codec_drv_write(struct snd_soc_component *component,
+       unsigned int reg, unsigned int val)
+ {
+       struct snd_soc_codec *codec = snd_soc_component_to_codec(component);
+       return codec->driver->write(codec, reg, val);
+ }
+ static int snd_soc_codec_drv_read(struct snd_soc_component *component,
+       unsigned int reg, unsigned int *val)
+ {
+       struct snd_soc_codec *codec = snd_soc_component_to_codec(component);
+       *val = codec->driver->read(codec, reg);
+       return 0;
+ }
  /**
   * snd_soc_register_codec - Register a codec with the ASoC core
   *
@@@ -4100,6 -4242,7 +4254,7 @@@ int snd_soc_register_codec(struct devic
                           int num_dai)
  {
        struct snd_soc_codec *codec;
+       struct regmap *regmap;
        int ret, i;
  
        dev_dbg(dev, "codec register %s\n", dev_name(dev));
                goto fail_codec;
        }
  
-       codec->write = codec_drv->write;
-       codec->read = codec_drv->read;
+       if (codec_drv->write)
+               codec->component.write = snd_soc_codec_drv_write;
+       if (codec_drv->read)
+               codec->component.read = snd_soc_codec_drv_read;
        codec->component.ignore_pmdown_time = codec_drv->ignore_pmdown_time;
        codec->dapm.bias_level = SND_SOC_BIAS_OFF;
        codec->dapm.dev = dev;
        codec->dapm.codec = codec;
+       codec->dapm.component = &codec->component;
        codec->dapm.seq_notifier = codec_drv->seq_notifier;
        codec->dapm.stream_event = codec_drv->stream_event;
        codec->dev = dev;
        codec->driver = codec_drv;
        codec->num_dai = num_dai;
-       codec->val_bytes = codec_drv->reg_word_size;
+       codec->component.val_bytes = codec_drv->reg_word_size;
        mutex_init(&codec->mutex);
  
+       if (!codec->component.write) {
+               if (codec_drv->get_regmap)
+                       regmap = codec_drv->get_regmap(dev);
+               else
+                       regmap = dev_get_regmap(dev, NULL);
+               if (regmap) {
+                       ret = snd_soc_component_init_io(&codec->component,
+                               regmap);
+                       if (ret) {
+                               dev_err(codec->dev,
+                                               "Failed to set cache I/O:%d\n",
+                                               ret);
+                               return ret;
+                       }
+               }
+       }
        for (i = 0; i < num_dai; i++) {
                fixup_codec_formats(&dai_drv[i].playback);
                fixup_codec_formats(&dai_drv[i].capture);
@@@ -4178,7 -4342,7 +4354,7 @@@ void snd_soc_unregister_codec(struct de
        return;
  
  found:
-       snd_soc_unregister_component(dev);
+       __snd_soc_unregister_component(&codec->component);
  
        mutex_lock(&client_mutex);
        list_del(&codec->list);
@@@ -4533,7 -4697,7 +4709,7 @@@ int snd_soc_of_get_dai_name(struct devi
  
                        if (id < 0 || id >= pos->num_dai) {
                                ret = -EINVAL;
 -                              break;
 +                              continue;
                        }
  
                        ret = 0;
This page took 0.047036 seconds and 5 git commands to generate.