From: Timur Tabi Date: Mon, 10 Jan 2011 21:58:13 +0000 (-0600) Subject: ASoC: let snd_soc_update_bits() return an error code X-Git-Tag: MMI-PSA29.97-13-9~16612^2~1226^2~85 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=180c329d6b0db49687c88303e7f3754e7afdc3bf;p=GitHub%2FMotorolaMobilityLLC%2Fkernel-slsi.git 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 Acked-by: Liam Girdwood Signed-off-by: Mark Brown --- 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); * * Writes new register value. * - * Returns 1 for change else 0. + * 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, unsigned int mask, unsigned int value) { int change; unsigned int old, new; + int ret; - old = snd_soc_read(codec, reg); + ret = snd_soc_read(codec, reg); + if (ret < 0) + return ret; + + old = ret; new = (old & ~mask) | value; change = old != new; - if (change) - snd_soc_write(codec, reg, new); + if (change) { + ret = snd_soc_write(codec, reg, new); + if (ret < 0) + return ret; + } return change; }