linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ASoC: wm2000: Use a signed return type for regmap_read
@ 2016-01-25 19:48 Lucas Tanure
  2016-01-26 16:52 ` Charles Keepax
  0 siblings, 1 reply; 2+ messages in thread
From: Lucas Tanure @ 2016-01-25 19:48 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown; +Cc: linux-kernel, patches, Jaroslav Kysela

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

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

end of thread, other threads:[~2016-01-26 16:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-25 19:48 [PATCH] ASoC: wm2000: Use a signed return type for regmap_read Lucas Tanure
2016-01-26 16:52 ` Charles Keepax

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).