Merge branch 'topic/asoc' into for-linus
[safe/jmp/linux-2.6] / sound / soc / codecs / wm9081.c
index c64e55a..13186fb 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/pm.h>
 #include <linux/i2c.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 #include <sound/core.h>
 #include <sound/pcm.h>
 #include <sound/pcm_params.h>
@@ -520,7 +521,7 @@ static int fll_factors(struct _fll_div *fll_div, unsigned int Fref,
 static int wm9081_set_fll(struct snd_soc_codec *codec, int fll_id,
                          unsigned int Fref, unsigned int Fout)
 {
-       struct wm9081_priv *wm9081 = codec->private_data;
+       struct wm9081_priv *wm9081 = snd_soc_codec_get_drvdata(codec);
        u16 reg1, reg4, reg5;
        struct _fll_div fll_div;
        int ret;
@@ -606,7 +607,7 @@ static int wm9081_set_fll(struct snd_soc_codec *codec, int fll_id,
 
 static int configure_clock(struct snd_soc_codec *codec)
 {
-       struct wm9081_priv *wm9081 = codec->private_data;
+       struct wm9081_priv *wm9081 = snd_soc_codec_get_drvdata(codec);
        int new_sysclk, i, target;
        unsigned int reg;
        int ret = 0;
@@ -701,7 +702,7 @@ static int clk_sys_event(struct snd_soc_dapm_widget *w,
                         struct snd_kcontrol *kcontrol, int event)
 {
        struct snd_soc_codec *codec = w->codec;
-       struct wm9081_priv *wm9081 = codec->private_data;
+       struct wm9081_priv *wm9081 = snd_soc_codec_get_drvdata(codec);
 
        /* This should be done on init() for bypass paths */
        switch (wm9081->sysclk_source) {
@@ -872,7 +873,7 @@ static int wm9081_set_dai_fmt(struct snd_soc_dai *dai,
                              unsigned int fmt)
 {
        struct snd_soc_codec *codec = dai->codec;
-       struct wm9081_priv *wm9081 = codec->private_data;
+       struct wm9081_priv *wm9081 = snd_soc_codec_get_drvdata(codec);
        unsigned int aif2 = snd_soc_read(codec, WM9081_AUDIO_INTERFACE_2);
 
        aif2 &= ~(WM9081_AIF_BCLK_INV | WM9081_AIF_LRCLK_INV |
@@ -964,7 +965,7 @@ static int wm9081_hw_params(struct snd_pcm_substream *substream,
                            struct snd_soc_dai *dai)
 {
        struct snd_soc_codec *codec = dai->codec;
-       struct wm9081_priv *wm9081 = codec->private_data;
+       struct wm9081_priv *wm9081 = snd_soc_codec_get_drvdata(codec);
        int ret, i, best, best_val, cur_val;
        unsigned int clk_ctrl2, aif1, aif2, aif3, aif4;
 
@@ -1027,7 +1028,7 @@ static int wm9081_hw_params(struct snd_pcm_substream *substream,
                       - wm9081->fs);
        for (i = 1; i < ARRAY_SIZE(clk_sys_rates); i++) {
                cur_val = abs((wm9081->sysclk_rate /
-                              clk_sys_rates[i].ratio) - wm9081->fs);;
+                              clk_sys_rates[i].ratio) - wm9081->fs);
                if (cur_val < best_val) {
                        best = i;
                        best_val = cur_val;
@@ -1138,7 +1139,7 @@ static int wm9081_set_sysclk(struct snd_soc_dai *codec_dai,
                             int clk_id, unsigned int freq, int dir)
 {
        struct snd_soc_codec *codec = codec_dai->codec;
-       struct wm9081_priv *wm9081 = codec->private_data;
+       struct wm9081_priv *wm9081 = snd_soc_codec_get_drvdata(codec);
 
        switch (clk_id) {
        case WM9081_SYSCLK_MCLK:
@@ -1158,7 +1159,7 @@ static int wm9081_set_tdm_slot(struct snd_soc_dai *dai,
        unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width)
 {
        struct snd_soc_codec *codec = dai->codec;
-       struct wm9081_priv *wm9081 = codec->private_data;
+       struct wm9081_priv *wm9081 = snd_soc_codec_get_drvdata(codec);
        unsigned int aif1 = snd_soc_read(codec, WM9081_AUDIO_INTERFACE_1);
 
        aif1 &= ~(WM9081_AIFDAC_TDM_SLOT_MASK | WM9081_AIFDAC_TDM_MODE_MASK);
@@ -1241,7 +1242,7 @@ static int wm9081_probe(struct platform_device *pdev)
 
        socdev->card->codec = wm9081_codec;
        codec = wm9081_codec;
-       wm9081 = codec->private_data;
+       wm9081 = snd_soc_codec_get_drvdata(codec);
 
        /* register pcms */
        ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1);
@@ -1262,19 +1263,9 @@ static int wm9081_probe(struct platform_device *pdev)
        snd_soc_dapm_new_controls(codec, wm9081_dapm_widgets,
                                  ARRAY_SIZE(wm9081_dapm_widgets));
        snd_soc_dapm_add_routes(codec, audio_paths, ARRAY_SIZE(audio_paths));
-       snd_soc_dapm_new_widgets(codec);
-
-       ret = snd_soc_init_card(socdev);
-       if (ret < 0) {
-               dev_err(codec->dev, "failed to register card: %d\n", ret);
-               goto card_err;
-       }
 
        return ret;
 
-card_err:
-       snd_soc_free_pcms(socdev);
-       snd_soc_dapm_free(socdev);
 pcm_err:
        return ret;
 }
@@ -1348,7 +1339,7 @@ static int wm9081_register(struct wm9081_priv *wm9081,
        INIT_LIST_HEAD(&codec->dapm_widgets);
        INIT_LIST_HEAD(&codec->dapm_paths);
 
-       codec->private_data = wm9081;
+       snd_soc_codec_set_drvdata(codec, wm9081);
        codec->name = "WM9081";
        codec->owner = THIS_MODULE;
        codec->dai = &wm9081_dai;
@@ -1452,21 +1443,6 @@ static __devexit int wm9081_i2c_remove(struct i2c_client *client)
        return 0;
 }
 
-#ifdef CONFIG_PM
-static int wm9081_i2c_suspend(struct i2c_client *client, pm_message_t msg)
-{
-       return snd_soc_suspend_device(&client->dev);
-}
-
-static int wm9081_i2c_resume(struct i2c_client *client)
-{
-       return snd_soc_resume_device(&client->dev);
-}
-#else
-#define wm9081_i2c_suspend NULL
-#define wm9081_i2c_resume NULL
-#endif
-
 static const struct i2c_device_id wm9081_i2c_id[] = {
        { "wm9081", 0 },
        { }
@@ -1480,8 +1456,6 @@ static struct i2c_driver wm9081_i2c_driver = {
        },
        .probe =    wm9081_i2c_probe,
        .remove =   __devexit_p(wm9081_i2c_remove),
-       .suspend =  wm9081_i2c_suspend,
-       .resume =   wm9081_i2c_resume,
        .id_table = wm9081_i2c_id,
 };