Skip to contentSkip to conversation

ASoC: Convert WM8960 to devm_kzalloc()

PATCH New Mark Brown 1 participant 4 messages Dec 17, 2011

Subsystems (3)
lore
Share & tools
lore

Mark Brown

author
#0 lore raw

PATCH 1/4 ASoC: Convert WM8960 to devm_kzalloc()

---
 sound/soc/codecs/wm8960.c |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)
sound/soc/codecs/wm8960.c +3 -4
index 2315b86..e5caae3 100644
@@ -973,7 +973,8 @@ static __devinit int wm8960_i2c_probe(struct i2c_client *i2c,
 	struct wm8960_priv *wm8960;
 	int ret;
 
-	wm8960 = kzalloc(sizeof(struct wm8960_priv), GFP_KERNEL);
+	wm8960 = devm_kzalloc(&i2c->dev, sizeof(struct wm8960_priv),
+			      GFP_KERNEL);
 	if (wm8960 == NULL)
 		return -ENOMEM;
 
@@ -982,15 +983,13 @@ static __devinit int wm8960_i2c_probe(struct i2c_client *i2c,
 
 	ret = snd_soc_register_codec(&i2c->dev,
 			&soc_codec_dev_wm8960, &wm8960_dai, 1);
-	if (ret < 0)
-		kfree(wm8960);
+
 	return ret;
 }
 
 static __devexit int wm8960_i2c_remove(struct i2c_client *client)
 {
 	snd_soc_unregister_codec(&client->dev);
-	kfree(i2c_get_clientdata(client));
 	return 0;
 }
 
Signature · 1 line
1.7.7.3
author
#1 lore raw

PATCH 2/4 ASoC: Remove I2C ifdefs from wm8961 driver

The driver only supports I2C so no need to conditionalise its use.

---
 sound/soc/codecs/wm8961.c |    6 ------
 1 files changed, 0 insertions(+), 6 deletions(-)
sound/soc/codecs/wm8961.c +0 -6
index 58fbf0a..13a0850 100644
@@ -1081,7 +1081,6 @@ static struct snd_soc_codec_driver soc_codec_dev_wm8961 = {
 	.volatile_register = wm8961_volatile_register,
 };
 
-#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
 static __devinit int wm8961_i2c_probe(struct i2c_client *i2c,
 				      const struct i2c_device_id *id)
 {
@@ -1123,27 +1122,22 @@ static struct i2c_driver wm8961_i2c_driver = {
 	.remove =   __devexit_p(wm8961_i2c_remove),
 	.id_table = wm8961_i2c_id,
 };
-#endif
 
 static int __init wm8961_modinit(void)
 {
 	int ret = 0;
-#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
 	ret = i2c_add_driver(&wm8961_i2c_driver);
 	if (ret != 0) {
 		printk(KERN_ERR "Failed to register wm8961 I2C driver: %d\n",
 		       ret);
 	}
-#endif
 	return ret;
 }
 module_init(wm8961_modinit);
 
 static void __exit wm8961_exit(void)
 {
-#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
 	i2c_del_driver(&wm8961_i2c_driver);
-#endif
 }
 module_exit(wm8961_exit);
 
Signature · 1 line
1.7.7.3
author
#2 lore raw

PATCH 3/4 ASoC: Convert wm8961 to devm_kzalloc()

In reply to Mark Brown
---
 sound/soc/codecs/wm8961.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
sound/soc/codecs/wm8961.c +4 -4
index 13a0850..8bcc17a 100644
@@ -1087,7 +1087,8 @@ static __devinit int wm8961_i2c_probe(struct i2c_client *i2c,
 	struct wm8961_priv *wm8961;
 	int ret;
 
-	wm8961 = kzalloc(sizeof(struct wm8961_priv), GFP_KERNEL);
+	wm8961 = devm_kzalloc(&i2c->dev, sizeof(struct wm8961_priv),
+			      GFP_KERNEL);
 	if (wm8961 == NULL)
 		return -ENOMEM;
 
@@ -1095,15 +1096,14 @@ static __devinit int wm8961_i2c_probe(struct i2c_client *i2c,
 
 	ret = snd_soc_register_codec(&i2c->dev,
 			&soc_codec_dev_wm8961, &wm8961_dai, 1);
-	if (ret < 0)
-		kfree(wm8961);
+
 	return ret;
 }
 
 static __devexit int wm8961_i2c_remove(struct i2c_client *client)
 {
 	snd_soc_unregister_codec(&client->dev);
-	kfree(i2c_get_clientdata(client));
+
 	return 0;
 }
 
Signature · 1 line
1.7.7.3
author
#3 lore raw

PATCH 4/4 ASoC: Use standard cache sync code in wm8961

In reply to Mark Brown

We write the reset register with the default value so it should not be mistakenly written.

---
 sound/soc/codecs/wm8961.c |   13 +------------
 1 files changed, 1 insertions(+), 12 deletions(-)
sound/soc/codecs/wm8961.c +1 -12
index 8bcc17a..4f20c72 100644
@@ -1047,18 +1047,7 @@ static int wm8961_suspend(struct snd_soc_codec *codec)
 
 static int wm8961_resume(struct snd_soc_codec *codec)
 {
-	u16 *reg_cache = codec->reg_cache;
-	int i;
-
-	for (i = 0; i < codec->driver->reg_cache_size; i++) {
-		if (reg_cache[i] == wm8961_reg_defaults[i])
-			continue;
-
-		if (i == WM8961_SOFTWARE_RESET)
-			continue;
-
-		snd_soc_write(codec, i, reg_cache[i]);
-	}
+	snd_soc_cache_sync(codec);
 
 	wm8961_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
 
Signature · 1 line
1.7.7.3