Message ID | CANp8-fy-mOUpMgR6F3j6k53gpAHh+TxiKdSaXFfqimcAwe_y3g@mail.gmail.com |
---|---|
State | Awaiting Upstream |
Headers | show |
Series | [v2] i2c: update i2c-dev.h warning in documentation | expand |
On Tue, 12 Dec 2017 19:43:09 +0300 "Cengiz C." <cengizc@gmail.com> wrote: > `Documentation/i2c/dev-interface` gives examples for accessing i2c from > userspace. > > There's a note that warns developers about the two `i2c-dev.h` header > files which were shipped with the kernel and i2c-tools separately. > > However, following i2c-tools commits suggest that the header files are now > identical (in functionality) and `i2c_*` helper functions are now defined > in a separate header called `i2c/smbus.h`, which is distributed with > i2c-tools: > > commit 652619121974 ("Minimize differences with kernel flavor") > commit 93caf007f4cb ("Move SMBus helper functions to include/i2c/smbus.h") > > Thus, I've converted the warning paragraph into a historical note and > updated the suggested header files. > > Signed-off-by: Cengiz Can <cengizc@gmail.com> Applied to the docs tree, thanks. Note that the patch was wrapped by your mailer and I had to fix it up; that would be nice to avoid in the future. Thanks, jon
> Applied to the docs tree, thanks. Note that the patch was wrapped by your > mailer and I had to fix it up; that would be nice to avoid in the future. Thank you! I've ditched claws-mail and will use git send-mail instead.
On Thu, 21 Dec 2017 23:49:16 +0300
Cengiz Can <cengizc@gmail.com> wrote:
> I've ditched claws-mail and will use git send-mail instead.
FWIW, I use claws for patch mailing and more. It can be made to work, you
just need to tweak the options a bit. The trick is to send patches to
yourself and keep at it until what you receive still applies.
jon
diff --git a/Documentation/i2c/dev-interface b/Documentation/i2c/dev-interface index 5ff19447ac44..d04e6e4964ee 100644 --- a/Documentation/i2c/dev-interface +++ b/Documentation/i2c/dev-interface @@ -17,13 +17,16 @@ i2c-10, ...). All 256 minor device numbers are reserved for i2c. 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-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 i2c-tools and is -meant to be included from user-space programs. You obviously want -the second one here. +So let's say you want to access an i2c adapter from a C program. +First, you need to include these two headers: + + #include <linux/i2c-dev.h> + #include <i2c/smbus.h> + +(Please note that there are two files named "i2c-dev.h" out there. One is +distributed with the Linux kernel and the other one is included in the +source tree of i2c-tools. They used to be different in content but since 2012 +they're identical. You should use "linux/i2c-dev.h"). Now, you have to decide which adapter you want to access. You should
`Documentation/i2c/dev-interface` gives examples for accessing i2c from userspace. There's a note that warns developers about the two `i2c-dev.h` header files which were shipped with the kernel and i2c-tools separately. However, following i2c-tools commits suggest that the header files are now identical (in functionality) and `i2c_*` helper functions are now defined in a separate header called `i2c/smbus.h`, which is distributed with i2c-tools: commit 652619121974 ("Minimize differences with kernel flavor") commit 93caf007f4cb ("Move SMBus helper functions to include/i2c/smbus.h") Thus, I've converted the warning paragraph into a historical note and updated the suggested header files. Signed-off-by: Cengiz Can <cengizc@gmail.com> --- Hello Jonathan, Thank you for the quick feedback. I've removed unnecessary modifications and fixed some grammar in the commit message. Documentation/i2c/dev-interface | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) inspect /sys/class/i2c-dev/ or run "i2cdetect -l" to decide this.