[alsa-devel] [PATCH 1/3] ASoC: Convert wm1250-ev1 driver to use devm_kzalloc()
Signed-off-by: Mark Brown broonie@opensource.wolfsonmicro.com --- sound/soc/codecs/wm1250-ev1.c | 10 +++------- 1 files changed, 3 insertions(+), 7 deletions(-)
diff --git a/sound/soc/codecs/wm1250-ev1.c b/sound/soc/codecs/wm1250-ev1.c index cd0ec0f..aefb4f8 100644 --- a/sound/soc/codecs/wm1250-ev1.c +++ b/sound/soc/codecs/wm1250-ev1.c @@ -116,7 +116,7 @@ static int __devinit wm1250_ev1_pdata(struct i2c_client *i2c) if (!pdata) return 0;
- wm1250 = kzalloc(sizeof(*wm1250), GFP_KERNEL); + wm1250 = devm_kzalloc(&i2c->dev, sizeof(*wm1250), GFP_KERNEL); if (!wm1250) { dev_err(&i2c->dev, "Unable to allocate private data\n"); ret = -ENOMEM; @@ -134,15 +134,13 @@ static int __devinit wm1250_ev1_pdata(struct i2c_client *i2c) ret = gpio_request_array(wm1250->gpios, ARRAY_SIZE(wm1250->gpios)); if (ret != 0) { dev_err(&i2c->dev, "Failed to get GPIOs: %d\n", ret); - goto err_alloc; + goto err; }
dev_set_drvdata(&i2c->dev, wm1250);
return ret;
-err_alloc: - kfree(wm1250); err: return ret; } @@ -151,10 +149,8 @@ static void wm1250_ev1_free(struct i2c_client *i2c) { struct wm1250_priv *wm1250 = dev_get_drvdata(&i2c->dev);
- if (wm1250) { + if (wm1250) gpio_free_array(wm1250->gpios, ARRAY_SIZE(wm1250->gpios)); - kfree(wm1250); - } }
static int __devinit wm1250_ev1_probe(struct i2c_client *i2c,
Signed-off-by: Mark Brown broonie@opensource.wolfsonmicro.com --- sound/soc/codecs/wm9081.c | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/sound/soc/codecs/wm9081.c b/sound/soc/codecs/wm9081.c index ba12690..8a4b970 100644 --- a/sound/soc/codecs/wm9081.c +++ b/sound/soc/codecs/wm9081.c @@ -1361,7 +1361,8 @@ static __devinit int wm9081_i2c_probe(struct i2c_client *i2c, unsigned int reg; int ret;
- wm9081 = kzalloc(sizeof(struct wm9081_priv), GFP_KERNEL); + wm9081 = devm_kzalloc(&i2c->dev, sizeof(struct wm9081_priv), + GFP_KERNEL); if (wm9081 == NULL) return -ENOMEM;
@@ -1405,7 +1406,6 @@ static __devinit int wm9081_i2c_probe(struct i2c_client *i2c, err_regmap: regmap_exit(wm9081->regmap); err: - kfree(wm9081);
return ret; } @@ -1416,7 +1416,6 @@ static __devexit int wm9081_i2c_remove(struct i2c_client *client)
snd_soc_unregister_codec(&client->dev); regmap_exit(wm9081->regmap); - kfree(i2c_get_clientdata(client)); return 0; }
Signed-off-by: Mark Brown broonie@opensource.wolfsonmicro.com --- sound/soc/codecs/wm8996.c | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/sound/soc/codecs/wm8996.c b/sound/soc/codecs/wm8996.c index 304a0e5..41cc9d2 100644 --- a/sound/soc/codecs/wm8996.c +++ b/sound/soc/codecs/wm8996.c @@ -3104,7 +3104,8 @@ static __devinit int wm8996_i2c_probe(struct i2c_client *i2c, int ret, i; unsigned int reg;
- wm8996 = kzalloc(sizeof(struct wm8996_priv), GFP_KERNEL); + wm8996 = devm_kzalloc(&i2c->dev, sizeof(struct wm8996_priv), + GFP_KERNEL); if (wm8996 == NULL) return -ENOMEM;
@@ -3216,7 +3217,6 @@ err_gpio: if (wm8996->pdata.ldo_ena > 0) gpio_free(wm8996->pdata.ldo_ena); err: - kfree(wm8996);
return ret; } @@ -3234,7 +3234,6 @@ static __devexit int wm8996_i2c_remove(struct i2c_client *client) gpio_set_value_cansleep(wm8996->pdata.ldo_ena, 0); gpio_free(wm8996->pdata.ldo_ena); } - kfree(wm8996); return 0; }
participants (1)
-
Mark Brown