Skip to content

Commit

Permalink
ASoC: wm8978: 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 978545e commit ad2c175
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions sound/soc/codecs/wm8978.c
Original file line number Diff line number Diff line change
Expand Up @@ -1046,7 +1046,7 @@ static __devinit int wm8978_i2c_probe(struct i2c_client *i2c,
if (wm8978 == NULL)
return -ENOMEM;

wm8978->regmap = regmap_init_i2c(i2c, &wm8978_regmap_config);
wm8978->regmap = devm_regmap_init_i2c(i2c, &wm8978_regmap_config);
if (IS_ERR(wm8978->regmap)) {
ret = PTR_ERR(wm8978->regmap);
dev_err(&i2c->dev, "Failed to allocate regmap: %d\n", ret);
Expand All @@ -1059,29 +1059,22 @@ static __devinit int wm8978_i2c_probe(struct i2c_client *i2c,
ret = regmap_write(wm8978->regmap, WM8978_RESET, 0);
if (ret != 0) {
dev_err(&i2c->dev, "Failed to issue reset: %d\n", ret);
goto err;
return ret;
}

ret = snd_soc_register_codec(&i2c->dev,
&soc_codec_dev_wm8978, &wm8978_dai, 1);
if (ret != 0) {
dev_err(&i2c->dev, "Failed to register CODEC: %d\n", ret);
goto err;
return ret;
}

return 0;

err:
regmap_exit(wm8978->regmap);
return ret;
}

static __devexit int wm8978_i2c_remove(struct i2c_client *client)
{
struct wm8978_priv *wm8978 = i2c_get_clientdata(client);

snd_soc_unregister_codec(&client->dev);
regmap_exit(wm8978->regmap);

return 0;
}
Expand Down

0 comments on commit ad2c175

Please sign in to comment.