[alsa-devel] [PATCH 01/14] ASoC: Convert alc5623 to devm_kzalloc()
Signed-off-by: Axel Lin axel.lin@gmail.com --- sound/soc/codecs/alc5623.c | 11 +++-------- 1 files changed, 3 insertions(+), 8 deletions(-)
diff --git a/sound/soc/codecs/alc5623.c b/sound/soc/codecs/alc5623.c index 6a9b621..3feee56 100644 --- a/sound/soc/codecs/alc5623.c +++ b/sound/soc/codecs/alc5623.c @@ -1022,7 +1022,8 @@ static int alc5623_i2c_probe(struct i2c_client *client,
dev_dbg(&client->dev, "Found codec id : alc56%02x\n", vid2);
- alc5623 = kzalloc(sizeof(struct alc5623_priv), GFP_KERNEL); + alc5623 = devm_kzalloc(&client->dev, sizeof(struct alc5623_priv), + GFP_KERNEL); if (alc5623 == NULL) return -ENOMEM;
@@ -1044,7 +1045,6 @@ static int alc5623_i2c_probe(struct i2c_client *client, alc5623_dai.name = "alc5623-hifi"; break; default: - kfree(alc5623); return -EINVAL; }
@@ -1053,20 +1053,15 @@ static int alc5623_i2c_probe(struct i2c_client *client,
ret = snd_soc_register_codec(&client->dev, &soc_codec_device_alc5623, &alc5623_dai, 1); - if (ret != 0) { + if (ret != 0) dev_err(&client->dev, "Failed to register codec: %d\n", ret); - kfree(alc5623); - }
return ret; }
static int alc5623_i2c_remove(struct i2c_client *client) { - struct alc5623_priv *alc5623 = i2c_get_clientdata(client); - snd_soc_unregister_codec(&client->dev); - kfree(alc5623); return 0; }
Signed-off-by: Axel Lin axel.lin@gmail.com --- sound/soc/codecs/cs4270.c | 6 ++---- 1 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/sound/soc/codecs/cs4270.c b/sound/soc/codecs/cs4270.c index fef0f48..0555366 100644 --- a/sound/soc/codecs/cs4270.c +++ b/sound/soc/codecs/cs4270.c @@ -671,7 +671,8 @@ static int cs4270_i2c_probe(struct i2c_client *i2c_client, i2c_client->addr); dev_info(&i2c_client->dev, "hardware revision %X\n", ret & 0xF);
- cs4270 = kzalloc(sizeof(struct cs4270_private), GFP_KERNEL); + cs4270 = devm_kzalloc(&i2c_client->dev, sizeof(struct cs4270_private), + GFP_KERNEL); if (!cs4270) { dev_err(&i2c_client->dev, "could not allocate codec\n"); return -ENOMEM; @@ -682,8 +683,6 @@ static int cs4270_i2c_probe(struct i2c_client *i2c_client,
ret = snd_soc_register_codec(&i2c_client->dev, &soc_codec_device_cs4270, &cs4270_dai, 1); - if (ret < 0) - kfree(cs4270); return ret; }
@@ -696,7 +695,6 @@ static int cs4270_i2c_probe(struct i2c_client *i2c_client, static int cs4270_i2c_remove(struct i2c_client *i2c_client) { snd_soc_unregister_codec(&i2c_client->dev); - kfree(i2c_get_clientdata(i2c_client)); return 0; }
Axel Lin wrote:
Signed-off-by: Axel Linaxel.lin@gmail.com
I won't be able to test this for at least another week, so I can't give it an official ACK yet.
On Thu, Dec 29, 2011 at 03:52:30PM +0000, Tabi Timur-B04825 wrote:
Axel Lin wrote:
Signed-off-by: Axel Linaxel.lin@gmail.com
I won't be able to test this for at least another week, so I can't give it an official ACK yet.
It's OK to ack things based purely off code review (epecially for simple transformations like this).
Mark Brown wrote:
It's OK to ack things based purely off code review (epecially for simple transformations like this).
I understand that, but I would really like the opportunity to try it for myself first. But if you're in a hurry to apply it, don't wait for me.
Signed-off-by: Axel Lin axel.lin@gmail.com --- sound/soc/codecs/cs42l51.c | 8 ++------ 1 files changed, 2 insertions(+), 6 deletions(-)
diff --git a/sound/soc/codecs/cs42l51.c b/sound/soc/codecs/cs42l51.c index ffce9f2..a8bf588 100644 --- a/sound/soc/codecs/cs42l51.c +++ b/sound/soc/codecs/cs42l51.c @@ -577,7 +577,8 @@ static int cs42l51_i2c_probe(struct i2c_client *i2c_client, dev_info(&i2c_client->dev, "found device cs42l51 rev %d\n", ret & 7);
- cs42l51 = kzalloc(sizeof(struct cs42l51_private), GFP_KERNEL); + cs42l51 = devm_kzalloc(&i2c_client->dev, sizeof(struct cs42l51_private), + GFP_KERNEL); if (!cs42l51) { dev_err(&i2c_client->dev, "could not allocate codec\n"); return -ENOMEM; @@ -588,18 +589,13 @@ static int cs42l51_i2c_probe(struct i2c_client *i2c_client,
ret = snd_soc_register_codec(&i2c_client->dev, &soc_codec_device_cs42l51, &cs42l51_dai, 1); - if (ret < 0) - kfree(cs42l51); error: return ret; }
static int cs42l51_i2c_remove(struct i2c_client *client) { - struct cs42l51_private *cs42l51 = i2c_get_clientdata(client); - snd_soc_unregister_codec(&client->dev); - kfree(cs42l51); return 0; }
Signed-off-by: Axel Lin axel.lin@gmail.com --- sound/soc/codecs/max98088.c | 6 ++---- 1 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/sound/soc/codecs/max98088.c b/sound/soc/codecs/max98088.c index ba4f6f1..006efcf 100644 --- a/sound/soc/codecs/max98088.c +++ b/sound/soc/codecs/max98088.c @@ -2069,7 +2069,8 @@ static int max98088_i2c_probe(struct i2c_client *i2c, struct max98088_priv *max98088; int ret;
- max98088 = kzalloc(sizeof(struct max98088_priv), GFP_KERNEL); + max98088 = devm_kzalloc(&i2c->dev, sizeof(struct max98088_priv), + GFP_KERNEL); if (max98088 == NULL) return -ENOMEM;
@@ -2080,15 +2081,12 @@ static int max98088_i2c_probe(struct i2c_client *i2c,
ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_max98088, &max98088_dai[0], 2); - if (ret < 0) - kfree(max98088); return ret; }
static int __devexit max98088_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/max98095.c | 7 ++----- 1 files changed, 2 insertions(+), 5 deletions(-)
diff --git a/sound/soc/codecs/max98095.c b/sound/soc/codecs/max98095.c index c69dd02..fcfa749 100644 --- a/sound/soc/codecs/max98095.c +++ b/sound/soc/codecs/max98095.c @@ -2340,7 +2340,8 @@ static int max98095_i2c_probe(struct i2c_client *i2c, struct max98095_priv *max98095; int ret;
- max98095 = kzalloc(sizeof(struct max98095_priv), GFP_KERNEL); + max98095 = devm_kzalloc(&i2c->dev, sizeof(struct max98095_priv), + GFP_KERNEL); if (max98095 == NULL) return -ENOMEM;
@@ -2350,16 +2351,12 @@ static int max98095_i2c_probe(struct i2c_client *i2c,
ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_max98095, max98095_dai, ARRAY_SIZE(max98095_dai)); - if (ret < 0) - kfree(max98095); return ret; }
static int __devexit max98095_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/max9850.c | 6 ++---- 1 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/sound/soc/codecs/max9850.c b/sound/soc/codecs/max9850.c index 47060d2..a191309 100644 --- a/sound/soc/codecs/max9850.c +++ b/sound/soc/codecs/max9850.c @@ -335,7 +335,8 @@ static int __devinit max9850_i2c_probe(struct i2c_client *i2c, struct max9850_priv *max9850; int ret;
- max9850 = kzalloc(sizeof(struct max9850_priv), GFP_KERNEL); + max9850 = devm_kzalloc(&i2c->dev, sizeof(struct max9850_priv), + GFP_KERNEL); if (max9850 == NULL) return -ENOMEM;
@@ -343,15 +344,12 @@ static int __devinit max9850_i2c_probe(struct i2c_client *i2c,
ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_max9850, &max9850_dai, 1); - if (ret < 0) - kfree(max9850); return ret; }
static __devexit int max9850_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/rt5631.c | 7 ++----- 1 files changed, 2 insertions(+), 5 deletions(-)
diff --git a/sound/soc/codecs/rt5631.c b/sound/soc/codecs/rt5631.c index f6e4f5e..20c324c 100644 --- a/sound/soc/codecs/rt5631.c +++ b/sound/soc/codecs/rt5631.c @@ -1724,7 +1724,8 @@ static int rt5631_i2c_probe(struct i2c_client *i2c, struct rt5631_priv *rt5631; int ret;
- rt5631 = kzalloc(sizeof(struct rt5631_priv), GFP_KERNEL); + rt5631 = devm_kzalloc(&i2c->dev, sizeof(struct rt5631_priv), + GFP_KERNEL); if (NULL == rt5631) return -ENOMEM;
@@ -1732,16 +1733,12 @@ static int rt5631_i2c_probe(struct i2c_client *i2c,
ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_rt5631, rt5631_dai, ARRAY_SIZE(rt5631_dai)); - if (ret < 0) - kfree(rt5631); - return ret; }
static __devexit int rt5631_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/ssm2602.c | 12 ++++-------- 1 files changed, 4 insertions(+), 8 deletions(-)
diff --git a/sound/soc/codecs/ssm2602.c b/sound/soc/codecs/ssm2602.c index 7dfc7b0..333dd98 100644 --- a/sound/soc/codecs/ssm2602.c +++ b/sound/soc/codecs/ssm2602.c @@ -652,7 +652,8 @@ static int __devinit ssm2602_spi_probe(struct spi_device *spi) struct ssm2602_priv *ssm2602; int ret;
- ssm2602 = kzalloc(sizeof(struct ssm2602_priv), GFP_KERNEL); + ssm2602 = devm_kzalloc(&spi->dev, sizeof(struct ssm2602_priv), + GFP_KERNEL); if (ssm2602 == NULL) return -ENOMEM;
@@ -662,15 +663,12 @@ static int __devinit ssm2602_spi_probe(struct spi_device *spi)
ret = snd_soc_register_codec(&spi->dev, &soc_codec_dev_ssm2602, &ssm2602_dai, 1); - if (ret < 0) - kfree(ssm2602); return ret; }
static int __devexit ssm2602_spi_remove(struct spi_device *spi) { snd_soc_unregister_codec(&spi->dev); - kfree(spi_get_drvdata(spi)); return 0; }
@@ -697,7 +695,8 @@ static int __devinit ssm2602_i2c_probe(struct i2c_client *i2c, struct ssm2602_priv *ssm2602; int ret;
- ssm2602 = kzalloc(sizeof(struct ssm2602_priv), GFP_KERNEL); + ssm2602 = devm_kzalloc(&i2c->dev, sizeof(struct ssm2602_priv), + GFP_KERNEL); if (ssm2602 == NULL) return -ENOMEM;
@@ -707,15 +706,12 @@ static int __devinit ssm2602_i2c_probe(struct i2c_client *i2c,
ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_ssm2602, &ssm2602_dai, 1); - if (ret < 0) - kfree(ssm2602); return ret; }
static int __devexit ssm2602_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/sta32x.c | 13 ++++--------- 1 files changed, 4 insertions(+), 9 deletions(-)
diff --git a/sound/soc/codecs/sta32x.c b/sound/soc/codecs/sta32x.c index 6648af6..fbd1450 100644 --- a/sound/soc/codecs/sta32x.c +++ b/sound/soc/codecs/sta32x.c @@ -968,28 +968,23 @@ static __devinit int sta32x_i2c_probe(struct i2c_client *i2c, struct sta32x_priv *sta32x; int ret;
- sta32x = kzalloc(sizeof(struct sta32x_priv), GFP_KERNEL); + sta32x = devm_kzalloc(&i2c->dev, sizeof(struct sta32x_priv), + GFP_KERNEL); if (!sta32x) return -ENOMEM;
i2c_set_clientdata(i2c, sta32x);
ret = snd_soc_register_codec(&i2c->dev, &sta32x_codec, &sta32x_dai, 1); - if (ret != 0) { + if (ret != 0) dev_err(&i2c->dev, "Failed to register codec (%d)\n", ret); - kfree(sta32x); - return ret; - }
- return 0; + return ret; }
static __devexit int sta32x_i2c_remove(struct i2c_client *client) { - struct sta32x_priv *sta32x = i2c_get_clientdata(client); - snd_soc_unregister_codec(&client->dev); - kfree(sta32x); return 0; }
Signed-off-by: Axel Lin axel.lin@gmail.com --- sound/soc/codecs/tlv320aic23.c | 5 +---- 1 files changed, 1 insertions(+), 4 deletions(-)
diff --git a/sound/soc/codecs/tlv320aic23.c b/sound/soc/codecs/tlv320aic23.c index 60d08aea..dfa41a9 100644 --- a/sound/soc/codecs/tlv320aic23.c +++ b/sound/soc/codecs/tlv320aic23.c @@ -634,7 +634,7 @@ static int tlv320aic23_codec_probe(struct i2c_client *i2c, if (!i2c_check_functionality(i2c->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) return -EINVAL;
- aic23 = kzalloc(sizeof(struct aic23), GFP_KERNEL); + aic23 = devm_kzalloc(&i2c->dev, sizeof(struct aic23), GFP_KERNEL); if (aic23 == NULL) return -ENOMEM;
@@ -643,14 +643,11 @@ static int tlv320aic23_codec_probe(struct i2c_client *i2c,
ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_tlv320aic23, &tlv320aic23_dai, 1); - if (ret < 0) - kfree(aic23); return ret; } static int __exit tlv320aic23_i2c_remove(struct i2c_client *i2c) { snd_soc_unregister_codec(&i2c->dev); - kfree(i2c_get_clientdata(i2c)); return 0; }
Signed-off-by: Axel Lin axel.lin@gmail.com --- sound/soc/codecs/tlv320aic26.c | 8 +------- 1 files changed, 1 insertions(+), 7 deletions(-)
diff --git a/sound/soc/codecs/tlv320aic26.c b/sound/soc/codecs/tlv320aic26.c index 86d1fa3..a038dae 100644 --- a/sound/soc/codecs/tlv320aic26.c +++ b/sound/soc/codecs/tlv320aic26.c @@ -416,7 +416,7 @@ static int aic26_spi_probe(struct spi_device *spi) dev_dbg(&spi->dev, "probing tlv320aic26 spi device\n");
/* Allocate driver data */ - aic26 = kzalloc(sizeof *aic26, GFP_KERNEL); + aic26 = devm_kzalloc(&spi->dev, sizeof *aic26, GFP_KERNEL); if (!aic26) return -ENOMEM;
@@ -427,18 +427,12 @@ static int aic26_spi_probe(struct spi_device *spi)
ret = snd_soc_register_codec(&spi->dev, &aic26_soc_codec_dev, &aic26_dai, 1); - if (ret < 0) - kfree(aic26); return ret; - - dev_dbg(&spi->dev, "SPI device initialized\n"); - return 0; }
static int aic26_spi_remove(struct spi_device *spi) { snd_soc_unregister_codec(&spi->dev); - kfree(spi_get_drvdata(spi)); return 0; }
Signed-off-by: Axel Lin axel.lin@gmail.com --- sound/soc/codecs/tlv320aic3x.c | 5 +---- 1 files changed, 1 insertions(+), 4 deletions(-)
diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c index 6f963c5..492f22f 100644 --- a/sound/soc/codecs/tlv320aic3x.c +++ b/sound/soc/codecs/tlv320aic3x.c @@ -1504,7 +1504,7 @@ static int aic3x_i2c_probe(struct i2c_client *i2c, struct aic3x_priv *aic3x; int ret;
- aic3x = kzalloc(sizeof(struct aic3x_priv), GFP_KERNEL); + aic3x = devm_kzalloc(&i2c->dev, sizeof(struct aic3x_priv), GFP_KERNEL); if (aic3x == NULL) { dev_err(&i2c->dev, "failed to create private data\n"); return -ENOMEM; @@ -1524,15 +1524,12 @@ static int aic3x_i2c_probe(struct i2c_client *i2c,
ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_aic3x, &aic3x_dai, 1); - if (ret < 0) - kfree(aic3x); return ret; }
static int aic3x_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/tlv320dac33.c | 6 ++---- 1 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/sound/soc/codecs/tlv320dac33.c b/sound/soc/codecs/tlv320dac33.c index c7a61fb..f0aad26 100644 --- a/sound/soc/codecs/tlv320dac33.c +++ b/sound/soc/codecs/tlv320dac33.c @@ -1532,7 +1532,8 @@ static int __devinit dac33_i2c_probe(struct i2c_client *client, } pdata = client->dev.platform_data;
- dac33 = kzalloc(sizeof(struct tlv320dac33_priv), GFP_KERNEL); + dac33 = devm_kzalloc(&client->dev, sizeof(struct tlv320dac33_priv), + GFP_KERNEL); if (dac33 == NULL) return -ENOMEM;
@@ -1587,7 +1588,6 @@ err_get: if (dac33->power_gpio >= 0) gpio_free(dac33->power_gpio); err_gpio: - kfree(dac33); return ret; }
@@ -1604,8 +1604,6 @@ static int __devexit dac33_i2c_remove(struct i2c_client *client) regulator_bulk_free(ARRAY_SIZE(dac33->supplies), dac33->supplies);
snd_soc_unregister_codec(&client->dev); - kfree(dac33); - return 0; }
Signed-off-by: Axel Lin axel.lin@gmail.com --- sound/soc/codecs/tpa6130a2.c | 5 +---- 1 files changed, 1 insertions(+), 4 deletions(-)
diff --git a/sound/soc/codecs/tpa6130a2.c b/sound/soc/codecs/tpa6130a2.c index 7eeca79..363b99d 100644 --- a/sound/soc/codecs/tpa6130a2.c +++ b/sound/soc/codecs/tpa6130a2.c @@ -376,7 +376,7 @@ static int __devinit tpa6130a2_probe(struct i2c_client *client, return -ENODEV; }
- data = kzalloc(sizeof(*data), GFP_KERNEL); + data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL); if (data == NULL) { dev_err(dev, "Can not allocate memory\n"); return -ENOMEM; @@ -450,7 +450,6 @@ err_regulator: if (data->power_gpio >= 0) gpio_free(data->power_gpio); err_gpio: - kfree(data); tpa6130a2_client = NULL;
return ret; @@ -466,8 +465,6 @@ static int __devexit tpa6130a2_remove(struct i2c_client *client) gpio_free(data->power_gpio);
regulator_put(data->supply); - - kfree(data); tpa6130a2_client = NULL;
return 0;
On Thu, Dec 29, 2011 at 11:56:23AM +0800, Axel Lin wrote:
Signed-off-by: Axel Lin axel.lin@gmail.com
Applied all, thanks.
participants (3)
-
Axel Lin
-
Mark Brown
-
Tabi Timur-B04825