Trent, Em Dom, 2006-05-14 às 08:06 -0700, Trent Piepho escreveu: > On Sun, 14 May 2006, Mauro Carvalho Chehab wrote: > > Em Sb, 2006-05-13 s 14:55 -0700, Trent Piepho escreveu: > > > I'd like to improve the way struct i2c_driver compatibility is handled. Here > > > are three versions of what the driver could would look like. I've removed a > > > few lines of code that aren't relevant. > > Hmm... I didn't got the idea of versions. Perhaps you've forgot to > > include something? > > Maybe they got stripped somehow? It's in my message on the list archive: > http://www.linuxtv.org/pipermail/linux-dvb/2006-May/010210.html hmm... perhaps I just didn't understood... After reading with more time, it seems me clearer. I2C code have a bad historic in terms of changing. For example, on every kernel from 2.6.12 to 2.6.16, there were some changes at I2C interfaces. There are also some changes expected to 2.6.18 (although, afaik, it shoudn't break backward compat). For an I2C macro to work, there are some options: 1) To have such macros at I2C headers. In this case, we should consult i2c maintainer. 2) to declare such macros on a common header to be included on every v4l/dvb i2c driver. Seems weird to have a I2C macro outside i2c stuff... 3) To give gentree.pl the capability of expanding macros. This is not a very easy task, although it is not impossible. It will also require that every new included code to be converted to this non-standard way. This will generate a "proprietary" way of handling I2C drivers inside our tree, with, IMO, sucks. 4) To have a copy of macro evaluation to the newest kernel inside gentree.pl. This would be terrible, since every new i2c change will generate change also at this macro evaluation at gentree. IMHO, if we cannot go with (1), better to leave as is. > Here is a cut and paste: > > Version 1: Has compatibility for pre 2.6.0. For kernel >= 2.6.16, the > macro V4LCOMPAT_I2C_DRIVER() will be blank. > > static struct i2c_driver i2c_driver_saa7115 = { > #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,15) > .driver = { > .name = "saa7115", > }, > #endif > .id = I2C_DRIVERID_SAA711X, > V4LCOMPAT_I2C_DRIVER("saa7115") > }; > > Version 2: Only back compatible to 2.6.0. For >= 2.6.16, the macro > V4LCOMPAT_I2C_DRIVER() will be blank. > > static struct i2c_driver i2c_driver_saa7115 = { > .driver = { > .name = "saa7115", > }, > .id = I2C_DRIVERID_SAA711X, > V4LCOMPAT_I2C_DRIVER("saa7115") > }; > > Version 3: Has compatibility to pre 2.6.0, For kernel >= 2.6.16, the > macro V4LCOMPAT_I2C_DRIVER() _will_ expand to real code. > > static struct i2c_driver i2c_driver_saa7115 = { > .id = I2C_DRIVERID_SAA711X, > V4LCOMPAT_I2C_DRIVER("saa7115") > }; > > Version 3 has the best compatibility and is the cleanest looking, but it > doesn't disappear when compiling on the latest kernel, instead it emits the > code that is correct for the latest kernel. > > Version 2 nearly as clean, but doesn't support pre 2.6.0. > > To compare, this is the mess that is there now: > static struct i2c_driver 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 = "tuner", > .flags = I2C_DF_NOTIFY, > #endif > .id = I2C_DRIVERID_TUNER, > .attach_adapter = tuner_probe, > .detach_client = tuner_detach, > .command = tuner_command, > #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) > .driver = { > #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,15) > .name = "tuner", > #endif > .suspend = tuner_suspend, > .resume = tuner_resume, > }, > #endif > }; Cheers, Mauro. _______________________________________________ linux-dvb@xxxxxxxxxxx http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb