All of lore.kernel.org
 help / color / mirror / Atom feed
* userspace  dev-interface linux-2.6.7
@ 2005-05-19  6:25 Nils Roeder
  2005-05-19  6:25 ` Nils Roeder
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: Nils Roeder @ 2005-05-19  6:25 UTC (permalink / raw)
  To: lm-sensors

hi

i use a userspace program to access /dev/i2c-0 which
uses (/doc/dev-interface)
#include <linux/i2c.h>
#include <linux/i2c-dev.h>
which works fine in linux-2.4.x

'porting' this to linux-2.6.7 causes too many errors.
can anyone point me to the right direction so solve these ?
(i realised in 2.6.7 the smbus macros are missing in i2c-dev.h
so i am basically a bit lost...)


a more interesting question (for me at least) is -
do i actually need to do that.
just today (i must admit) i tried lmsensors for the first time, 
crosscompiled 'i2cdetect' and realised it can find all my devices 
attached to /dev/i2c-0.
so, can i read and write to the devices found by i2cdetect
(e.g 0x4b on /dev/i2c-0)
using kernel drivers rather than my userspace program,
if so how (or where can i read about it) ?

cheers,
   nils

^ permalink raw reply	[flat|nested] 10+ messages in thread

* userspace  dev-interface linux-2.6.7
  2005-05-19  6:25 userspace dev-interface linux-2.6.7 Nils Roeder
  2005-05-19  6:25 ` Nils Roeder
  2005-05-19  6:25 ` Jean Delvare
@ 2005-05-19  6:25 ` Rudolf Marek
  2005-05-19  6:25 ` Jean Delvare
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Rudolf Marek @ 2005-05-19  6:25 UTC (permalink / raw)
  To: lm-sensors

Nils Roeder wrote:
> hi
> 
> i use a userspace program to access /dev/i2c-0 which
> uses (/doc/dev-interface)
> #include <linux/i2c.h>
> #include <linux/i2c-dev.h>
> which works fine in linux-2.4.x
> 
> 'porting' this to linux-2.6.7 causes too many errors.
> can anyone point me to the right direction so solve these ?
> (i realised in 2.6.7 the smbus macros are missing in i2c-dev.h
> so i am basically a bit lost...)

Yes plz read further.

> a more interesting question (for me at least) is -
> do i actually need to do that.
> just today (i must admit) i tried lmsensors for the first time,
> crosscompiled 'i2cdetect' and realised it can find all my devices
> attached to /dev/i2c-0.
> so, can i read and write to the devices found by i2cdetect
> (e.g 0x4b on /dev/i2c-0)
> using kernel drivers rather than my userspace program,
> if so how (or where can i read about it) 

Have you read linux-2.6.XXXX/Documentation/i2c ?

There is file called dev-interface, that should help you.
If you have any more questions, just write again.

Regards

Rudolf

^ permalink raw reply	[flat|nested] 10+ messages in thread

* userspace  dev-interface linux-2.6.7
  2005-05-19  6:25 userspace dev-interface linux-2.6.7 Nils Roeder
                   ` (4 preceding siblings ...)
  2005-05-19  6:25 ` Nils Roeder
@ 2005-05-19  6:25 ` Nils Roeder
  2005-05-19  6:25 ` Jean Delvare
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Nils Roeder @ 2005-05-19  6:25 UTC (permalink / raw)
  To: lm-sensors

Rudolf Marek wrote:
[snip]
> Have you read linux-2.6.XXXX/Documentation/i2c ?
> 
> There is file called dev-interface, that should help you.
> If you have any more questions, just write again.
> 

thanks for replying.
Linux-2.6.XXXX/Documentation/i2c is what i read.
the problem is that #include <linux/i2c-dev.h> causes
compiler errors because of the missing I2C_SMBUS_... macros in 2.6.x
(if you want i include the error output, my example program or
  the linux/i2c-dev.h file i am using)
although all this is fixable, i am surprised that i couldn't find
any howto/tutorial/advice on that - or am i the only one having this
problem ?

thanks,
   nils

^ permalink raw reply	[flat|nested] 10+ messages in thread

* userspace  dev-interface linux-2.6.7
  2005-05-19  6:25 userspace dev-interface linux-2.6.7 Nils Roeder
                   ` (2 preceding siblings ...)
  2005-05-19  6:25 ` Rudolf Marek
@ 2005-05-19  6:25 ` Jean Delvare
  2005-05-19  6:25 ` Nils Roeder
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Jean Delvare @ 2005-05-19  6:25 UTC (permalink / raw)
  To: lm-sensors


Hi Nils,

> Linux-2.6.XXXX/Documentation/i2c is what i read.
> the problem is that #include <linux/i2c-dev.h> causes
> compiler errors because of the missing I2C_SMBUS_... macros in 2.6.x
> (if you want i include the error output, my example program or
>  the linux/i2c-dev.h file i am using)
> although all this is fixable, i am surprised that i couldn't find
> any howto/tutorial/advice on that - or am i the only one having this
> problem ?

There are two i2c-dev.h files, one for kernel-space and one for
user-space. If you are writing a user-space tool which will access
/dev/i2c-*, you need the user-space version of i2c-dev.h, which is
distributed with lm_sensors for historical reasons, although I believe
the kernel-headers package has a copy as well. This version will work
regardless of the version of the kernel you are using.

Hope that helps,
--
Jean Delvare

^ permalink raw reply	[flat|nested] 10+ messages in thread

* userspace  dev-interface linux-2.6.7
  2005-05-19  6:25 userspace dev-interface linux-2.6.7 Nils Roeder
                   ` (3 preceding siblings ...)
  2005-05-19  6:25 ` Jean Delvare
@ 2005-05-19  6:25 ` Nils Roeder
  2005-05-19  6:25 ` Nils Roeder
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Nils Roeder @ 2005-05-19  6:25 UTC (permalink / raw)
  To: lm-sensors

Jean Delvare wrote:
[snip]

 >
 > There are two i2c-dev.h files, one for kernel-space and one for
 > user-space. If you are writing a user-space tool which will access
 > /dev/i2c-*, you need the user-space version of i2c-dev.h, which is
 > distributed with lm_sensors for historical reasons, although I believe
 > the kernel-headers package has a copy as well. This version will work
 > regardless of the version of the kernel you are using.
 >
 > Hope that helps,
 > --
 > Jean Delvare
 >
that helps indeed, thanks very much.
why is this not mentioned in
linux-2.6.x/Documentation/i2c/dev-interface ?

while it is mentioned in
http://www2.lm-sensors.nu/~lm78/cvs/lm_sensors2/doc/developers/applications

thanks again,
   nils

^ permalink raw reply	[flat|nested] 10+ messages in thread

* userspace  dev-interface linux-2.6.7
  2005-05-19  6:25 userspace dev-interface linux-2.6.7 Nils Roeder
  2005-05-19  6:25 ` Nils Roeder
