Messages in this thread Patch in this message | | | From | Lucas Tanure <> | Subject | [PATCH] ASoC: wm2000: Use a signed return type for regmap_read | Date | Mon, 25 Jan 2016 17:48:13 -0200 |
| |
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, ®); id = reg << 8; - reg = wm2000_read(i2c, WM2000_REG_ID2); + wm2000_read(i2c, WM2000_REG_ID2, ®); 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, ®); dev_info(&i2c->dev, "revision %c\n", reg + 'A'); wm2000->mclk = devm_clk_get(&i2c->dev, "MCLK"); -- 2.7.0
| |