diff options
author | Jean Delvare <khali@linux-fr.org> | 2008-11-19 17:10:55 +0000 |
---|---|---|
committer | Andy Green <agreen@pads.home.warmcat.com> | 2008-11-19 17:10:55 +0000 |
commit | 6fab8077091c1caaac32fda150fd6ef26918569e (patch) | |
tree | 668d48e3cbdad938fad804763d43098a34050bfe | |
parent | 3c55e0e19b71483f20604966dcdc6dc765c9a436 (diff) |
ASoC: Convert neo1973/lm4857 to a new-style i2c driver
Convert the lm4857 driver in neo1973_wm8753 to the new (standard)
i2c device driver binding model. I assumed that the LM4857 was always
on the same I2C bus as the WM8753 codec.
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Cc: Tim Niemeyer <reddog@mastersword.de>
Cc: Graeme Gregory <graeme@openmoko.org>
Cc: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
-rw-r--r-- | sound/soc/s3c24xx/neo1973_wm8753.c | 56 |
1 files changed, 47 insertions, 9 deletions
diff --git a/sound/soc/s3c24xx/neo1973_wm8753.c b/sound/soc/s3c24xx/neo1973_wm8753.c index 4ac2aae5ca0..3c3429d2a1c 100644 --- a/sound/soc/s3c24xx/neo1973_wm8753.c +++ b/sound/soc/s3c24xx/neo1973_wm8753.c @@ -602,8 +602,6 @@ static int lm4857_i2c_probe(struct i2c_client *client, { DBG("Entered %s\n", __func__); - i2c = client; - lm4857_write_regs(); return 0; } @@ -612,8 +610,6 @@ static int lm4857_i2c_remove(struct i2c_client *client) { DBG("Entered %s\n", __func__); - i2c = NULL; - return 0; } @@ -653,7 +649,7 @@ static void lm4857_shutdown(struct i2c_client *dev) } static const struct i2c_device_id lm4857_i2c_id[] = { - { "neo1973_lm4857", 0 }, + { "neo1973_lm4857", 0 } { } }; @@ -671,6 +667,48 @@ static struct i2c_driver lm4857_i2c_driver = { }; static struct platform_device *neo1973_snd_device; +static struct i2c_client *lm4857_client; + +static int __init neo1973_add_lm4857_device(struct platform_device *pdev, + int i2c_bus, + unsigned short i2c_address) +{ + struct i2c_board_info info; + struct i2c_adapter *adapter; + struct i2c_client *client; + int ret; + + ret = i2c_add_driver(&lm4857_i2c_driver); + if (ret != 0) { + dev_err(&pdev->dev, "can't add lm4857 driver\n"); + return ret; + } + + memset(&info, 0, sizeof(struct i2c_board_info)); + info.addr = i2c_address; + strlcpy(info.type, "neo1973_lm4857", I2C_NAME_SIZE); + + adapter = i2c_get_adapter(i2c_bus); + if (!adapter) { + dev_err(&pdev->dev, "can't get i2c adapter %d\n", i2c_bus); + goto err_driver; + } + + client = i2c_new_device(adapter, &info); + i2c_put_adapter(adapter); + if (!client) { + dev_err(&pdev->dev, "can't add lm4857 device at 0x%x\n", + (unsigned int)info.addr); + goto err_driver; + } + + lm4857_client = client; + return 0; + +err_driver: + i2c_del_driver(&lm4857_i2c_driver); + return -ENODEV; +} static int __init neo1973_init(void) { @@ -697,11 +735,10 @@ static int __init neo1973_init(void) return ret; } - ret = i2c_add_driver(&lm4857_i2c_driver); - if (ret != 0) { - printk(KERN_ERR "can't add i2c driver"); + ret = neo1973_add_lm4857_device(neo1973_snd_device, + neo1973_wm8753_setup, 0x7C); + if (ret != 0) platform_device_unregister(neo1973_snd_device); - } return ret; } @@ -710,6 +747,7 @@ static void __exit neo1973_exit(void) { DBG("Entered %s\n", __func__); + i2c_unregister_device(lm4857_client); i2c_del_driver(&lm4857_i2c_driver); platform_device_unregister(neo1973_snd_device); } |