[alsa-devel] [PATCH 01/10] ASoC: Convert 88pm860x-codec to devm_kzalloc()
Signed-off-by: Axel Lin axel.lin@gmail.com --- sound/soc/codecs/88pm860x-codec.c | 7 ++----- 1 files changed, 2 insertions(+), 5 deletions(-)
diff --git a/sound/soc/codecs/88pm860x-codec.c b/sound/soc/codecs/88pm860x-codec.c index 99ca53c..9fd3b68 100644 --- a/sound/soc/codecs/88pm860x-codec.c +++ b/sound/soc/codecs/88pm860x-codec.c @@ -1430,7 +1430,8 @@ static int __devinit pm860x_codec_probe(struct platform_device *pdev) struct resource *res; int i, ret;
- pm860x = kzalloc(sizeof(struct pm860x_priv), GFP_KERNEL); + pm860x = devm_kzalloc(&pdev->dev, sizeof(struct pm860x_priv), + GFP_KERNEL); if (pm860x == NULL) return -ENOMEM;
@@ -1459,17 +1460,13 @@ static int __devinit pm860x_codec_probe(struct platform_device *pdev)
out: platform_set_drvdata(pdev, NULL); - kfree(pm860x); return -EINVAL; }
static int __devexit pm860x_codec_remove(struct platform_device *pdev) { - struct pm860x_priv *pm860x = platform_get_drvdata(pdev); - snd_soc_unregister_codec(&pdev->dev); platform_set_drvdata(pdev, NULL); - kfree(pm860x); return 0; }
Signed-off-by: Axel Lin axel.lin@gmail.com --- sound/soc/codecs/ad1836.c | 7 +++---- 1 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/sound/soc/codecs/ad1836.c b/sound/soc/codecs/ad1836.c index 919322d..982d201 100644 --- a/sound/soc/codecs/ad1836.c +++ b/sound/soc/codecs/ad1836.c @@ -341,7 +341,8 @@ static int __devinit ad1836_spi_probe(struct spi_device *spi) struct ad1836_priv *ad1836; int ret;
- ad1836 = kzalloc(sizeof(struct ad1836_priv), GFP_KERNEL); + ad1836 = devm_kzalloc(&spi->dev, sizeof(struct ad1836_priv), + GFP_KERNEL); if (ad1836 == NULL) return -ENOMEM;
@@ -351,17 +352,15 @@ static int __devinit ad1836_spi_probe(struct spi_device *spi)
ret = snd_soc_register_codec(&spi->dev, &soc_codec_dev_ad1836, &ad183x_dais[ad1836->type], 1); - if (ret < 0) - kfree(ad1836); return ret; }
static int __devexit ad1836_spi_remove(struct spi_device *spi) { snd_soc_unregister_codec(&spi->dev); - kfree(spi_get_drvdata(spi)); return 0; } + static const struct spi_device_id ad1836_ids[] = { { "ad1835", AD1835 }, { "ad1836", AD1836 },
On Mon, Dec 26, 2011 at 08:50:02PM +0800, Axel Lin wrote:
Signed-off-by: Axel Lin axel.lin@gmail.com
Applied the rest of these, thanks.
Signed-off-by: Axel Lin axel.lin@gmail.com --- sound/soc/codecs/ad193x.c | 19 ++++++++----------- 1 files changed, 8 insertions(+), 11 deletions(-)
diff --git a/sound/soc/codecs/ad193x.c b/sound/soc/codecs/ad193x.c index c1b7d92..a4a6bef 100644 --- a/sound/soc/codecs/ad193x.c +++ b/sound/soc/codecs/ad193x.c @@ -385,14 +385,15 @@ static int __devinit ad193x_spi_probe(struct spi_device *spi) struct ad193x_priv *ad193x; int ret;
- ad193x = kzalloc(sizeof(struct ad193x_priv), GFP_KERNEL); + ad193x = devm_kzalloc(&spi->dev, sizeof(struct ad193x_priv), + GFP_KERNEL); if (ad193x == NULL) return -ENOMEM;
ad193x->regmap = regmap_init_spi(spi, &ad193x_spi_regmap_config); if (IS_ERR(ad193x->regmap)) { ret = PTR_ERR(ad193x->regmap); - goto err_free; + goto err_out; }
spi_set_drvdata(spi, ad193x); @@ -406,9 +407,7 @@ static int __devinit ad193x_spi_probe(struct spi_device *spi)
err_regmap_exit: regmap_exit(ad193x->regmap); -err_free: - kfree(ad193x); - +err_out: return ret; }
@@ -418,7 +417,6 @@ static int __devexit ad193x_spi_remove(struct spi_device *spi)
snd_soc_unregister_codec(&spi->dev); regmap_exit(ad193x->regmap); - kfree(ad193x); return 0; }
@@ -455,14 +453,15 @@ static int __devinit ad193x_i2c_probe(struct i2c_client *client, struct ad193x_priv *ad193x; int ret;
- ad193x = kzalloc(sizeof(struct ad193x_priv), GFP_KERNEL); + ad193x = devm_kzalloc(&client->dev, sizeof(struct ad193x_priv), + GFP_KERNEL); if (ad193x == NULL) return -ENOMEM;
ad193x->regmap = regmap_init_i2c(client, &ad193x_i2c_regmap_config); if (IS_ERR(ad193x->regmap)) { ret = PTR_ERR(ad193x->regmap); - goto err_free; + goto err_out; }
i2c_set_clientdata(client, ad193x); @@ -476,8 +475,7 @@ static int __devinit ad193x_i2c_probe(struct i2c_client *client,
err_regmap_exit: regmap_exit(ad193x->regmap); -err_free: - kfree(ad193x); +err_out: return ret; }
@@ -487,7 +485,6 @@ static int __devexit ad193x_i2c_remove(struct i2c_client *client)
snd_soc_unregister_codec(&client->dev); regmap_exit(ad193x->regmap); - kfree(ad193x); return 0; }
Signed-off-by: Axel Lin axel.lin@gmail.com --- sound/soc/codecs/adau1373.c | 6 +----- 1 files changed, 1 insertions(+), 5 deletions(-)
diff --git a/sound/soc/codecs/adau1373.c b/sound/soc/codecs/adau1373.c index 637b114..971ba45 100644 --- a/sound/soc/codecs/adau1373.c +++ b/sound/soc/codecs/adau1373.c @@ -1360,7 +1360,7 @@ static int __devinit adau1373_i2c_probe(struct i2c_client *client, struct adau1373 *adau1373; int ret;
- adau1373 = kzalloc(sizeof(*adau1373), GFP_KERNEL); + adau1373 = devm_kzalloc(&client->dev, sizeof(*adau1373), GFP_KERNEL); if (!adau1373) return -ENOMEM;
@@ -1368,16 +1368,12 @@ static int __devinit adau1373_i2c_probe(struct i2c_client *client,
ret = snd_soc_register_codec(&client->dev, &adau1373_codec_driver, adau1373_dai_driver, ARRAY_SIZE(adau1373_dai_driver)); - if (ret < 0) - kfree(adau1373); - return ret; }
static int __devexit adau1373_i2c_remove(struct i2c_client *client) { snd_soc_unregister_codec(&client->dev); - kfree(dev_get_drvdata(&client->dev)); return 0; }
Signed-off-by: Axel Lin axel.lin@gmail.com --- sound/soc/codecs/adau1701.c | 6 +----- 1 files changed, 1 insertions(+), 5 deletions(-)
diff --git a/sound/soc/codecs/adau1701.c b/sound/soc/codecs/adau1701.c index 6a6af56..6b325ea 100644 --- a/sound/soc/codecs/adau1701.c +++ b/sound/soc/codecs/adau1701.c @@ -496,23 +496,19 @@ static __devinit int adau1701_i2c_probe(struct i2c_client *client, struct adau1701 *adau1701; int ret;
- adau1701 = kzalloc(sizeof(*adau1701), GFP_KERNEL); + adau1701 = devm_kzalloc(&client->dev, sizeof(*adau1701), GFP_KERNEL); if (!adau1701) return -ENOMEM;
i2c_set_clientdata(client, adau1701); ret = snd_soc_register_codec(&client->dev, &adau1701_codec_drv, &adau1701_dai, 1); - if (ret < 0) - kfree(adau1701); - return ret; }
static __devexit int adau1701_i2c_remove(struct i2c_client *client) { snd_soc_unregister_codec(&client->dev); - kfree(i2c_get_clientdata(client)); return 0; }
Signed-off-by: Axel Lin axel.lin@gmail.com --- sound/soc/codecs/da7210.c | 7 ++----- 1 files changed, 2 insertions(+), 5 deletions(-)
diff --git a/sound/soc/codecs/da7210.c b/sound/soc/codecs/da7210.c index e4ca61c..62e6a9c 100644 --- a/sound/soc/codecs/da7210.c +++ b/sound/soc/codecs/da7210.c @@ -944,7 +944,8 @@ static int __devinit da7210_i2c_probe(struct i2c_client *i2c, struct da7210_priv *da7210; int ret;
- da7210 = kzalloc(sizeof(struct da7210_priv), GFP_KERNEL); + da7210 = devm_kzalloc(&i2c->dev, sizeof(struct da7210_priv), + GFP_KERNEL); if (!da7210) return -ENOMEM;
@@ -953,16 +954,12 @@ static int __devinit da7210_i2c_probe(struct i2c_client *i2c,
ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_da7210, &da7210_dai, 1); - if (ret < 0) - kfree(da7210); - return ret; }
static int __devexit da7210_i2c_remove(struct i2c_client *client) { snd_soc_unregister_codec(&client->dev); - kfree(i2c_get_clientdata(client)); return 0; }
On Mon, Dec 26, 2011 at 08:54:04PM +0800, Axel Lin wrote:
Signed-off-by: Axel Lin axel.lin@gmail.com
Applied, thanks.
Signed-off-by: Axel Lin axel.lin@gmail.com --- sound/soc/codecs/jz4740.c | 12 +++++------- 1 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/sound/soc/codecs/jz4740.c b/sound/soc/codecs/jz4740.c index d73d283..4624e75 100644 --- a/sound/soc/codecs/jz4740.c +++ b/sound/soc/codecs/jz4740.c @@ -353,7 +353,8 @@ static int __devinit jz4740_codec_probe(struct platform_device *pdev) struct jz4740_codec *jz4740_codec; struct resource *mem;
- jz4740_codec = kzalloc(sizeof(*jz4740_codec), GFP_KERNEL); + jz4740_codec = devm_kzalloc(&pdev->dev, sizeof(*jz4740_codec), + GFP_KERNEL); if (!jz4740_codec) return -ENOMEM;
@@ -361,14 +362,14 @@ static int __devinit jz4740_codec_probe(struct platform_device *pdev) if (!mem) { dev_err(&pdev->dev, "Failed to get mmio memory resource\n"); ret = -ENOENT; - goto err_free_codec; + goto err_out; }
mem = request_mem_region(mem->start, resource_size(mem), pdev->name); if (!mem) { dev_err(&pdev->dev, "Failed to request mmio memory region\n"); ret = -EBUSY; - goto err_free_codec; + goto err_out; }
jz4740_codec->base = ioremap(mem->start, resource_size(mem)); @@ -394,9 +395,7 @@ err_iounmap: iounmap(jz4740_codec->base); err_release_mem_region: release_mem_region(mem->start, resource_size(mem)); -err_free_codec: - kfree(jz4740_codec); - +err_out: return ret; }
@@ -411,7 +410,6 @@ static int __devexit jz4740_codec_remove(struct platform_device *pdev) release_mem_region(mem->start, resource_size(mem));
platform_set_drvdata(pdev, NULL); - kfree(jz4740_codec);
return 0; }
Signed-off-by: Axel Lin axel.lin@gmail.com --- sound/soc/codecs/lm4857.c | 13 ++----------- 1 files changed, 2 insertions(+), 11 deletions(-)
diff --git a/sound/soc/codecs/lm4857.c b/sound/soc/codecs/lm4857.c index c387daf..3190392 100644 --- a/sound/soc/codecs/lm4857.c +++ b/sound/soc/codecs/lm4857.c @@ -215,7 +215,7 @@ static int __devinit lm4857_i2c_probe(struct i2c_client *i2c, struct lm4857 *lm4857; int ret;
- lm4857 = kzalloc(sizeof(*lm4857), GFP_KERNEL); + lm4857 = devm_kzalloc(&i2c->dev, sizeof(*lm4857), GFP_KERNEL); if (!lm4857) return -ENOMEM;
@@ -225,21 +225,12 @@ static int __devinit lm4857_i2c_probe(struct i2c_client *i2c,
ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_lm4857, NULL, 0);
- if (ret) { - kfree(lm4857); - return ret; - } - - return 0; + return ret; }
static int __devexit lm4857_i2c_remove(struct i2c_client *i2c) { - struct lm4857 *lm4857 = i2c_get_clientdata(i2c); - snd_soc_unregister_codec(&i2c->dev); - kfree(lm4857); - return 0; }
On Mon, Dec 26, 2011 at 08:56:25PM +0800, Axel Lin wrote:
Signed-off-by: Axel Lin axel.lin@gmail.com
Applied, thanks.
Signed-off-by: Axel Lin axel.lin@gmail.com --- sound/soc/codecs/tlv320aic32x4.c | 6 ++---- 1 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/sound/soc/codecs/tlv320aic32x4.c b/sound/soc/codecs/tlv320aic32x4.c index 81a26e1..eb401ef 100644 --- a/sound/soc/codecs/tlv320aic32x4.c +++ b/sound/soc/codecs/tlv320aic32x4.c @@ -709,7 +709,8 @@ static __devinit int aic32x4_i2c_probe(struct i2c_client *i2c, struct aic32x4_priv *aic32x4; int ret;
- aic32x4 = kzalloc(sizeof(struct aic32x4_priv), GFP_KERNEL); + aic32x4 = devm_kzalloc(&i2c->dev, sizeof(struct aic32x4_priv), + GFP_KERNEL); if (aic32x4 == NULL) return -ENOMEM;
@@ -728,15 +729,12 @@ static __devinit int aic32x4_i2c_probe(struct i2c_client *i2c,
ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_aic32x4, &aic32x4_dai, 1); - if (ret < 0) - kfree(aic32x4); return ret; }
static __devexit int aic32x4_i2c_remove(struct i2c_client *client) { snd_soc_unregister_codec(&client->dev); - kfree(i2c_get_clientdata(client)); return 0; }
Signed-off-by: Axel Lin axel.lin@gmail.com --- sound/soc/codecs/uda1380.c | 6 ++---- 1 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/sound/soc/codecs/uda1380.c b/sound/soc/codecs/uda1380.c index 8f734d6..4f1b23d 100644 --- a/sound/soc/codecs/uda1380.c +++ b/sound/soc/codecs/uda1380.c @@ -803,7 +803,8 @@ static __devinit int uda1380_i2c_probe(struct i2c_client *i2c, struct uda1380_priv *uda1380; int ret;
- uda1380 = kzalloc(sizeof(struct uda1380_priv), GFP_KERNEL); + uda1380 = devm_kzalloc(&i2c->dev, sizeof(struct uda1380_priv), + GFP_KERNEL); if (uda1380 == NULL) return -ENOMEM;
@@ -812,15 +813,12 @@ static __devinit int uda1380_i2c_probe(struct i2c_client *i2c,
ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_uda1380, uda1380_dai, ARRAY_SIZE(uda1380_dai)); - if (ret < 0) - kfree(uda1380); return ret; }
static int __devexit uda1380_i2c_remove(struct i2c_client *i2c) { snd_soc_unregister_codec(&i2c->dev); - kfree(i2c_get_clientdata(i2c)); return 0; }
On Mon, Dec 26, 2011 at 08:58:14PM +0800, Axel Lin wrote:
Signed-off-by: Axel Lin axel.lin@gmail.com
Applied, thanks.
On Mon, Dec 26, 2011 at 08:48:48PM +0800, Axel Lin wrote:
Signed-off-by: Axel Lin axel.lin@gmail.com
Applied, thanks.
participants (2)
-
Axel Lin
-
Mark Brown