aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSachin Kamat <sachin.kamat@linaro.org>2012-11-26 06:49:45 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-12-01 23:07:28 -0500
commitad2c175b8d625188766e4cecf8911cda208e4931 (patch)
tree6d326b6ad79cd02f6f75e2ccdc34b2c4d2a6607a
parent978545e7b1a9d114eccd291dd0caf1d437b49f24 (diff)
ASoC: wm8978: Use devm_regmap_init_i2c()
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>
-rw-r--r--sound/soc/codecs/wm8978.c13
1 files changed, 3 insertions, 10 deletions
diff --git a/sound/soc/codecs/wm8978.c b/sound/soc/codecs/wm8978.c
index 4fba13678f0e..b54c9e532758 100644
--- a/sound/soc/codecs/wm8978.c
+++ b/sound/soc/codecs/wm8978.c
@@ -1046,7 +1046,7 @@ static __devinit int wm8978_i2c_probe(struct i2c_client *i2c,
1046 if (wm8978 == NULL) 1046 if (wm8978 == NULL)
1047 return -ENOMEM; 1047 return -ENOMEM;
1048 1048
1049 wm8978->regmap = regmap_init_i2c(i2c, &wm8978_regmap_config); 1049 wm8978->regmap = devm_regmap_init_i2c(i2c, &wm8978_regmap_config);
1050 if (IS_ERR(wm8978->regmap)) { 1050 if (IS_ERR(wm8978->regmap)) {
1051 ret = PTR_ERR(wm8978->regmap); 1051 ret = PTR_ERR(wm8978->regmap);
1052 dev_err(&i2c->dev, "Failed to allocate regmap: %d\n", ret); 1052 dev_err(&i2c->dev, "Failed to allocate regmap: %d\n", ret);
@@ -1059,29 +1059,22 @@ static __devinit int wm8978_i2c_probe(struct i2c_client *i2c,
1059 ret = regmap_write(wm8978->regmap, WM8978_RESET, 0); 1059 ret = regmap_write(wm8978->regmap, WM8978_RESET, 0);
1060 if (ret != 0) { 1060 if (ret != 0) {
1061 dev_err(&i2c->dev, "Failed to issue reset: %d\n", ret); 1061 dev_err(&i2c->dev, "Failed to issue reset: %d\n", ret);
1062 goto err; 1062 return ret;
1063 } 1063 }
1064 1064
1065 ret = snd_soc_register_codec(&i2c->dev, 1065 ret = snd_soc_register_codec(&i2c->dev,
1066 &soc_codec_dev_wm8978, &wm8978_dai, 1); 1066 &soc_codec_dev_wm8978, &wm8978_dai, 1);
1067 if (ret != 0) { 1067 if (ret != 0) {
1068 dev_err(&i2c->dev, "Failed to register CODEC: %d\n", ret); 1068 dev_err(&i2c->dev, "Failed to register CODEC: %d\n", ret);
1069 goto err; 1069 return ret;
1070 } 1070 }
1071 1071
1072 return 0; 1072 return 0;
1073
1074err:
1075 regmap_exit(wm8978->regmap);
1076 return ret;
1077} 1073}
1078 1074
1079static __devexit int wm8978_i2c_remove(struct i2c_client *client) 1075static __devexit int wm8978_i2c_remove(struct i2c_client *client)
1080{ 1076{
1081 struct wm8978_priv *wm8978 = i2c_get_clientdata(client);
1082
1083 snd_soc_unregister_codec(&client->dev); 1077 snd_soc_unregister_codec(&client->dev);
1084 regmap_exit(wm8978->regmap);
1085 1078
1086 return 0; 1079 return 0;
1087} 1080}