@ 2005-05-19  6:25 ` Jean Delvare
  2005-05-19  6:25 ` Rudolf Marek
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Jean Delvare @ 2005-05-19  6:25 UTC (permalink / raw)
  To: lm-sensors

> that helps indeed, thanks very much.
> why is this not mentioned in
> linux-2.6.x/Documentation/i2c/dev-interface ?
> 
> while it is mentioned in
> http://www2.lm-sensors.nu/~lm78/cvs/lm_sensors2/doc/developers/applications

No idea, most probably because nobody updated the dev-interface document
since the i2c-dev header file was split. If you submit a patch updating
it, I'll review it and have it applied.

Thanks,
-- 
Jean Delvare

^ permalink raw reply	[flat|nested] 10+ messages in thread

* userspace  dev-interface linux-2.6.7
  2005-05-19  6:25 userspace dev-interface linux-2.6.7 Nils Roeder
@ 2005-05-19  6:25 ` Nils Roeder
  2005-05-19  6:25 ` Jean Delvare
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Nils Roeder @ 2005-05-19  6:25 UTC (permalink / raw)
  To: lm-sensors

Jean Delvare wrote:
[snip]
> No idea, most probably because nobody updated the dev-interface document
> since the i2c-dev header file was split. If you submit a patch updating
> it, I'll review it and have it applied.

i am happy to submit an update patch for the dev-interface document, but 
at the moment i still have too many errors - i assume not many people 
use /dev from user-space in 2.6.x anymore ?

so far :

(i) use lm_sensors i2c-dev.h instead of kernel header file
#include <linux/i2c.h>
#include "i2c-dev.h" /* lm_sensors header file */

causes compile errors due to <linux/i2c.h>

(ii)
putting some #ifdef __KERNEL__ back into <linux/i2c.h> helps.
two errors remain:

i2c-dev.h:39: error: redefinition of `struct i2c_msg'
i2c-dev.h:123: error: redefinition of `union i2c_smbus_data'

(iii)
commenting out the above definitions in "i2c-dev.h"
helps compiling, but i am not sure it should be done...

any suggestions anyone ?

regards

   nils roeder

^ permalink raw reply	[flat|nested] 10+ messages in thread

