]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - sound/soc/codecs/wm8731.c
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/x86/linux...
[linux-2.6-omap-h63xx.git] / sound / soc / codecs / wm8731.c
index e6b990507df24b293d03a169a6efe56a088d3ec9..0cf9265fca8fb54ef9c66d1704a896738b60d227 100644 (file)
@@ -19,7 +19,6 @@
 #include <linux/pm.h>
 #include <linux/i2c.h>
 #include <linux/platform_device.h>
-#include <sound/driver.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
@@ -111,7 +110,7 @@ static int wm8731_write(struct snd_soc_codec *codec, unsigned int reg,
        data[0] = (reg << 1) | ((value >> 8) & 0x0001);
        data[1] = value & 0x00ff;
 
-       wm8731_write_reg_cache (codec, reg, value);
+       wm8731_write_reg_cache(codec, reg, value);
        if (codec->hw_write(codec->control_data, data, 2) == 2)
                return 0;
        else
@@ -155,8 +154,10 @@ static int wm8731_add_controls(struct snd_soc_codec *codec)
        int err, i;
 
        for (i = 0; i < ARRAY_SIZE(wm8731_snd_controls); i++) {
-               if ((err = snd_ctl_add(codec->card,
-                               snd_soc_cnew(&wm8731_snd_controls[i],codec, NULL))) < 0)
+               err = snd_ctl_add(codec->card,
+                                 snd_soc_cnew(&wm8731_snd_controls[i],
+                                               codec, NULL));
+               if (err < 0)
                        return err;
        }
 
@@ -222,15 +223,13 @@ static int wm8731_add_widgets(struct snd_soc_codec *codec)
 {
        int i;
 
-       for(i = 0; i < ARRAY_SIZE(wm8731_dapm_widgets); i++) {
+       for (i = 0; i < ARRAY_SIZE(wm8731_dapm_widgets); i++)
                snd_soc_dapm_new_control(codec, &wm8731_dapm_widgets[i]);
-       }
 
        /* set up audio path interconnects */
-       for(i = 0; intercon[i][0] != NULL; i++) {
+       for (i = 0; intercon[i][0] != NULL; i++)
                snd_soc_dapm_connect_input(codec, intercon[i][0],
                        intercon[i][1], intercon[i][2]);
-       }
 
        snd_soc_dapm_new_widgets(codec);
        return 0;
@@ -543,14 +542,10 @@ static int wm8731_init(struct snd_soc_device *socdev)
        codec->dapm_event = wm8731_dapm_event;
        codec->dai = &wm8731_dai;
        codec->num_dai = 1;
-       codec->reg_cache_size = ARRAY_SIZE(wm8731_reg);
-       codec->reg_cache =
-                       kzalloc(sizeof(u16) * ARRAY_SIZE(wm8731_reg), GFP_KERNEL);
+       codec->reg_cache_size = sizeof(wm8731_reg);
+       codec->reg_cache = kmemdup(wm8731_reg, sizeof(wm8731_reg), GFP_KERNEL);
        if (codec->reg_cache == NULL)
                return -ENOMEM;
-       memcpy(codec->reg_cache,
-               wm8731_reg, sizeof(u16) * ARRAY_SIZE(wm8731_reg));
-       codec->reg_cache_size = sizeof(u16) * ARRAY_SIZE(wm8731_reg);
 
        wm8731_reset(codec);
 
@@ -566,13 +561,13 @@ static int wm8731_init(struct snd_soc_device *socdev)
 
        /* set the update bits */
        reg = wm8731_read_reg_cache(codec, WM8731_LOUT1V);
-       wm8731_write(codec, WM8731_LOUT1V, reg 0x0100);
+       wm8731_write(codec, WM8731_LOUT1V, reg & ~0x0100);
        reg = wm8731_read_reg_cache(codec, WM8731_ROUT1V);
-       wm8731_write(codec, WM8731_ROUT1V, reg 0x0100);
+       wm8731_write(codec, WM8731_ROUT1V, reg & ~0x0100);
        reg = wm8731_read_reg_cache(codec, WM8731_LINVOL);
-       wm8731_write(codec, WM8731_LINVOL, reg 0x0100);
+       wm8731_write(codec, WM8731_LINVOL, reg & ~0x0100);
        reg = wm8731_read_reg_cache(codec, WM8731_RINVOL);
-       wm8731_write(codec, WM8731_RINVOL, reg 0x0100);
+       wm8731_write(codec, WM8731_RINVOL, reg & ~0x0100);
 
        wm8731_add_controls(codec);
        wm8731_add_widgets(codec);
@@ -594,7 +589,7 @@ pcm_err:
 
 static struct snd_soc_device *wm8731_socdev;
 
-#if defined (CONFIG_I2C) || defined (CONFIG_I2C_MODULE)
+#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
 
 /*
  * WM8731 2 wire address is determined by GPIO5
@@ -627,12 +622,11 @@ static int wm8731_codec_probe(struct i2c_adapter *adap, int addr, int kind)
        client_template.adapter = adap;
        client_template.addr = addr;
 
-       i2c = kzalloc(sizeof(struct i2c_client), GFP_KERNEL);
+       i2c = kmemdup(&client_template, sizeof(client_template), GFP_KERNEL);
        if (i2c == NULL) {
                kfree(codec);
                return -ENOMEM;
        }
-       memcpy(i2c, &client_template, sizeof(struct i2c_client));
        i2c_set_clientdata(i2c, codec);
        codec->control_data = i2c;
 
@@ -657,7 +651,7 @@ err:
 
 static int wm8731_i2c_detach(struct i2c_client *client)
 {
-       struct snd_soc_codeccodec = i2c_get_clientdata(client);
+       struct snd_soc_codec *codec = i2c_get_clientdata(client);
        i2c_detach_client(client);
        kfree(codec->reg_cache);
        kfree(client);
@@ -715,7 +709,7 @@ static int wm8731_probe(struct platform_device *pdev)
        INIT_LIST_HEAD(&codec->dapm_paths);
 
        wm8731_socdev = socdev;
-#if defined (CONFIG_I2C) || defined (CONFIG_I2C_MODULE)
+#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
        if (setup->i2c_address) {
                normal_i2c[0] = setup->i2c_address;
                codec->hw_write = (hw_write_t)i2c_master_send;
@@ -740,7 +734,7 @@ static int wm8731_remove(struct platform_device *pdev)
 
        snd_soc_free_pcms(socdev);
        snd_soc_dapm_free(socdev);
-#if defined (CONFIG_I2C) || defined (CONFIG_I2C_MODULE)
+#if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
        i2c_del_driver(&wm8731_i2c_driver);
 #endif
        kfree(codec->private_data);
@@ -755,7 +749,6 @@ struct snd_soc_codec_device soc_codec_dev_wm8731 = {
        .suspend =      wm8731_suspend,
        .resume =       wm8731_resume,
 };
-
 EXPORT_SYMBOL_GPL(soc_codec_dev_wm8731);
 
 MODULE_DESCRIPTION("ASoC WM8731 driver");