ASoC: wm8995: Convert to use devm_kzalloc()
Signed-off-by: Tushar Behera <tushar.behera@linaro.org>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
diff --git a/sound/soc/codecs/wm8995.c b/sound/soc/codecs/wm8995.c
index 28c89b0..2eb68c1 100644
--- a/sound/soc/codecs/wm8995.c
+++ b/sound/soc/codecs/wm8995.c
@@ -2261,7 +2261,7 @@
struct wm8995_priv *wm8995;
int ret;
- wm8995 = kzalloc(sizeof *wm8995, GFP_KERNEL);
+ wm8995 = devm_kzalloc(&spi->dev, sizeof(*wm8995), GFP_KERNEL);
if (!wm8995)
return -ENOMEM;
@@ -2271,7 +2271,7 @@
if (IS_ERR(wm8995->regmap)) {
ret = PTR_ERR(wm8995->regmap);
dev_err(&spi->dev, "Failed to register regmap: %d\n", ret);
- goto err_alloc;
+ return ret;
}
ret = snd_soc_register_codec(&spi->dev,
@@ -2284,8 +2284,6 @@
err_regmap:
regmap_exit(wm8995->regmap);
-err_alloc:
- kfree(wm8995);
return ret;
}
@@ -2295,7 +2293,6 @@
struct wm8995_priv *wm8995 = spi_get_drvdata(spi);
snd_soc_unregister_codec(&spi->dev);
regmap_exit(wm8995->regmap);
- kfree(wm8995);
return 0;
}
@@ -2316,7 +2313,7 @@
struct wm8995_priv *wm8995;
int ret;
- wm8995 = kzalloc(sizeof *wm8995, GFP_KERNEL);
+ wm8995 = devm_kzalloc(&i2c->dev, sizeof(*wm8995), GFP_KERNEL);
if (!wm8995)
return -ENOMEM;
@@ -2326,7 +2323,7 @@
if (IS_ERR(wm8995->regmap)) {
ret = PTR_ERR(wm8995->regmap);
dev_err(&i2c->dev, "Failed to register regmap: %d\n", ret);
- goto err_alloc;
+ return ret;
}
ret = snd_soc_register_codec(&i2c->dev,
@@ -2341,8 +2338,6 @@
err_regmap:
regmap_exit(wm8995->regmap);
-err_alloc:
- kfree(wm8995);
return ret;
}
@@ -2353,7 +2348,6 @@
snd_soc_unregister_codec(&client->dev);
regmap_exit(wm8995->regmap);
- kfree(wm8995);
return 0;
}