aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/sound/soc.h1
-rw-r--r--sound/soc/soc-core.c25
-rw-r--r--sound/soc/soc-dapm.c27
-rw-r--r--sound/soc/soc-io.c1
4 files changed, 34 insertions, 20 deletions
diff --git a/include/sound/soc.h b/include/sound/soc.h
index 55381fca6e0d..2f687edd4fde 100644
--- a/include/sound/soc.h
+++ b/include/sound/soc.h
@@ -560,6 +560,7 @@ struct snd_soc_codec {
560 unsigned int ac97_created:1; /* Codec has been created by SoC */ 560 unsigned int ac97_created:1; /* Codec has been created by SoC */
561 unsigned int sysfs_registered:1; /* codec has been sysfs registered */ 561 unsigned int sysfs_registered:1; /* codec has been sysfs registered */
562 unsigned int cache_init:1; /* codec cache has been initialized */ 562 unsigned int cache_init:1; /* codec cache has been initialized */
563 unsigned int using_regmap:1; /* using regmap access */
563 u32 cache_only; /* Suppress writes to hardware */ 564 u32 cache_only; /* Suppress writes to hardware */
564 u32 cache_sync; /* Cache needs to be synced to hardware */ 565 u32 cache_sync; /* Cache needs to be synced to hardware */
565 566
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 41c8e45a23e2..35a1e639d7f9 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1869,23 +1869,28 @@ EXPORT_SYMBOL_GPL(snd_soc_bulk_write_raw);
1869int snd_soc_update_bits(struct snd_soc_codec *codec, unsigned short reg, 1869int snd_soc_update_bits(struct snd_soc_codec *codec, unsigned short reg,
1870 unsigned int mask, unsigned int value) 1870 unsigned int mask, unsigned int value)
1871{ 1871{
1872 int change; 1872 bool change;
1873 unsigned int old, new; 1873 unsigned int old, new;
1874 int ret; 1874 int ret;
1875 1875
1876 ret = snd_soc_read(codec, reg); 1876 if (codec->using_regmap) {
1877 if (ret < 0) 1877 ret = regmap_update_bits_check(codec->control_data, reg,
1878 return ret; 1878 mask, value, &change);
1879 1879 } else {
1880 old = ret; 1880 ret = snd_soc_read(codec, reg);
1881 new = (old & ~mask) | (value & mask);
1882 change = old != new;
1883 if (change) {
1884 ret = snd_soc_write(codec, reg, new);
1885 if (ret < 0) 1881 if (ret < 0)
1886 return ret; 1882 return ret;
1883
1884 old = ret;
1885 new = (old & ~mask) | (value & mask);
1886 change = old != new;
1887 if (change)
1888 ret = snd_soc_write(codec, reg, new);
1887 } 1889 }
1888 1890
1891 if (ret < 0)
1892 return ret;
1893
1889 return change; 1894 return change;
1890} 1895}
1891EXPORT_SYMBOL_GPL(snd_soc_update_bits); 1896EXPORT_SYMBOL_GPL(snd_soc_update_bits);
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index 1f55ded4047f..31a06b2b4442 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -197,21 +197,28 @@ static int soc_widget_write(struct snd_soc_dapm_widget *w, int reg, int val)
197static int soc_widget_update_bits(struct snd_soc_dapm_widget *w, 197static int soc_widget_update_bits(struct snd_soc_dapm_widget *w,
198 unsigned short reg, unsigned int mask, unsigned int value) 198 unsigned short reg, unsigned int mask, unsigned int value)
199{ 199{
200 int change; 200 bool change;
201 unsigned int old, new; 201 unsigned int old, new;
202 int ret; 202 int ret;
203 203
204 ret = soc_widget_read(w, reg); 204 if (w->codec && w->codec->using_regmap) {
205 if (ret < 0) 205 ret = regmap_update_bits_check(w->codec->control_data,
206 return ret; 206 reg, mask, value, &change);
207 207 if (ret != 0)
208 old = ret; 208 return ret;
209 new = (old & ~mask) | (value & mask); 209 } else {
210 change = old != new; 210 ret = soc_widget_read(w, reg);
211 if (change) {
212 ret = soc_widget_write(w, reg, new);
213 if (ret < 0) 211 if (ret < 0)
214 return ret; 212 return ret;
213
214 old = ret;
215 new = (old & ~mask) | (value & mask);
216 change = old != new;
217 if (change) {
218 ret = soc_widget_write(w, reg, new);
219 if (ret < 0)
220 return ret;
221 }
215 } 222 }
216 223
217 return change; 224 return change;
diff --git a/sound/soc/soc-io.c b/sound/soc/soc-io.c
index c8610cbf34a5..39ba5070ff92 100644
--- a/sound/soc/soc-io.c
+++ b/sound/soc/soc-io.c
@@ -140,6 +140,7 @@ int snd_soc_codec_set_cache_io(struct snd_soc_codec *codec,
140 140
141 case SND_SOC_REGMAP: 141 case SND_SOC_REGMAP:
142 /* Device has made its own regmap arrangements */ 142 /* Device has made its own regmap arrangements */
143 codec->using_regmap = true;
143 break; 144 break;
144 145
145 default: 146 default: