Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 92816 - linux-headers: i2c-dev.h is incorrect for user applications
Summary: linux-headers: i2c-dev.h is incorrect for user applications
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: x86 Linux
: High normal (vote)
Assignee: Tim Yamin (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-05-16 11:05 UTC by Jordan Crouse
Modified: 2006-07-23 06:45 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Patch to modify i2c-dev.h in linux-headers to be userland friendly (i2cdev.patch,698 bytes, patch)
2005-05-16 11:08 UTC, Jordan Crouse
Details | Diff
ebuild patch (patch01.patch,396 bytes, patch)
2006-07-23 06:45 UTC, Matteo Pillon
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jordan Crouse 2005-05-16 11:05:08 UTC
The stock version of i2c-dev.h in linux-headers includes several kernel specific defines that freak out user applications.  I know that user apps normally bring in their own i2c-dev.h, but thats no reason for the core header to not compile.  This appears to still be a problem as of linux-headers-2.6.11.

Patch will be attached.

Reproducible: Always
Steps to Reproduce:
Comment 1 Jordan Crouse 2005-05-16 11:08:04 UTC
Created attachment 59033 [details, diff]
Patch to modify i2c-dev.h in linux-headers to be userland friendly

This modifies i2c-dev.h to compile cleanly in userland.  Also, it includes
<linux/i2c.h>, so that applications will only have to include <linux/i2c-dev.h>
(which avoids issues with other header packages on other distributions).
Comment 2 Daniel Drake (RETIRED) gentoo-dev 2005-05-17 03:07:38 UTC
reassigning
Comment 3 Tim Yamin (RETIRED) gentoo-dev 2005-05-17 13:36:13 UTC
Try just:

#include <linux/compiler.h>
#include <linux/i2c.h>

without the __user removals. See if that fixes the issue and let me know please.
Comment 4 Jordan Crouse 2005-05-18 08:19:12 UTC
That would work - but is it the right thing to suggest to all i2c based
applications?  My other points of reference are FC3 and linux-libc-headers, and
both enable i2c applications to work with #include <linux/i2c-dev.h> only.  I'm
not so concerned with my own apps, but rather general correctness in the distro
as a whole.  We all know we have to hack on linux headers to make them user land
friendly, and since __user has no value outside of the kernel, I think its
reasonable to kill it.
Comment 5 Tim Yamin (RETIRED) gentoo-dev 2005-05-24 07:02:28 UTC
> and both enable i2c applications to work with #include <linux/i2c-dev.h> only.

If you're including i2c-dev, to do anything useful with it you'll most certainly
need the i2c.h access functions too.

> and since __user has no value outside of the kernel, I think its reasonable to
kill it.

Right, but then you'd have to either a) automatically kill it using a sed script
(which would work) or b) Manually kill every instance. Either method deviates
away further from the upstream headers, which we'd rather nudge into working
rather than rewrite - this means things are much easier to port when newer
upstream versions come out, for example. It's a mess, and things would be much
nicer if upstream would just release working headers, but they don't want to do
that just now...

I've added the workaround in comment #3 to CVS, emerge sync in about an hour,
remerge linux-headers, and confirm. Things should work, please reopen this bug
if they don't.
Comment 6 Matteo Pillon 2006-07-23 06:42:22 UTC
The problem is still present in linux-headers-2.6.11-r5.
In the kernel source tree, under Documentation/i2c/dev-interface, you can read the following:
  So let's say you want to access an i2c adapter from a C program. The
  first thing to do is "#include <linux/i2c-dev.h>". Please note that
  there are two files named "i2c-dev.h" out there, one is distributed
  with the Linux kernel and is meant to be included from kernel
  driver code, the other one is distributed with lm_sensors and is
  meant to be included from user-space programs. You obviously want
  the second one here.
So I tried substituting the i2c-dev.h installed by linux-headers with the one provided by lm_sensors and all works flawless (I tried compiling the hd44780 driver for the i2c interface of lcdproc 0.5).

I attached a modified ebuild, just put i2c-dev.h from lm_sensors package in FILESDIR.

This works for me, don't know if it has drawbacks.

emerge --info output

Portage 2.1.1_pre2-r8 (default-linux/x86/2006.0, gcc-4.1.1/vanilla, glibc-2.4-r3, 2.6.17-gentoo-r2 i686)
=================================================================
                       System Settings
=================================================================
System uname: 2.6.17-gentoo-r2 i686 AMD Athlon(tm) XP 2200+
Gentoo Base System version 1.12.1
app-admin/eselect-compiler: 2.0.0_rc2-r1
dev-lang/python:     2.4.3-r1
dev-python/pycrypto: 2.0.1-r5
dev-util/ccache:     [Not Present]
dev-util/confcache:  [Not Present]
sys-apps/sandbox:    1.2.18.1
sys-devel/autoconf:  2.13, 2.60
sys-devel/automake:  1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.6-r2
sys-devel/binutils:  2.17
sys-devel/gcc-config: [Not Present]
sys-devel/libtool:   1.5.22
virtual/os-headers:  2.6.11-r5
ACCEPT_KEYWORDS="x86 ~x86"
AUTOCLEAN="yes"
CBUILD="i686-pc-linux-gnu"
CFLAGS="-O2 -march=athlon-xp -mtune=athlon-xp -pipe"
CHOST="i686-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/X11/xkb"
CONFIG_PROTECT_MASK="/etc/env.d /etc/eselect/compiler /etc/gconf /etc/revdep-rebuild /etc/splash /etc/terminfo"
CXXFLAGS="-O2 -march=athlon-xp -mtune=athlon-xp -pipe"
DISTDIR="/usr/portage/distfiles"
FEATURES="autoconfig distlocks metadata-transfer parallel-fetch sandbox sfperms strict"
GENTOO_MIRRORS="http://distfiles.gentoo.org http://distro.ibiblio.org/pub/linux/distributions/gentoo"
LC_ALL="it_IT.utf8"
LINGUAS="it"
PKGDIR="/usr/portage/packages"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --delete-after --stats --timeout=180 --exclude='/distfiles' --exclude='/local' --exclude='/packages'"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/portage/local/layman/fluidportage"
SYNC="rsync://neptune.octopus/gentoo-portage"
USE="x86 3dnow X alsa apm avi berkdb bitmap-fonts bzip2 cli crypt cups dbus dlloader dri emacs emboss encode expat firefox foomaticdb fortran gdbm gif gimp glitz gnome gpm gstreamer gtk gtk2 gtkhml hald imlib ipv6 isdnlog jpeg libg++ libwww mad mikmod mmx motif mp3 mpeg ncurses nls nptl nptlonly ogg opengl pam pcre pdf pdflib perl png ppds pppd preview-latex python quicktime readline reflection sdl session spell spl sse ssl svg tcpd timidity truetype truetype-fonts type1-fonts udev unicode usb vorbis xinerama xml xmms xorg xv zlib elibc_glibc input_devices_evdev input_devices_mouse input_devices_keyboard kernel_linux linguas_it userland_GNU video_cards_radeon"
Unset:  CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LANG, LDFLAGS, MAKEOPTS, PORTAGE_RSYNC_EXTRA_OPTS

Comment 7 Matteo Pillon 2006-07-23 06:45:56 UTC
Created attachment 92552 [details, diff]
ebuild patch