[alsa-devel] [PATCH] ASoC: core - make IO calls return a valid errno on failure.
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; }
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.
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
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.
participants (2)
-
Liam Girdwood
-
Mark Brown