All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] [v2] ASoC: let snd_soc_update_bits() return an error code
@ 2011-01-10 21:58 Timur Tabi
  2011-01-11 10:51 ` Liam Girdwood
  2011-01-11 11:04 ` Mark Brown
  0 siblings, 2 replies; 3+ messages in thread
From: Timur Tabi @ 2011-01-10 21:58 UTC (permalink / raw)
  To: alsa-devel, broonie, dp, lrg

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>
---
 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 a233607..bcf2f6d 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -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;
 }
-- 
1.7.3.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] [v2] ASoC: let snd_soc_update_bits() return an error code
  2011-01-10 21:58 [PATCH] [v2] ASoC: let snd_soc_update_bits() return an error code Timur Tabi
@ 2011-01-11 10:51 ` Liam Girdwood
  2011-01-11 11:04 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Liam Girdwood @ 2011-01-11 10:51 UTC (permalink / raw)
  To: Timur Tabi; +Cc: dp, alsa-devel, broonie

On Mon, 2011-01-10 at 15:58 -0600, Timur Tabi wrote:
> 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>
-- 
Freelance Developer, SlimLogic Ltd
ASoC and Voltage Regulator Maintainer.
http://www.slimlogic.co.uk

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] [v2] ASoC: let snd_soc_update_bits() return an error code
  2011-01-10 21:58 [PATCH] [v2] ASoC: let snd_soc_update_bits() return an error code Timur Tabi
  2011-01-11 10:51 ` Liam Girdwood
@ 2011-01-11 11:04 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2011-01-11 11:04 UTC (permalink / raw)
  To: Timur Tabi; +Cc: dp, alsa-devel, lrg

On Mon, Jan 10, 2011 at 03:58:13PM -0600, Timur Tabi wrote:
> Update snd_soc_update_bits() so that it returns a negative error code if the
> the read or write operation fails.

Applied, thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-01-11 11:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-10 21:58 [PATCH] [v2] ASoC: let snd_soc_update_bits() return an error code Timur Tabi
2011-01-11 10:51 ` Liam Girdwood
2011-01-11 11:04 ` Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.