Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1317246 > unrolled thread

[PATCH] ASoC: wm2000: Use a signed return type for regmap_read

Started byLucas Tanure <tanure@linux.com>
First post2016-01-25 20:50 +0100
Last post2016-01-26 18:00 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] ASoC: wm2000: Use a signed return type for regmap_read Lucas Tanure <tanure@linux.com> - 2016-01-25 20:50 +0100
    Re: [PATCH] ASoC: wm2000: Use a signed return type for regmap_read Charles Keepax <ckeepax@opensource.wolfsonmicro.com> - 2016-01-26 18:00 +0100

#1317246 — [PATCH] ASoC: wm2000: Use a signed return type for regmap_read

FromLucas Tanure <tanure@linux.com>
Date2016-01-25 20:50 +0100
Subject[PATCH] ASoC: wm2000: Use a signed return type for regmap_read
Message-ID<qUVjc-pt-13@gated-at.bofh.it>
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

[toc] | [next] | [standalone]


#1318141

FromCharles Keepax <ckeepax@opensource.wolfsonmicro.com>
Date2016-01-26 18:00 +0100
Message-ID<qVf8f-6St-25@gated-at.bofh.it>
In reply to#1317246
On Mon, Jan 25, 2016 at 05:48:13PM -0200, Lucas Tanure wrote:
> 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);

At this point the wm2000_read function is not really adding
anything feels like we should just remove it and use regmap_read
directly.

Thanks,
Charles

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web