diff options
author | Hans Verkuil <hverkuil@xs4all.nl> | 2007-09-14 09:58:06 +0200 |
---|---|---|
committer | Hans Verkuil <hverkuil@xs4all.nl> | 2007-09-14 09:58:06 +0200 |
commit | e5f182c1d62f1ea1f7dc45d7f1b9d241fb1e6c74 (patch) | |
tree | 6402ab5218c930493bc897162ebe22977f99b82f /linux | |
parent | b3aa8ed04b7cab08e4a997aec02c02ce0b3809bd (diff) | |
download | mediapointer-dvb-s2-e5f182c1d62f1ea1f7dc45d7f1b9d241fb1e6c74.tar.gz mediapointer-dvb-s2-e5f182c1d62f1ea1f7dc45d7f1b9d241fb1e6c74.tar.bz2 |
upd64083: 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/upd64083.c | 96 ++++-------------------------------
1 file changed, 13 insertions(+), 83 deletions(-)
Diffstat (limited to 'linux')
-rw-r--r-- | linux/drivers/media/video/upd64083.c | 96 |
1 files changed, 13 insertions, 83 deletions
diff --git a/linux/drivers/media/video/upd64083.c b/linux/drivers/media/video/upd64083.c index ccf340a5b..280c593d0 100644 --- a/linux/drivers/media/video/upd64083.c +++ b/linux/drivers/media/video/upd64083.c @@ -27,6 +27,7 @@ #include <linux/videodev2.h> #include <media/v4l2-common.h> #include <media/v4l2-chip-ident.h> +#include <media/v4l2-i2c-drv-legacy.h> #include <media/upd64083.h> #include "compat.h" @@ -179,40 +180,18 @@ static int upd64083_command(struct i2c_client *client, unsigned int cmd, void *a /* i2c implementation */ -static struct i2c_driver i2c_driver; - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) -static int upd64083_attach(struct i2c_adapter *adapter, int address, int kind) -#else -static int upd64083_attach(struct i2c_adapter *adapter, int address, - unsigned short flags, int kind) -#endif +static int upd64083_probe(struct i2c_client *client) { - struct i2c_client *client; struct upd64083_state *state; int i; - if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) + if (!i2c_check_functionality(client->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, "uPD64083"); - - 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 upd64083_state), GFP_KERNEL); if (state == NULL) { - kfree(client); return -ENOMEM; } i2c_set_clientdata(client, state); @@ -223,74 +202,25 @@ static int upd64083_attach(struct i2c_adapter *adapter, int address, for (i = 0; i < TOT_REGS; i++) { upd64083_write(client, i, state->regs[i]); } - i2c_attach_client(client); - -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) - MOD_INC_USE_COUNT; -#endif return 0; } -static int upd64083_probe(struct i2c_adapter *adapter) +static int upd64083_remove(struct i2c_client *client) { -#ifdef I2C_CLASS_TV_ANALOG - if (adapter->class & I2C_CLASS_TV_ANALOG) -#else - if (adapter->id == I2C_HW_B_BT848) -#endif - return i2c_probe(adapter, &addr_data, upd64083_attach); - return 0; -} - -static int upd64083_detach(struct i2c_client *client) -{ - int err; - - err = i2c_detach_client(client); - if (err) - return err; - - 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) - .name = "upd64083", - .flags = I2C_DF_NOTIFY, -#else - .driver = { - .name = "upd64083", - }, -#endif - .id = I2C_DRIVERID_UPD64083, - .attach_adapter = upd64083_probe, - .detach_client = upd64083_detach, - .command = upd64083_command, -}; - #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) EXPORT_NO_SYMBOLS; #endif -static int __init upd64083_init_module(void) -{ - return i2c_add_driver(&i2c_driver); -} - -static void __exit upd64083_exit_module(void) -{ - i2c_del_driver(&i2c_driver); -} - -module_init(upd64083_init_module); -module_exit(upd64083_exit_module); +static struct v4l2_i2c_driver_data v4l2_i2c_data = { + .name = "upd64083", + .driverid = I2C_DRIVERID_UPD64083, + .command = upd64083_command, + .probe = upd64083_probe, + .remove = upd64083_remove, +}; |