Re: i2c changes in 2.6.15+
On Tue, Jan 24, 2006 at 11:03:35PM +0100, Nicolas Boullis wrote:
>
> I just made the corresponding changes. Please see (and try) the attached
> patch.
Here it is.
Nicolas
Index: modules/adv717x.c
===================================================================
RCS file: /cvsroot/dxr3/em8300/modules/adv717x.c,v
retrieving revision 1.49
diff -u -r1.49 adv717x.c
--- modules/adv717x.c 5 Nov 2005 01:12:13 -0000 1.49
+++ modules/adv717x.c 24 Jan 2006 22:02:56 -0000
@@ -199,12 +199,18 @@
/* This is the driver that will be inserted */
static struct i2c_driver adv717x_driver = {
-#if defined(EM8300_I2C_FORCE_NEW_API) || (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,54) && !defined(EM8300_I2C_FORCE_OLD_API))
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
+ .driver = {
+ .name = "adv717x",
+ },
+#else
+#if defined(EM8300_I2C_FORCE_NEW_API) || LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,54)
.owner = THIS_MODULE,
#endif
- .name = "ADV717X video encoder driver",
- .id = I2C_DRIVERID_ADV717X,
+ .name = "adv717x",
.flags = I2C_DF_NOTIFY,
+#endif
+ .id = I2C_DRIVERID_ADV717X,
.attach_adapter = &adv717x_attach_adapter,
.detach_client = &adv717x_detach_client,
.command = &adv717x_command
Index: modules/bt865.c
===================================================================
RCS file: /cvsroot/dxr3/em8300/modules/bt865.c,v
retrieving revision 1.40
diff -u -r1.40 bt865.c
--- modules/bt865.c 15 Nov 2005 07:15:16 -0000 1.40
+++ modules/bt865.c 24 Jan 2006 22:02:56 -0000
@@ -87,12 +87,18 @@
/* This is the driver that will be inserted */
static struct i2c_driver bt865_driver = {
-#if defined(EM8300_I2C_FORCE_NEW_API) || (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,54) && !defined(EM8300_I2C_FORCE_OLD_API))
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
+ .driver = {
+ .name = "bt865",
+ },
+#else
+#if defined(EM8300_I2C_FORCE_NEW_API) || LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,54)
.owner = THIS_MODULE,
#endif
- .name = "BT865 video encoder driver",
- .id = I2C_DRIVERID_BT865,
+ .name = "bt865",
.flags = I2C_DF_NOTIFY,
+#endif
+ .id = I2C_DRIVERID_BT865,
.attach_adapter = &bt865_attach_adapter,
.detach_client = &bt865_detach_client,
.command = &bt865_command
Index: modules/em8300_i2c.c
===================================================================
RCS file: /cvsroot/dxr3/em8300/modules/em8300_i2c.c,v
retrieving revision 1.24
diff -u -r1.24 em8300_i2c.c
--- modules/em8300_i2c.c 18 Nov 2005 23:29:07 -0000 1.24
+++ modules/em8300_i2c.c 24 Jan 2006 22:02:56 -0000
@@ -77,8 +77,12 @@
static int em8300_i2c_lock_client(struct i2c_client *client)
{
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,54) && !defined(EM8300_I2C_FORCE_OLD_API))
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,54)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
+ if (!try_module_get(client->driver->driver.owner)) {
+#else
if (!try_module_get(client->driver->owner)) {
+#endif
printk(KERN_ERR "em8300_i2c: Unable to lock client module\n");
return -ENODEV;
}
@@ -129,9 +133,13 @@
case I2C_DRIVERID_ADV717X:
case I2C_DRIVERID_BT865:
em->encoder = NULL;
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,54) && !defined(EM8300_I2C_FORCE_OLD_API))
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,54)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
+ module_put(client->driver->driver.owner);
+#else
module_put(client->driver->owner);
#endif
+#endif
break;
}