[alsa-devel] [PATCH 1/4] ASoC: Convert WM8960 to devm_kzalloc()
Signed-off-by: Mark Brown broonie@opensource.wolfsonmicro.com --- sound/soc/codecs/wm8960.c | 7 +++---- 1 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/sound/soc/codecs/wm8960.c b/sound/soc/codecs/wm8960.c index 2315b86..e5caae3 100644 --- a/sound/soc/codecs/wm8960.c +++ b/sound/soc/codecs/wm8960.c @@ -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; }
The driver only supports I2C so no need to conditionalise its use.
Signed-off-by: Mark Brown broonie@opensource.wolfsonmicro.com --- sound/soc/codecs/wm8961.c | 6 ------ 1 files changed, 0 insertions(+), 6 deletions(-)
diff --git a/sound/soc/codecs/wm8961.c b/sound/soc/codecs/wm8961.c index 58fbf0a..13a0850 100644 --- a/sound/soc/codecs/wm8961.c +++ b/sound/soc/codecs/wm8961.c @@ -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);
Signed-off-by: Mark Brown broonie@opensource.wolfsonmicro.com --- sound/soc/codecs/wm8961.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/sound/soc/codecs/wm8961.c b/sound/soc/codecs/wm8961.c index 13a0850..8bcc17a 100644 --- a/sound/soc/codecs/wm8961.c +++ b/sound/soc/codecs/wm8961.c @@ -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; }
We write the reset register with the default value so it should not be mistakenly written.
Signed-off-by: Mark Brown broonie@opensource.wolfsonmicro.com --- sound/soc/codecs/wm8961.c | 13 +------------ 1 files changed, 1 insertions(+), 12 deletions(-)
diff --git a/sound/soc/codecs/wm8961.c b/sound/soc/codecs/wm8961.c index 8bcc17a..4f20c72 100644 --- a/sound/soc/codecs/wm8961.c +++ b/sound/soc/codecs/wm8961.c @@ -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);
participants (1)
-
Mark Brown