Installation Guide for i2c and lm_sensors 2.9.2 and 2.10.2

It is probably worth reminding that this page is not meant for Linux 2.6 users, since an up-to-date version of the i2c subsystem is already included in 2.6 kernels.

What was new in i2c 2.9.0?

Versions of i2c from 2.8.0 to 2.8.8 were not compatible with the version of i2c present in the Linux 2.4 kernels. As a result I, Jean Delvare, member of the lm_sensors project team, had to set up and maintain patches that would allow users to live with the incompatibility until a definitive solution was found. One solution would have been to merge all our changes into Linux 2.4. However, Marcelo Tosatti did not want this to happen as he thought the changes were too big and could introduce problems.

Although I got a little angry at first, with a better understanding of the situation I now think that he was perfectly right. The changes that were done in i2c 2.8.0 and which broke the compatibility were not correct, and should not have been made in the first place (or, more precisely, they did belong to the 2.5 branch of the Linux tree, not the 2.4 one).

So the correct solution to the incompatibility was to revert some of the changes that were introduced in i2c 2.8.0, so that i2c 2.9.0 would be fully compatible with Linux 2.4.

This page will provide information and patches to anyone interested in using i2c 2.9.2 or 2.10.2 and presumably lm_sensors 2.9.2 or 2.10.2, with a particular focus on the differences with the i2c 2.8.x series.

Practical comparison of i2c 2.8.x and i2c 2.9.0 and later

When installing i2c, you have two options. Either you patch your kernel tree with the new i2c subsystem, or you build it outside of the kernel tree. Both ways have their supporters and benefits. Patching the kernel tree may be easier for Linux distributions, it also allows for non-modular kernel builds. Building apart from the kernel tree is usually easier for end-users.

With i2c 2.8.x, building i2c outside of the kernel was not possible anymore as soon as you needed non-lm_sensors i2c drivers (the most famous one being bttv). In this case you had to patch your kernel, not only with the new i2c subsystem but also we a load of compatibility patches for almost all i2c drivers in the kernel tree, so that they would comply with the changes made in i2c 2.8.0.

Since i2c 2.9.0, the compatibility is back, which means that both options are usable again. Compiling outside of the kernel is straightforward and doesn't need any additional patch. The rest of this page covers the second option, when you want to patch your kernel. This option requires one small compatibility patch as detailed below.


Here are the patches needed to update the 2.4 kernel's i2c subsystem to 2.9.2 or 2.10.2. For each kernel version, the main patch can be generated using i2c's mkpatch script (and actually you have to use this script if you want to generate a patch for a kernel that is not supported here).

The only additional patch provided here affects the bttv and tvmixer media/video drivers. Ironically, these drivers were updated to workaround the i2c 2.8.x incompatibility issue, but in a tricky way that now gets fooled by i2c 2.9.0 and later.

To go technical, both drivers check if the i2c subsystem supports a particular functionality, I2C_PEC ioctl, and switch to a Linux 2.6/i2c 2.8.x compatible mode if it does. This functionality is not related with the new i2c subsystem model, but happens to have been introduced in i2c 2.6.4 (and Linux 2.5.32), while the 2.4 kernels have i2c 2.6.1, so it sounded like a convenient way to differenciate between an i2c 2.8.x-patched 2.4 kernel and an unpatched one. However, i2c 2.9.0 is compatible with the old model again (linux 2.4, i2c 2.7.0 and earlier) but does of course still supports I2C_PEC ioctl. Thus checking for I2C_PEC ioctl support no longer works. This is what happens when you check one thing in the hope it'll give you information about something else that isn't directly related.

The issue affects kernels from 2.4.23 to 2.4.28.

My only regret is that this whole mess wasn't fixed earlier. Unfortunately, I didn't know what exactly should be done back then.

Patches for i2c 2.10.2

Patch set for the 2.4.34 kernel:

Patch set for the 2.4.33 kernel:

Patch set for the 2.4.32 kernel:

Patch set for the 2.4.31 kernel:

Patch set for the 2.4.30 kernel:

Patch set for the 2.4.29 kernel:

Patch set for the 2.4.28 kernel:

Patch set for the 2.4.27 kernel:

Patches for i2c 2.9.2

Patch set for the 2.4.32 kernel:

Patch set for the 2.4.31 kernel:

Patch set for the 2.4.30 kernel:

Patch set for the 2.4.29 kernel:

Patch set for the 2.4.28 kernel:

Patch set for the 2.4.27 kernel:

lm_sensors 2.9.2 and 2.10.2

There is not much to add about lm_sensors. It can be either compiled outside of the kernel, or patched into the kernel using mkpatch, as usual. lm_sensors 2.9.2 requires i2c 2.9.x. lm_sensors 2.10.2 doesn't need i2c 2.10.x (any version from 2.9.0 will work), but it is still recommended to upgrade i2c to 2.10.2 as it contains a few interesting fixes. Note that lm_sensors 2.9.x will not work with i2c 2.10.x though.

Please note that, when compiling lm_sensors outside of the kernel with i2c patched into the kernel, you'll have to edit the value of I2C_HEADERS in the Makefile file, so that it points to your new, patched kernel headers, and not your local headers (which is the default). I usually forget to do it myself, so I thought I should remind you do to so.

Third party drivers

You may still have problems with some drivers that are neither part of lm_sensors, nor part of the Linux kernel. Some of them were hacked to support the i2c 2.8.x series, possibly in the same incorrect way as the bttv and tvmixer drivers were, so they will have trouble with i2c 2.9.0 and later.

The authors of such drivers are invited to revert their code change to drop support of the i2c 2.8.x series, which is considered deprecated, and properly support i2c 2.9.0 and later instead.

Useful links