diff options
author | Hans Verkuil <hverkuil@xs4all.nl> | 2007-09-13 16:10:07 +0200 |
---|---|---|
committer | Hans Verkuil <hverkuil@xs4all.nl> | 2007-09-13 16:10:07 +0200 |
commit | 9d69c811776a2ca50f901effcb999e8662d5c504 (patch) | |
tree | 1560c3f02d19bdc0d681cad3f176386209e59d6b /linux/drivers/media | |
parent | 9ffc9b84fc6de477f366efda9e590838e05bcc98 (diff) | |
download | mediapointer-dvb-s2-9d69c811776a2ca50f901effcb999e8662d5c504.tar.gz mediapointer-dvb-s2-9d69c811776a2ca50f901effcb999e8662d5c504.tar.bz2 |
wm8739: convert to bus-based I2C API.
From: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
---
linux/drivers/media/video/wm8739.c | 98 ++++---------------------------------
1 file changed, 12 insertions(+), 86 deletions(-)
Diffstat (limited to 'linux/drivers/media')
-rw-r--r-- | linux/drivers/media/video/wm8739.c | 98 |
1 files changed, 12 insertions, 86 deletions
diff --git a/linux/drivers/media/video/wm8739.c b/linux/drivers/media/video/wm8739.c index 999c25a30..953c47ed4 100644 --- a/linux/drivers/media/video/wm8739.c +++ b/linux/drivers/media/video/wm8739.c @@ -30,6 +30,7 @@ #include <linux/videodev.h> #include <media/v4l2-common.h> #include <media/v4l2-chip-ident.h> +#include <media/v4l2-i2c-drv-legacy.h> #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) #include "i2c-compat.h" #include <linux/slab.h> @@ -271,35 +272,11 @@ static int wm8739_command(struct i2c_client *client, unsigned int cmd, void *arg /* i2c implementation */ -static struct i2c_driver i2c_driver; - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) -static int wm8739_attach(struct i2c_adapter *adapter, int address, int kind) -#else -static int wm8739_attach(struct i2c_adapter *adapter, int address, - unsigned short flags, int kind) -#endif +static int wm8739_probe(struct i2c_client *client) { - struct i2c_client *client; struct wm8739_state *state; - /* Check if the adapter supports the needed features */ - if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) - return 0; - - client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL); - if (client == NULL) - return -ENOMEM; - - client->addr = address; - client->adapter = adapter; - client->driver = &i2c_driver; -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,15) - client->flags = I2C_CLIENT_ALLOW_USE; -#endif - snprintf(client->name, sizeof(client->name) - 1, "wm8739"); - - v4l_info(client, "chip found @ 0x%x (%s)\n", address << 1, adapter->name); + v4l_info(client, "chip found @ 0x%x (%s)\n", client->addr << 1, client->adapter->name); state = kmalloc(sizeof(struct wm8739_state), GFP_KERNEL); if (state == NULL) { @@ -326,77 +303,26 @@ static int wm8739_attach(struct i2c_adapter *adapter, int address, /* normal, 256fs, 48KHz sampling rate */ wm8739_write(client, R9, 0x001); /* activate */ wm8739_set_audio(client); /* set volume/mute */ - - i2c_attach_client(client); - -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) - MOD_INC_USE_COUNT; -#endif - return 0; -} - -static int wm8739_probe(struct i2c_adapter *adapter) -{ -#ifdef I2C_CLASS_TV_ANALOG - if (adapter->class & I2C_CLASS_TV_ANALOG) -#else - if (adapter->id == I2C_HW_B_CX2341X) -#endif - return i2c_probe(adapter, &addr_data, wm8739_attach); return 0; } -static int wm8739_detach(struct i2c_client *client) +static int wm8739_remove(struct i2c_client *client) { - struct wm8739_state *state = i2c_get_clientdata(client); - int err; - - err = i2c_detach_client(client); - if (err) - return err; - - kfree(state); - kfree(client); -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) - MOD_DEC_USE_COUNT; -#endif + kfree(i2c_get_clientdata(client)); return 0; } -/* ----------------------------------------------------------------------- */ - -/* i2c implementation */ -static struct i2c_driver i2c_driver = { -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) && LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,15) - .owner = THIS_MODULE, -#endif -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,15) +static struct v4l2_i2c_driver_data v4l2_i2c_data = { .name = "wm8739", - .flags = I2C_DF_NOTIFY, -#else - .driver = { - .name = "wm8739", - }, -#endif - .id = I2C_DRIVERID_WM8739, - .attach_adapter = wm8739_probe, - .detach_client = wm8739_detach, + .driverid = I2C_DRIVERID_WM8739, .command = wm8739_command, + .probe = wm8739_probe, + .remove = wm8739_remove, +#ifndef I2C_CLASS_TV_ANALOG + .legacy_id = I2C_HW_B_CX2341X, +#endif }; #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) EXPORT_NO_SYMBOLS; #endif - -static int __init wm8739_init_module(void) -{ - return i2c_add_driver(&i2c_driver); -} - -static void __exit wm8739_cleanup_module(void) -{ - i2c_del_driver(&i2c_driver); -} - -module_init(wm8739_init_module); -module_exit(wm8739_cleanup_module); |