Skip to contentSkip to conversation

ASoC: Convert alc5623 to devm_kzalloc()

PATCH Applied Axel Lin 3 participants 18 messages Dec 29, 2011 – Jan 2, 2012

Subsystems (6)
lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/14 ASoC: Convert alc5623 to devm_kzalloc()

---
 sound/soc/codecs/alc5623.c |   11 +++--------
 1 files changed, 3 insertions(+), 8 deletions(-)
sound/soc/codecs/alc5623.c +3 -8
index 6a9b621..3feee56 100644
@@ -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;
 }
 
Signature · 1 line
1.7.5.4
author
#1 lore raw

PATCH 2/14 ASoC: Convert cs4270 to devm_kzalloc()

---
 sound/soc/codecs/cs4270.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)
sound/soc/codecs/cs4270.c +2 -4
index fef0f48..0555366 100644
@@ -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;
 }
 
Signature · 1 line
1.7.5.4
#2 lore raw

Re: [PATCH 02/14] ASoC: Convert cs4270 to devm_kzalloc()

Quoted 1 line · Axel Lin

I won't be able to test this for at least another week, so I can't give it an official ACK yet.

#3 lore raw

Re: [PATCH 02/14] ASoC: Convert cs4270 to devm_kzalloc()

Quoted 5 lines · On Thu, Dec 29, 2011 at 03:52:30PM +0000, Tabi Timur-B04825 wrote:
Quoted 1 line · Axel Lin

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).

#4 lore raw

Re: [PATCH 02/14] ASoC: Convert cs4270 to devm_kzalloc()

Quoted 2 lines · Mark Brown

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.

author
#5 lore raw

PATCH 3/14 ASoC: Convert cs42l51 to devm_kzalloc()

In reply to Axel Lin
---
 sound/soc/codecs/cs42l51.c |    8 ++------
 1 files changed, 2 insertions(+), 6 deletions(-)
sound/soc/codecs/cs42l51.c +2 -6
index ffce9f2..a8bf588 100644
@@ -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;
 }
 
Signature · 1 line
1.7.5.4
author
#6 lore raw

PATCH 4/14 ASoC: Convert max98088 to devm_kzalloc()

In reply to Axel Lin
---
 sound/soc/codecs/max98088.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)
sound/soc/codecs/max98088.c +2 -4
index ba4f6f1..006efcf 100644
@@ -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;
 }
 
Signature · 1 line
1.7.5.4
author
#7 lore raw

PATCH 5/14 ASoC: Convert max98095 to devm_kzalloc()

In reply to Axel Lin
---
 sound/soc/codecs/max98095.c |    7 ++-----
 1 files changed, 2 insertions(+), 5 deletions(-)
sound/soc/codecs/max98095.c +2 -5
index c69dd02..fcfa749 100644
@@ -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;
 }
 
Signature · 1 line
1.7.5.4
author
#8 lore raw

PATCH 6/14 ASoC: Convert max9850 to devm_kzalloc()

In reply to Axel Lin
---
 sound/soc/codecs/max9850.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)
sound/soc/codecs/max9850.c +2 -4
index 47060d2..a191309 100644
@@ -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;
 }
 
Signature · 1 line
1.7.5.4
author
#9 lore raw

PATCH 7/14 ASoC: Convert rt5631 to devm_kzalloc()

In reply to Axel Lin
---
 sound/soc/codecs/rt5631.c |    7 ++-----
 1 files changed, 2 insertions(+), 5 deletions(-)
sound/soc/codecs/rt5631.c +2 -5
index f6e4f5e..20c324c 100644
@@ -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;
 }
 
Signature · 1 line
1.7.5.4
author
#10 lore raw

PATCH 8/14 ASoC: Convert ssm2602 to devm_kzalloc()

In reply to Axel Lin
---
 sound/soc/codecs/ssm2602.c |   12 ++++--------
 1 files changed, 4 insertions(+), 8 deletions(-)
sound/soc/codecs/ssm2602.c +4 -8
index 7dfc7b0..333dd98 100644
@@ -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;
 }
 
Signature · 1 line
1.7.5.4
author
#11 lore raw

PATCH 9/14 ASoC: Convert sta32x to devm_kzalloc()

In reply to Axel Lin
---
 sound/soc/codecs/sta32x.c |   13 ++++---------
 1 files changed, 4 insertions(+), 9 deletions(-)
sound/soc/codecs/sta32x.c +4 -9
index 6648af6..fbd1450 100644
@@ -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;
 }
 
Signature · 1 line
1.7.5.4
author
#12 lore raw

PATCH 10/14 ASoC: Convert tlv320aic23 to devm_kzalloc()

In reply to Axel Lin
---
 sound/soc/codecs/tlv320aic23.c |    5 +----
 1 files changed, 1 insertions(+), 4 deletions(-)
sound/soc/codecs/tlv320aic23.c +1 -4
index 60d08aea..dfa41a9 100644
@@ -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;
 }
 
Signature · 1 line
1.7.5.4
author
#13 lore raw

PATCH 11/14 ASoC: Convert tlv320aic26 to devm_kzalloc()

In reply to Axel Lin
---
 sound/soc/codecs/tlv320aic26.c |    8 +-------
 1 files changed, 1 insertions(+), 7 deletions(-)
sound/soc/codecs/tlv320aic26.c +1 -7
index 86d1fa3..a038dae 100644
@@ -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;
 }
 
Signature · 1 line
1.7.5.4
author
#14 lore raw

PATCH 12/14 ASoC: Convert tlv320aic3x to devm_kzalloc()

In reply to Axel Lin
---
 sound/soc/codecs/tlv320aic3x.c |    5 +----
 1 files changed, 1 insertions(+), 4 deletions(-)
sound/soc/codecs/tlv320aic3x.c +1 -4
index 6f963c5..492f22f 100644
@@ -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;
 }
 
Signature · 1 line
1.7.5.4
author
#15 lore raw

PATCH 13/14 ASoC: Convert tlv320dac33 to devm_kzalloc()

In reply to Axel Lin
---
 sound/soc/codecs/tlv320dac33.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)
sound/soc/codecs/tlv320dac33.c +2 -4
index c7a61fb..f0aad26 100644
@@ -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;
 }
 
Signature · 1 line
1.7.5.4
author
#16 lore raw

PATCH 14/14 ASoC: Convert tpa6130a2 to devm_kzalloc()

In reply to Axel Lin
---
 sound/soc/codecs/tpa6130a2.c |    5 +----
 1 files changed, 1 insertions(+), 4 deletions(-)
sound/soc/codecs/tpa6130a2.c +1 -4
index 7eeca79..363b99d 100644
@@ -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;
Signature · 1 line
1.7.5.4