* userspace  dev-interface linux-2.6.7
  2005-05-19  6:25 userspace dev-interface linux-2.6.7 Nils Roeder
                   ` (5 preceding siblings ...)
  2005-05-19  6:25 ` Nils Roeder
@ 2005-05-19  6:25 ` Jean Delvare
  2005-05-19  6:25 ` Nils Roeder
  2005-06-25 11:25 ` [lm-sensors] " Jean Delvare
  8 siblings, 0 replies; 10+ messages in thread
From: Jean Delvare @ 2005-05-19  6:25 UTC (permalink / raw)
  To: lm-sensors

Hi Nils,

> i am happy to submit an update patch for the dev-interface document,
> but  at the moment i still have too many errors - i assume not many
> people  use /dev from user-space in 2.6.x anymore ?

Well, i2cdetect, i2cdump and i2cset can be compiled when running a 2.6
kernel - so lots of people actually do.

> (i) use lm_sensors i2c-dev.h instead of kernel header file
> #include <linux/i2c.h>
> #include "i2c-dev.h" /* lm_sensors header file */
> 
> causes compile errors due to <linux/i2c.h>

Do not include linux/i2c.h in a user-space program. This is a
kernel-space header file. If should work just fine without it, the only
header file you really need is i2c-dev.h.

-- 
Jean Delvare

^ permalink raw reply	[flat|nested] 10+ messages in thread

* userspace  dev-interface linux-2.6.7
  2005-05-19  6:25 userspace dev-interface linux-2.6.7 Nils Roeder
                   ` (6 preceding siblings ...)
  2005-05-19  6:25 ` Jean Delvare
@ 2005-05-19  6:25 ` Nils Roeder
  2005-06-25 11:25 ` [lm-sensors] " Jean Delvare
  8 siblings, 0 replies; 10+ messages in thread
From: Nils Roeder @ 2005-05-19  6:25 UTC (permalink / raw)
  To: lm-sensors

hi,

here is an updated version of Documentation/i2c/dev_interface
which just adds that there are two versions of i2c-dev.h
and that the userspace version is distributed with lm_sensors.

   nils
-------------- next part --------------
--- Documentation/i2c/dev-interface.orig	2005-05-09 11:47:22.000000000 +0100
+++ Documentation/i2c/dev-interface	2005-05-09 11:50:18.000000000 +0100
@@ -16,7 +16,9 @@ C example
 So let's say you want to access an i2c adapter from a C program. The
 first thing to do is `#include <linux/i2c.h>" and "#include <linux/i2c-dev.h>. 
 Yes, I know, you should never include kernel header files, but until glibc 
-knows about i2c, there is not much choice.
+knows about i2c, there is not much choice. For this purpose there are two 
+i2c-dev.h files, one for kernel-space and one for user-space. The user-space 
+version of i2c-dev.h is distributed with lm_sensors for historical reasons.
 
 Now, you have to decide which adapter you want to access. You should
 inspect /sys/class/i2c-dev/ to decide this. Adapter numbers are assigned

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [lm-sensors] Re: userspace  dev-interface linux-2.6.7
  2005-05-19  6:25 userspace dev-interface linux-2.6.7 Nils Roeder
                   ` (7 preceding siblings ...)
  2005-05-19  6:25 ` Nils Roeder
@ 2005-06-25 11:25 ` Jean Delvare
  8 siblings, 0 replies; 10+ messages in thread
From: Jean Delvare @ 2005-06-25 11:25 UTC (permalink / raw)
  To: lm-sensors

Hi Nils,

Sorry for the late answer.

> here is an updated version of Documentation/i2c/dev_interface
> which just adds that there are two versions of i2c-dev.h
> and that the userspace version is distributed with lm_sensors.

It wasn't totally exact, so I reworded it and commited the change to
i2c-CVS. Thanks for the suggestion. A similar change is on its way to
Linux 2.6.

Thanks,
-- 
Jean Delvare

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2005-06-25 11:25 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-05-19  6:25 userspace dev-interface linux-2.6.7 Nils Roeder
2005-05-19  6:25 ` Nils Roeder
2005-05-19  6:25 ` Jean Delvare
2005-05-19  6:25 ` Rudolf Marek
2005-05-19  6:25 ` Jean Delvare
2005-05-19  6:25 ` Nils Roeder
2005-05-19  6:25 ` Nils Roeder
2005-05-19  6:25 ` Jean Delvare
2005-05-19  6:25 ` Nils Roeder
2005-06-25 11:25 ` [lm-sensors] " Jean Delvare

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.