Skip to contentSkip to conversation

ASoC: let snd_soc_update_bits() return an error code

PATCH Applied Timur Tabi 3 participants 3 messages Jan 10, 2011 – Jan 11, 2011

Subsystems (2)
lore
Share & tools
lore

Timur Tabi

author
#0 lore raw

PATCH v2 1/1 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.

---
 sound/soc/soc-core.c |   16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)
sound/soc/soc-core.c +12 -4
index a233607..bcf2f6d 100644
@@ -2132,19 +2132,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;
 }
Signature · 1 line
1.7.3.4
Acked-by on v2 1/1
#1 lore raw
Quoted 11 lines · Timur Tabi

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.

Signature · 3 lines
Freelance Developer, SlimLogic Ltd
ASoC and Voltage Regulator Maintainer.
http://www.slimlogic.co.uk
Applied
#2 lore raw
In reply to Timur Tabi
Quoted 2 lines · Timur Tabi

Update snd_soc_update_bits() so that it returns a negative error code if the the read or write operation fails.

Applied, thanks.