diff options
author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2011-12-03 07:33:55 -0500 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-01-21 16:15:38 -0500 |
commit | 8a713da8d1ce9ceaf738b32e2b24f22d4432f886 (patch) | |
tree | c0fb13d21f18ed19c82e4d9214d440e34b0c474b /sound | |
parent | 278047fd654dde7ed95c8604fcefeeacc5c0bb2b (diff) |
ASoC: Use regmap update bits operation for drivers using regmap
If a driver is using regmap directly ensure that we're coherent with
non-ASoC register updates by using the regmap API directly to do our
read/modify/write cycles. This will bypass the ASoC cache but drivers
using regmap directly should not be using the ASoC cache.
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound')
-rw-r--r-- | sound/soc/soc-core.c | 25 | ||||
-rw-r--r-- | sound/soc/soc-dapm.c | 27 | ||||
-rw-r--r-- | sound/soc/soc-io.c | 1 |
3 files changed, 33 insertions, 20 deletions
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); | |||
1869 | int snd_soc_update_bits(struct snd_soc_codec *codec, unsigned short reg, | 1869 | int 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 | } |
1891 | EXPORT_SYMBOL_GPL(snd_soc_update_bits); | 1896 | EXPORT_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) | |||
197 | static int soc_widget_update_bits(struct snd_soc_dapm_widget *w, | 197 | static 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: |