diff options
author | Timur Tabi <timur@freescale.com> | 2011-01-10 16:58:13 -0500 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2011-01-11 06:04:07 -0500 |
commit | 180c329d6b0db49687c88303e7f3754e7afdc3bf (patch) | |
tree | 9191736f71c899ac928c64f897e70181040ba4cc /sound/soc | |
parent | 4fde768ecf39360eaed44152c2556dd10c3e0ce7 (diff) |
ASoC: let snd_soc_update_bits() return an error code
Update snd_soc_update_bits() so that it returns a negative error code if the
the read or write operation fails.
Note that currently, a lot of the lower-level read functions have an unsigned
integer return type (and some of them even try to return a negative number),
but this code still appears to work in those cases.
An examination of the code shows that all current callers are compatible with
this change.
Signed-off-by: Timur Tabi <timur@freescale.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc')
-rw-r--r-- | sound/soc/soc-core.c | 16 |
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 | */ |
2142 | int snd_soc_update_bits(struct snd_soc_codec *codec, unsigned short reg, | 2142 | int 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 | } |