diff options
author | Andy Green <andy@openmoko.com> | 2008-11-19 17:11:06 +0000 |
---|---|---|
committer | Andy Green <andy@openmoko.com> | 2008-11-19 17:11:06 +0000 |
commit | d5b248f08d34926f3136c2b7b611ea1aff19d238 (patch) | |
tree | dc5db2124018d30d3471f489b45f37be852ea343 /sound | |
parent | c727e99d84972bd03f62de99acffcfc4e13952b9 (diff) |
tracking-2.6.28-breakage-after-change-to-64xx-tree.patch
Signed-off-by: Andy Green <andy@openmoko.com>
Diffstat (limited to 'sound')
-rw-r--r-- | sound/soc/codecs/wm8753.c | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/sound/soc/codecs/wm8753.c b/sound/soc/codecs/wm8753.c index 04553e22575..4706b87d3f1 100644 --- a/sound/soc/codecs/wm8753.c +++ b/sound/soc/codecs/wm8753.c @@ -1684,6 +1684,47 @@ static struct i2c_driver wm8753_i2c_driver = { .class = I2C_CLASS_SOUND }; +static int wm8753_add_i2c_device(struct platform_device *pdev, + const struct wm8753_setup_data *setup) +{ + struct i2c_board_info info; + struct i2c_adapter *adapter; + struct i2c_client *client; + int ret; + + ret = i2c_add_driver(&wm8753_i2c_driver); + if (ret != 0) { + dev_err(&pdev->dev, "can't add i2c driver\n"); + return ret; + } + + memset(&info, 0, sizeof(struct i2c_board_info)); + info.addr = setup->i2c_address; + strlcpy(info.type, "wm8753", I2C_NAME_SIZE); + + adapter = i2c_get_adapter(setup->i2c_bus); + if (!adapter) { + dev_err(&pdev->dev, "can't get i2c adapter %d\n", + setup->i2c_bus); + goto err_driver; + } + + client = i2c_new_device(adapter, &info); + i2c_put_adapter(adapter); + if (!client) { + dev_err(&pdev->dev, "can't add i2c device at 0x%x\n", + (unsigned int)info.addr); + goto err_driver; + } + + return 0; + +err_driver: + i2c_del_driver(&wm8753_i2c_driver); + return -ENODEV; +} + + #endif #if defined(CONFIG_SPI_MASTER) @@ -1746,12 +1787,14 @@ static int wm8753_spi_write(struct spi_device *spi, const char *data, int len) static int wm8753_probe(struct platform_device *pdev) { struct snd_soc_device *socdev = platform_get_drvdata(pdev); + struct wm8753_setup_data *setup; struct snd_soc_codec *codec; struct wm8753_priv *wm8753; int ret = 0; pr_info("WM8753 Audio Codec %s\n", WM8753_VERSION); + setup = socdev->codec_data; codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL); if (codec == NULL) return -ENOMEM; @@ -1773,7 +1816,7 @@ static int wm8753_probe(struct platform_device *pdev) #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) if (setup->i2c_address) { codec->hw_write = (hw_write_t)i2c_master_send; - ret = add_i2c_device(pdev, setup); + ret = wm8753_add_i2c_device(pdev, setup); } #endif #if defined(CONFIG_SPI_MASTER) |