diff options
Diffstat (limited to 'linux/drivers/media/video/msp3400-driver.c')
-rw-r--r-- | linux/drivers/media/video/msp3400-driver.c | 139 |
1 files changed, 16 insertions, 123 deletions
diff --git a/linux/drivers/media/video/msp3400-driver.c b/linux/drivers/media/video/msp3400-driver.c index cd9180668..bc74cdccb 100644 --- a/linux/drivers/media/video/msp3400-driver.c +++ b/linux/drivers/media/video/msp3400-driver.c @@ -53,6 +53,7 @@ #include <linux/videodev.h> #include <linux/videodev2.h> #include <media/v4l2-common.h> +#include <media/v4l2-i2c-drv-legacy.h> #include <media/tvaudio.h> #include <media/msp3400.h> #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) @@ -825,62 +826,24 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg) return 0; } -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) -#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,14) -#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,20) static int msp_suspend(struct i2c_client *client, pm_message_t state) -#else -static int msp_suspend(struct device * dev, pm_message_t state) -#endif -#else -#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,13) -static int msp_suspend(struct device * dev, pm_message_t state, u32 level) -#else -static int msp_suspend(struct device * dev, u32 state, u32 level) -#endif -#endif { -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,20) - struct i2c_client *client = container_of(dev, struct i2c_client, dev); -#endif - v4l_dbg(1, msp_debug, client, "suspend\n"); msp_reset(client); return 0; } -#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,14) -#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,20) static int msp_resume(struct i2c_client *client) -#else -static int msp_resume(struct device * dev) -#endif -#else -static int msp_resume(struct device * dev, u32 level) -#endif { -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,20) - struct i2c_client *client = container_of(dev, struct i2c_client, dev); -#endif - v4l_dbg(1, msp_debug, client, "resume\n"); msp_wake_thread(client); return 0; } -#endif /* LINUX_VERSION_CODE */ /* ----------------------------------------------------------------------- */ -static struct i2c_driver i2c_driver; - -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) -static int msp_attach(struct i2c_adapter *adapter, int address, - unsigned short flags, int kind) -#else -static int msp_attach(struct i2c_adapter *adapter, int address, int kind) -#endif +static int msp_probe(struct i2c_client *client) { - struct i2c_client *client; struct msp_state *state; int (*thread_func)(void *data) = NULL; int msp_hard; @@ -889,27 +852,15 @@ static int msp_attach(struct i2c_adapter *adapter, int address, int kind) int msp_product, msp_prod_hi, msp_prod_lo; int msp_rom; - client = kzalloc(sizeof(*client), GFP_KERNEL); - if (!client) - 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, "msp3400"); if (msp_reset(client) == -1) { v4l_dbg(1, msp_debug, client, "msp3400 not found\n"); - kfree(client); - return 0; + return -ENODEV; } state = kzalloc(sizeof(*state), GFP_KERNEL); if (!state) { - kfree(client); return -ENOMEM; } @@ -937,8 +888,7 @@ static int msp_attach(struct i2c_adapter *adapter, int address, int kind) if (state->rev1 == -1 || (state->rev1 == 0 && state->rev2 == 0)) { v4l_dbg(1, msp_debug, client, "not an msp3400 (cannot read chip version)\n"); kfree(state); - kfree(client); - return 0; + return -ENODEV; } #if 0 @@ -1003,7 +953,7 @@ static int msp_attach(struct i2c_adapter *adapter, int address, int kind) } /* hello world :-) */ - v4l_info(client, "%s found @ 0x%x (%s)\n", client->name, address << 1, adapter->name); + v4l_info(client, "%s found @ 0x%x (%s)\n", client->name, client->addr << 1, client->adapter->name); v4l_info(client, "%s ", client->name); if (state->has_nicam && state->has_radio) printk("supports nicam and radio, "); @@ -1048,31 +998,12 @@ static int msp_attach(struct i2c_adapter *adapter, int address, int kind) #endif msp_wake_thread(client); } - - /* done */ - i2c_attach_client(client); - -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) - MOD_INC_USE_COUNT; -#endif - return 0; -} - -static int msp_probe(struct i2c_adapter *adapter) -{ -#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, msp_attach); return 0; } -static int msp_detach(struct i2c_client *client) +static int msp_remove(struct i2c_client *client) { struct msp_state *state = i2c_get_clientdata(client); - int err; /* shutdown control thread */ if (state->kthread) { @@ -1093,63 +1024,25 @@ static int msp_detach(struct i2c_client *client) } msp_reset(client); - 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 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 = "msp3400", - .flags = I2C_DF_NOTIFY, -#endif - .id = I2C_DRIVERID_MSP3400, - .attach_adapter = msp_probe, - .detach_client = msp_detach, -#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,20) +static struct v4l2_i2c_driver_data v4l2_i2c_data = { + .name = "msp3400", + .driverid = I2C_DRIVERID_MSP3400, + .command = msp_command, + .probe = msp_probe, + .remove = msp_remove, .suspend = msp_suspend, - .resume = msp_resume, -#endif - .command = msp_command, -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0) - .driver = { -#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,15) - .name = "msp3400", -#endif -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,20) - .suspend = msp_suspend, - .resume = msp_resume, -#endif - }, -#endif + .resume = msp_resume, }; -static int __init msp3400_init_module(void) -{ - return i2c_add_driver(&i2c_driver); -} - -static void __exit msp3400_cleanup_module(void) -{ - i2c_del_driver(&i2c_driver); -} - -module_init(msp3400_init_module); -module_exit(msp3400_cleanup_module); +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) +EXPORT_NO_SYMBOLS; +#endif /* * Overrides for Emacs so that we follow Linus's tabbing style. |