ASoC: core: Allow snd_soc_update_bits use 32 bits register
[firefly-linux-kernel-4.4.55.git] / sound / soc / soc-core.c
index 359c2849b364b3c78ec0824d864dadb3125b4294..7f0a9297e42087b3507da184f93ca1f36798a8f9 100644 (file)
@@ -1127,16 +1127,41 @@ static int soc_probe_codec(struct snd_soc_card *card,
 
        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->dapm_widgets) {
+               ret = snd_soc_dapm_new_controls(&codec->dapm,
+                                               driver->dapm_widgets,
+                                               driver->num_dapm_widgets);
+
+               if (ret != 0) {
+                       dev_err(codec->dev,
+                               "Failed to create new controls %d\n", ret);
+                       goto err_probe;
+               }
+       }
 
        /* Create DAPM widgets for each DAI stream */
-       list_for_each_entry(dai, &codec->component.dai_list, list)
-               snd_soc_dapm_new_dai_widgets(&codec->dapm, dai);
+       list_for_each_entry(dai, &codec->component.dai_list, list) {
+               ret = snd_soc_dapm_new_dai_widgets(&codec->dapm, dai);
+
+               if (ret != 0) {
+                       dev_err(codec->dev,
+                               "Failed to create DAI widgets %d\n", ret);
+                       goto err_probe;
+               }
+       }
 
        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) {
@@ -1150,10 +1175,6 @@ static int soc_probe_codec(struct snd_soc_card *card,
                        codec->name);
        }
 
-       /* If the driver didn't set I/O up try regmap */
-       if (!codec->write && dev_get_regmap(codec->dev, NULL))
-               snd_soc_codec_set_cache_io(codec, 0, 0, SND_SOC_REGMAP);
-
        if (driver->controls)
                snd_soc_add_codec_controls(codec, driver->controls,
                                     driver->num_controls);
@@ -1247,7 +1268,7 @@ static int soc_post_component_init(struct snd_soc_card *card,
        struct snd_soc_dai_link *dai_link = NULL;
        struct snd_soc_aux_dev *aux_dev = NULL;
        struct snd_soc_pcm_runtime *rtd;
-       const char *temp, *name;
+       const char *name;
        int ret = 0;
 
        if (!dailess) {
@@ -1261,10 +1282,6 @@ static int soc_post_component_init(struct snd_soc_card *card,
        }
        rtd->card = card;
 
-       /* machine controls, routes and widgets are not prefixed */
-       temp = codec->name_prefix;
-       codec->name_prefix = NULL;
-
        /* do machine specific initialization */
        if (!dailess && dai_link->init)
                ret = dai_link->init(rtd);
@@ -1274,7 +1291,6 @@ static int soc_post_component_init(struct snd_soc_card *card,
                dev_err(card->dev, "ASoC: failed to init %s: %d\n", name, ret);
                return ret;
        }
-       codec->name_prefix = temp;
 
        /* register the rtd device */
        rtd->codec = codec;
@@ -1655,7 +1671,7 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card)
        }
 
        /* card bind complete so register a sound card */
-       ret = snd_card_create(SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1,
+       ret = snd_card_new(card->dev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1,
                        card->owner, 0, &card->snd_card);
        if (ret < 0) {
                dev_err(card->dev,
@@ -1663,7 +1679,6 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card)
                        card->name, ret);
                goto base_error;
        }
-       card->snd_card->dev = card->dev;
 
        card->dapm.bias_level = SND_SOC_BIAS_OFF;
        card->dapm.dev = card->dev;
@@ -2315,7 +2330,7 @@ EXPORT_SYMBOL_GPL(snd_soc_write);
  *
  * Returns 1 for change, 0 for no change, or negative error code.
  */
-int snd_soc_update_bits(struct snd_soc_codec *codec, unsigned short reg,
+int snd_soc_update_bits(struct snd_soc_codec *codec, unsigned int reg,
                                unsigned int mask, unsigned int value)
 {
        bool change;
@@ -2356,7 +2371,7 @@ EXPORT_SYMBOL_GPL(snd_soc_update_bits);
  * Returns 1 for change else 0.
  */
 int snd_soc_update_bits_locked(struct snd_soc_codec *codec,
-                              unsigned short reg, unsigned int mask,
+                              unsigned int reg, unsigned int mask,
                               unsigned int value)
 {
        int change;
@@ -2381,7 +2396,7 @@ EXPORT_SYMBOL_GPL(snd_soc_update_bits_locked);
  *
  * Returns 1 for change else 0.
  */
-int snd_soc_test_bits(struct snd_soc_codec *codec, unsigned short reg,
+int snd_soc_test_bits(struct snd_soc_codec *codec, unsigned int reg,
                                unsigned int mask, unsigned int value)
 {
        int change;
@@ -2896,7 +2911,7 @@ int snd_soc_put_volsw_sx(struct snd_kcontrol *kcontrol,
        int min = mc->min;
        int mask = (1 << (fls(min + max) - 1)) - 1;
        int err = 0;
-       unsigned short val, val_mask, val2 = 0;
+       unsigned int val, val_mask, val2 = 0;
 
        val_mask = mask << shift;
        val = (ucontrol->value.integer.value[0] + min) & mask;
@@ -3619,14 +3634,14 @@ int snd_soc_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
 EXPORT_SYMBOL_GPL(snd_soc_dai_set_fmt);
 
 /**
- * snd_soc_of_xlate_tdm_slot - generate tx/rx slot mask.
+ * snd_soc_xlate_tdm_slot - generate tx/rx slot mask.
  * @slots: Number of slots in use.
  * @tx_mask: bitmask representing active TX slots.
  * @rx_mask: bitmask representing active RX slots.
  *
  * Generates the TDM tx and rx slot default masks for DAI.
  */
-static int snd_soc_of_xlate_tdm_slot_mask(unsigned int slots,
+static int snd_soc_xlate_tdm_slot_mask(unsigned int slots,
                                          unsigned int *tx_mask,
                                          unsigned int *rx_mask)
 {
@@ -3656,11 +3671,11 @@ static int snd_soc_of_xlate_tdm_slot_mask(unsigned int slots,
 int snd_soc_dai_set_tdm_slot(struct snd_soc_dai *dai,
        unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width)
 {
-       if (dai->driver && dai->driver->ops->of_xlate_tdm_slot_mask)
-               dai->driver->ops->of_xlate_tdm_slot_mask(slots,
+       if (dai->driver && dai->driver->ops->xlate_tdm_slot_mask)
+               dai->driver->ops->xlate_tdm_slot_mask(slots,
                                                &tx_mask, &rx_mask);
        else
-               snd_soc_of_xlate_tdm_slot_mask(slots, &tx_mask, &rx_mask);
+               snd_soc_xlate_tdm_slot_mask(slots, &tx_mask, &rx_mask);
 
        if (dai->driver && dai->driver->ops->set_tdm_slot)
                return dai->driver->ops->set_tdm_slot(dai, tx_mask, rx_mask,