ASoC: wm2000: Use a signed return type for regmap_read
Subsystems (3)
PATCH 1/1 ASoC: wm2000: Use a signed return type for regmap_read
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 <[email protected]>
--- sound/soc/codecs/wm2000.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-)
sound/soc/codecs/wm2000.c +9 -16
@@ -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" );
Signature · 1 line
2.7.0
Quoted 21 lines · Lucas Tanure
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 parametersSigned-off-by Lucas Tanure <[email protected]>--- sound/soc/codecs/wm2000.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-)sound/soc/codecs/wm2000.c +2
-1@@ -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) {
sound/soc/codecs/wm2000.c static int wm2000_write(struct i2c_client *i2c, unsigned int reg, · line 95
Quoted 10 lines
sound/soc/codecs/wm2000.c +1
-8struct 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