[RFC] kernel compat code, how far to go back?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In kernel 2.6.0, struct i2c_driver got two new fields, 'owner' and 'driver'.
The owner field later went away in 2.6.16.

Some code checks for kernel >= 2.6.0 before it sets stuff in the .driver
field.

Other code has some i2c_driver compat checks, but it doesn't try to handle
kernels < 2.6.0.

tuner_core.c doesn't get the check correct, and looks for kernel >= 2.5.0 when
it should be >= 2.6.0.  I suppose this means there aren't many users for 2.5
kernels...

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.

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.

_______________________________________________

linux-dvb@xxxxxxxxxxx
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

[Index of Archives]     [Linux Media]     [Video 4 Linux]     [Asterisk]     [Samba]     [Xorg]     [Xfree86]     [Linux USB]

  Powered by Linux