[i2c] Userspace Headers for recent kernels
don
don_reid at comcast.net
Tue Sep 19 23:20:34 CEST 2006
On Tue, Sep 19, 2006 at 10:14:06PM +0200, Jean Delvare wrote:
> Hi Don,
>
> > I am trying to find or create some header files (i2c-dev.h and i2c.h
> > if needed). That will work for user-space programs with recent kernels
> > like 2.6.17.13.
> >
> > I have read the various messages in this lists archives and elsewhere
> > which say:
> >
> > - The kernel headers are not for users (no kidding they produce
> > copious errors).
> >
> > - The Lm-sensors headers should be used.
> >
> > However all the versions of lm-sensors I have found, including the current
> > SVN, don't seem to match the kernel code. For example the function
> > i2c_smbus_write_byte() in the kernel wants a struct i2c_client while the
> > lm-sensors file declares it with an int (a file number).
> >
> > Am I missing something? If not does anyone have such headers?
>
> The file you need is indeed kernel/include/i2c-dev.h from the
> lm_sensors package. It is installed
> as /usr/local/include/linux/i2c-dev.h by "make user_install. This file
> will work for both 2.4 and 2.6 kernels.
>
> Some of the inline functions declared in this file have the same name
> as some functions in the kernel, because they are similar in spirit.
> However, the kernel structure are not available from user-space.
> User-space uses ioctls to control the kernel (bus) drivers, and the
> inline functions in i2c-dev.h are wrappers for these ioctls. If you are
> confused by the different function signatures, just consider that the
> similar names are unfortunate. These are really different functions.
>
> For a simple example of user-space tool using i2c-dev, please see
> prog/dump/i2cset.c in the lm_sensors package.
Thanks for the reply. Yes I already have been looking at that code.
It doesn't work for me and I am trying to figure out why.
Can you point me at the code that implements the version of
i2c_smbus_write_byte() that is used by this program? The only one I can
find is in the kernel? I probably need to include some function or library
with my small app.
Thanks
Don
More information about the i2c
mailing list