Skip to content

Commit

Permalink
ASoC: wm8962: Use devm_regmap_init_i2c()
Browse files Browse the repository at this point in the history
devm_regmap_init_i2c() is device managed and makes error
handling and code cleanup simpler.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
  • Loading branch information
Sachin Kamat authored and Mark Brown committed Dec 2, 2012
1 parent 92437cb commit b439c6d
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions sound/soc/codecs/wm8962.c
Original file line number Diff line number Diff line change
Expand Up @@ -3624,7 +3624,7 @@ static __devinit int wm8962_i2c_probe(struct i2c_client *i2c,
return ret;
}

wm8962->regmap = regmap_init_i2c(i2c, &wm8962_regmap);
wm8962->regmap = devm_regmap_init_i2c(i2c, &wm8962_regmap);
if (IS_ERR(wm8962->regmap)) {
ret = PTR_ERR(wm8962->regmap);
dev_err(&i2c->dev, "Failed to allocate regmap: %d\n", ret);
Expand All @@ -3641,20 +3641,20 @@ static __devinit int wm8962_i2c_probe(struct i2c_client *i2c,
ret = regmap_read(wm8962->regmap, WM8962_SOFTWARE_RESET, &reg);
if (ret < 0) {
dev_err(&i2c->dev, "Failed to read ID register\n");
goto err_regmap;
goto err_enable;
}
if (reg != 0x6243) {
dev_err(&i2c->dev,
"Device is not a WM8962, ID %x != 0x6243\n", reg);
ret = -EINVAL;
goto err_regmap;
goto err_enable;
}

ret = regmap_read(wm8962->regmap, WM8962_RIGHT_INPUT_VOLUME, &reg);
if (ret < 0) {
dev_err(&i2c->dev, "Failed to read device revision: %d\n",
ret);
goto err_regmap;
goto err_enable;
}

dev_info(&i2c->dev, "customer id %x revision %c\n",
Expand All @@ -3667,7 +3667,7 @@ static __devinit int wm8962_i2c_probe(struct i2c_client *i2c,
ret = wm8962_reset(wm8962);
if (ret < 0) {
dev_err(&i2c->dev, "Failed to issue reset\n");
goto err_regmap;
goto err_enable;
}

if (pdata && pdata->in4_dc_measure) {
Expand All @@ -3686,15 +3686,13 @@ static __devinit int wm8962_i2c_probe(struct i2c_client *i2c,
ret = snd_soc_register_codec(&i2c->dev,
&soc_codec_dev_wm8962, &wm8962_dai, 1);
if (ret < 0)
goto err_regmap;
goto err_enable;

/* The drivers should power up as needed */
regulator_bulk_disable(ARRAY_SIZE(wm8962->supplies), wm8962->supplies);

return 0;

err_regmap:
regmap_exit(wm8962->regmap);
err_enable:
regulator_bulk_disable(ARRAY_SIZE(wm8962->supplies), wm8962->supplies);
err:
Expand All @@ -3703,10 +3701,7 @@ static __devinit int wm8962_i2c_probe(struct i2c_client *i2c,

static __devexit int wm8962_i2c_remove(struct i2c_client *client)
{
struct wm8962_priv *wm8962 = dev_get_drvdata(&client->dev);

snd_soc_unregister_codec(&client->dev);
regmap_exit(wm8962->regmap);
return 0;
}

Expand Down

0 comments on commit b439c6d

Please sign in to comment.