mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Lucas Tanure <tanure@linux.com>
To: Liam Girdwood <lgirdwood@gmail.com>, Mark Brown <broonie@kernel.org>
Cc: linux-kernel@vger.kernel.org,
	patches@opensource.wolfsonmicro.com,
	Jaroslav Kysela <perex@perex.cz>
Subject: [PATCH] ASoC: wm2000: Use a signed return type for regmap_read
Date: Mon, 25 Jan 2016 17:48:13 -0200	[thread overview]
Message-ID: <1453751293-28246-1-git-send-email-tanure@linux.com> (raw)

The return type "unsigned int" was used by the regmap_read() function despite
of the aspect that it will eventually return a negative error code. So, change
to signed int and get reg by reference in the parameters

Signed-off-by: Lucas Tanure <tanure@linux.com>
---
 sound/soc/codecs/wm2000.c | 25 +++++++++----------------
 1 file changed, 9 insertions(+), 16 deletions(-)

diff --git a/sound/soc/codecs/wm2000.c b/sound/soc/codecs/wm2000.c
index a67ea10..990d710 100644
--- a/sound/soc/codecs/wm2000.c
+++ b/sound/soc/codecs/wm2000.c
@@ -88,17 +88,11 @@ static int wm2000_write(struct i2c_client *i2c, unsigned int reg,
 	return regmap_write(wm2000->regmap, reg, value);
 }
 
-static unsigned int wm2000_read(struct i2c_client *i2c, unsigned int r)
+static int wm2000_read(struct i2c_client *i2c, unsigned int reg,
+			unsigned int *value)
 {
 	struct wm2000_priv *wm2000 = i2c_get_clientdata(i2c);
-	unsigned int val;
-	int ret;
-
-	ret = regmap_read(wm2000->regmap, r, &val);
-	if (ret < 0)
-		return -1;
-
-	return val;
+	return regmap_read(wm2000->regmap, reg, value);
 }
 
 static void wm2000_reset(struct wm2000_priv *wm2000)
@@ -118,11 +112,10 @@ static int wm2000_poll_bit(struct i2c_client *i2c,
 	int timeout = 4000;
 	int val;
 
-	val = wm2000_read(i2c, reg);
-
+	wm2000_read(i2c, reg, &val);
 	while (!(val & mask) && --timeout) {
 		msleep(1);
-		val = wm2000_read(i2c, reg);
+		wm2000_read(i2c, reg, &val);
 	}
 
 	if (timeout == 0)
@@ -213,7 +206,7 @@ static int wm2000_power_up(struct i2c_client *i2c, int analogue)
 			     WM2000_MODE_THERMAL_ENABLE);
 	}
 
-	ret = wm2000_read(i2c, WM2000_REG_SPEECH_CLARITY);
+	wm2000_read(i2c, WM2000_REG_SPEECH_CLARITY, &ret);
 	if (wm2000->speech_clarity)
 		ret |= WM2000_SPEECH_CLARITY;
 	else
@@ -858,9 +851,9 @@ static int wm2000_i2c_probe(struct i2c_client *i2c,
 	}
 
 	/* Verify that this is a WM2000 */
-	reg = wm2000_read(i2c, WM2000_REG_ID1);
+	wm2000_read(i2c, WM2000_REG_ID1, &reg);
 	id = reg << 8;
-	reg = wm2000_read(i2c, WM2000_REG_ID2);
+	wm2000_read(i2c, WM2000_REG_ID2, &reg);
 	id |= reg & 0xff;
 
 	if (id != 0x2000) {
@@ -869,7 +862,7 @@ static int wm2000_i2c_probe(struct i2c_client *i2c,
 		goto err_supplies;
 	}
 
-	reg = wm2000_read(i2c, WM2000_REG_REVISON);
+	wm2000_read(i2c, WM2000_REG_REVISON, &reg);
 	dev_info(&i2c->dev, "revision %c\n", reg + 'A');
 
 	wm2000->mclk = devm_clk_get(&i2c->dev, "MCLK");
-- 
2.7.0

             reply	other threads:[~2016-01-25 19:48 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-25 19:48 Lucas Tanure [this message]
2016-01-26 16:52 ` Charles Keepax

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1453751293-28246-1-git-send-email-tanure@linux.com \
    --to=tanure@linux.com \
    --cc=broonie@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=patches@opensource.wolfsonmicro.com \
    --cc=perex@perex.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome