aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sound/soc/soc-core.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 2ff708a41119..6cc68140fa67 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -2137,19 +2137,27 @@ EXPORT_SYMBOL_GPL(snd_soc_write);
2137 * 2137 *
2138 * Writes new register value. 2138 * Writes new register value.
2139 * 2139 *
2140 * Returns 1 for change else 0. 2140 * Returns 1 for change, 0 for no change, or negative error code.
2141 */ 2141 */
2142int snd_soc_update_bits(struct snd_soc_codec *codec, unsigned short reg, 2142int snd_soc_update_bits(struct snd_soc_codec *codec, unsigned short reg,
2143 unsigned int mask, unsigned int value) 2143 unsigned int mask, unsigned int value)
2144{ 2144{
2145 int change; 2145 int change;
2146 unsigned int old, new; 2146 unsigned int old, new;
2147 int ret;
2147 2148
2148 old = snd_soc_read(codec, reg); 2149 ret = snd_soc_read(codec, reg);
2150 if (ret < 0)
2151 return ret;
2152
2153 old = ret;
2149 new = (old & ~mask) | value; 2154 new = (old & ~mask) | value;
2150 change = old != new; 2155 change = old != new;
2151 if (change) 2156 if (change) {
2152 snd_soc_write(codec, reg, new); 2157 ret = snd_soc_write(codec, reg, new);
2158 if (ret < 0)
2159 return ret;
2160 }
2153 2161
2154 return change; 2162 return change;
2155} 2163}