All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ASoC: core - make IO calls return a valid errno on failure.
@ 2011-07-25 10:15 Liam Girdwood
  2011-07-25 21:22 ` Mark Brown
  0 siblings, 1 reply; 4+ messages in thread
From: Liam Girdwood @ 2011-07-25 10:15 UTC (permalink / raw)
  To: Mark Brown; +Cc: alsa-devel, Liam Girdwood

IO call failures should return an errno instead of -1

Signed-off-by: Liam Girdwood <lrg@ti.com>
---
 sound/soc/soc-core.c |    4 ++--
 sound/soc/soc-dapm.c |    4 ++--
 sound/soc/soc-io.c   |    6 +++---
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 159f144..fcf69f4 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1661,7 +1661,7 @@ int snd_soc_platform_read(struct snd_soc_platform *platform,
 
 	if (!platform->driver->read) {
 		dev_err(platform->dev, "platform has no read back\n");
-		return -1;
+		return -EINVAL;
 	}
 
 	ret = platform->driver->read(platform, reg);
@@ -1677,7 +1677,7 @@ int snd_soc_platform_write(struct snd_soc_platform *platform,
 {
 	if (!platform->driver->write) {
 		dev_err(platform->dev, "platform has no write back\n");
-		return -1;
+		return -EINVAL;
 	}
 
 	dev_dbg(platform->dev, "write %x = %x\n", reg, val);
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index 3956670..45141fa 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -132,7 +132,7 @@ static int soc_widget_read(struct snd_soc_dapm_widget *w, int reg)
 		return snd_soc_platform_read(w->platform, reg);
 
 	dev_err(w->dapm->dev, "no valid widget read method\n");
-	return -1;
+	return -EINVAL;
 }
 
 static int soc_widget_write(struct snd_soc_dapm_widget *w, int reg, int val)
@@ -143,7 +143,7 @@ static int soc_widget_write(struct snd_soc_dapm_widget *w, int reg, int val)
 		return snd_soc_platform_write(w->platform, reg, val);
 
 	dev_err(w->dapm->dev, "no valid widget write method\n");
-	return -1;
+	return -EINVAL;
 }
 
 static int soc_widget_update_bits(struct snd_soc_dapm_widget *w,
diff --git a/sound/soc/soc-io.c b/sound/soc/soc-io.c
index cca490c..166186c 100644
--- a/sound/soc/soc-io.c
+++ b/sound/soc/soc-io.c
@@ -41,7 +41,7 @@ static int do_hw_write(struct snd_soc_codec *codec, unsigned int reg,
 	    !codec->cache_bypass) {
 		ret = snd_soc_cache_write(codec, reg, value);
 		if (ret < 0)
-			return -1;
+			return ret;
 	}
 
 	if (codec->cache_only) {
@@ -67,7 +67,7 @@ static unsigned int hw_read(struct snd_soc_codec *codec, unsigned int reg)
 	    snd_soc_codec_volatile_register(codec, reg) ||
 	    codec->cache_bypass) {
 		if (codec->cache_only)
-			return -1;
+			return -EINVAL;
 
 		BUG_ON(!codec->hw_read);
 		return codec->hw_read(codec, reg);
@@ -75,7 +75,7 @@ static unsigned int hw_read(struct snd_soc_codec *codec, unsigned int reg)
 
 	ret = snd_soc_cache_read(codec, reg, &val);
 	if (ret < 0)
-		return -1;
+		return ret;
 	return val;
 }
 
-- 
1.7.4.1

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

* Re: [PATCH] ASoC: core - make IO calls return a valid errno on failure.
  2011-07-25 10:15 [PATCH] ASoC: core - make IO calls return a valid errno on failure Liam Girdwood
@ 2011-07-25 21:22 ` Mark Brown
  2011-07-26 11:18   ` Liam Girdwood
  0 siblings, 1 reply; 4+ messages in thread
From: Mark Brown @ 2011-07-25 21:22 UTC (permalink / raw)
  To: Liam Girdwood; +Cc: alsa-devel

On Mon, Jul 25, 2011 at 11:15:59AM +0100, Liam Girdwood wrote:
> IO call failures should return an errno instead of -1

Yeah, it really should but it's kind of tricky for the reads as we're
returning errors in band and we could have 32 bit registers (I'm
guessing the platform versions already do) so we lose.  :/  Not sure
what the best thing to do there is, changing to return the errors out of
band for reads is more painful than I care to contemplate.

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

* Re: [PATCH] ASoC: core - make IO calls return a valid errno on failure.
  2011-07-25 21:22 ` Mark Brown
@ 2011-07-26 11:18   ` Liam Girdwood
  2011-07-26 11:43     ` Mark Brown
  0 siblings, 1 reply; 4+ messages in thread
From: Liam Girdwood @ 2011-07-26 11:18 UTC (permalink / raw)
  To: Mark Brown; +Cc: alsa-devel

On Mon, 2011-07-25 at 23:22 +0200, Mark Brown wrote:
> On Mon, Jul 25, 2011 at 11:15:59AM +0100, Liam Girdwood wrote:
> > IO call failures should return an errno instead of -1
> 
> Yeah, it really should but it's kind of tricky for the reads as we're
> returning errors in band and we could have 32 bit registers (I'm
> guessing the platform versions already do) so we lose.  :/  Not sure
> what the best thing to do there is, changing to return the errors out of
> band for reads is more painful than I care to contemplate.

Oh, I agree it would be painful for a rework here. But why did you
suggest this sort of update in a previous patch comment ? (Unless I
misunderstood).

Liam

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

* Re: [PATCH] ASoC: core - make IO calls return a valid errno on failure.
  2011-07-26 11:18   ` Liam Girdwood
@ 2011-07-26 11:43     ` Mark Brown
  0 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2011-07-26 11:43 UTC (permalink / raw)
  To: Liam Girdwood; +Cc: alsa-devel

On Tue, Jul 26, 2011 at 12:18:19PM +0100, Liam Girdwood wrote:
> On Mon, 2011-07-25 at 23:22 +0200, Mark Brown wrote:

> > Yeah, it really should but it's kind of tricky for the reads as we're
> > returning errors in band and we could have 32 bit registers (I'm
> > guessing the platform versions already do) so we lose.  :/  Not sure
> > what the best thing to do there is, changing to return the errors out of
> > band for reads is more painful than I care to contemplate.

> Oh, I agree it would be painful for a rework here. But why did you
> suggest this sort of update in a previous patch comment ? (Unless I
> misunderstood).

Dunno the specific posting but there's two things I can think of:

- This isn't an issue for writes so they can and should pass back error
  codes, it's only reads that have trouble.

- If I see people converting an error code into -EINVAL or something I
  tend to complain about that.

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

end of thread, other threads:[~2011-07-26 11:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-25 10:15 [PATCH] ASoC: core - make IO calls return a valid errno on failure Liam Girdwood
2011-07-25 21:22 ` Mark Brown
2011-07-26 11:18   ` Liam Girdwood
2011-07-26 11:43     ` 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.