linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] i2c: update i2c-dev.h warning in documentation
@ 2017-12-09 20:10 Cengiz Can
  2017-12-11 23:20 ` Jonathan Corbet
  0 siblings, 1 reply; 7+ messages in thread
From: Cengiz Can @ 2017-12-09 20:10 UTC (permalink / raw)
  To: Wolfram Sang, Jonathan Corbet; +Cc: linux-i2c, linux-doc, linux-kernel

`dev-interface` document gives examples for accessing i2c from
userspace.

There's a note warning developers about the different `i2c-dev.h` header
files which were shipped with the kernel and i2c-tools separately.

However, these commits in i2c-tools repository suggests that the header
files are now identical (in functionality) and `i2c_*` 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>
---
Sorry for duplicate mails. My email client hard-wrapped previous patch.

Thanks.

 Documentation/i2c/dev-interface | 29 ++++++++++++++++-------------
 1 file changed, 16 insertions(+), 13 deletions(-)

diff --git a/Documentation/i2c/dev-interface b/Documentation/i2c/dev-interface
index 5ff19447ac44..04d110697863 100644
--- a/Documentation/i2c/dev-interface
+++ b/Documentation/i2c/dev-interface
@@ -9,21 +9,24 @@ i2c adapters present on your system at a given time. i2cdetect is part of
 the i2c-tools package.
 
 I2C device files are character device files with major device number 89
-and a minor device number corresponding to the number assigned as 
-explained above. They should be called "i2c-%d" (i2c-0, i2c-1, ..., 
+and a minor device number corresponding to the number assigned as
+explained above. They should be called "i2c-%d" (i2c-0, i2c-1, ...,
 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
 inspect /sys/class/i2c-dev/ or run "i2cdetect -l" to decide this.
@@ -35,7 +38,7 @@ Next thing, open the device file, as follows:
   int file;
   int adapter_nr = 2; /* probably dynamically determined */
   char filename[20];
-  
+
   snprintf(filename, 19, "/dev/i2c-%d", adapter_nr);
   file = open(filename, O_RDWR);
   if (file < 0) {
@@ -69,7 +72,7 @@ the device supports them. Both are illustrated below.
     /* res contains the read word */
   }
 
-  /* Using I2C Write, equivalent of 
+  /* Using I2C Write, equivalent of
      i2c_smbus_write_word_data(file, reg, 0x6543) */
   buf[0] = reg;
   buf[1] = 0x43;
@@ -144,7 +147,7 @@ You can do plain i2c transactions by using read(2) and write(2) calls.
 You do not need to pass the address byte; instead, set it through
 ioctl I2C_SLAVE before you try to access the device.
 
-You can do SMBus level transactions (see documentation file smbus-protocol 
+You can do SMBus level transactions (see documentation file smbus-protocol
 for details) through the following functions:
   __s32 i2c_smbus_write_quick(int file, __u8 value);
   __s32 i2c_smbus_read_byte(int file);
@@ -155,7 +158,7 @@ for details) through the following functions:
   __s32 i2c_smbus_write_word_data(int file, __u8 command, __u16 value);
   __s32 i2c_smbus_process_call(int file, __u8 command, __u16 value);
   __s32 i2c_smbus_read_block_data(int file, __u8 command, __u8 *values);
-  __s32 i2c_smbus_write_block_data(int file, __u8 command, __u8 length, 
+  __s32 i2c_smbus_write_block_data(int file, __u8 command, __u8 length,
                                    __u8 *values);
 All these transactions return -1 on failure; you can read errno to see
 what happened. The 'write' transactions return 0 on success; the
-- 
2.15.1



-- 
	Cengiz Can

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

* Re: [PATCH] i2c: update i2c-dev.h warning in documentation
  2017-12-09 20:10 [PATCH] i2c: update i2c-dev.h warning in documentation Cengiz Can
@ 2017-12-11 23:20 ` Jonathan Corbet
  2017-12-12 16:43   ` [PATCH v2] " Cengiz C.
  0 siblings, 1 reply; 7+ messages in thread
From: Jonathan Corbet @ 2017-12-11 23:20 UTC (permalink / raw)
  To: Cengiz Can; +Cc: Wolfram Sang, linux-i2c, linux-doc, linux-kernel

On Sat, 9 Dec 2017 23:10:58 +0300
Cengiz Can <cengizc@gmail.com> wrote:

> `dev-interface` document gives examples for accessing i2c from
> userspace.
> 
> There's a note warning developers about the different `i2c-dev.h` header
> files which were shipped with the kernel and i2c-tools separately.
> 
> However, these commits in i2c-tools repository suggests that the header
> files are now identical (in functionality) and `i2c_*` 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>

So this seems like a worthwhile change, but the patch contains a number of
unrelated changes, mostly white-space stuff it seems.  Can you clean that
up and resend?

Thanks,

jon

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

* [PATCH v2] i2c: update i2c-dev.h warning in documentation
  2017-12-11 23:20 ` Jonathan Corbet
@ 2017-12-12 16:43   ` Cengiz C.
  2017-12-21 19:38     ` Jonathan Corbet
  0 siblings, 1 reply; 7+ messages in thread
From: Cengiz C. @ 2017-12-12 16:43 UTC (permalink / raw)
  To: Jonathan Corbet; +Cc: Wolfram Sang, linux-i2c, linux-doc, linux-kernel

`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(-)

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
 inspect /sys/class/i2c-dev/ or run "i2cdetect -l" to decide this.
-- 
2.15.1

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

* Re: [PATCH v2] i2c: update i2c-dev.h warning in documentation
  2017-12-12 16:43   ` [PATCH v2] " Cengiz C.
@ 2017-12-21 19:38     ` Jonathan Corbet
  2017-12-21 20:49       ` Cengiz Can
  0 siblings, 1 reply; 7+ messages in thread
From: Jonathan Corbet @ 2017-12-21 19:38 UTC (permalink / raw)
  To: Cengiz C.; +Cc: Wolfram Sang, linux-i2c, linux-doc, linux-kernel

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

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

* Re: [PATCH v2] i2c: update i2c-dev.h warning in documentation
  2017-12-21 19:38     ` Jonathan Corbet
@ 2017-12-21 20:49       ` Cengiz Can
  2017-12-21 20:54         ` Jonathan Corbet
  0 siblings, 1 reply; 7+ messages in thread
From: Cengiz Can @ 2017-12-21 20:49 UTC (permalink / raw)
  To: Jonathan Corbet; +Cc: Wolfram Sang, linux-i2c, linux-doc, linux-kernel

> 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.

-- 
Cengiz Can

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

* Re: [PATCH v2] i2c: update i2c-dev.h warning in documentation
  2017-12-21 20:49       ` Cengiz Can
@ 2017-12-21 20:54         ` Jonathan Corbet
  0 siblings, 0 replies; 7+ messages in thread
From: Jonathan Corbet @ 2017-12-21 20:54 UTC (permalink / raw)
  To: Cengiz Can; +Cc: Wolfram Sang, linux-i2c, linux-doc, linux-kernel

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

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

* [PATCH] i2c: update i2c-dev.h warning in documentation
@ 2017-12-09 19:59 Cengiz Can
  0 siblings, 0 replies; 7+ messages in thread
From: Cengiz Can @ 2017-12-09 19:59 UTC (permalink / raw)
  To: Wolfram Sang, Jonathan Corbet; +Cc: linux-i2c, linux-doc, linux-kernel

`dev-interface` document gives examples for accessing i2c from
userspace.

There's a note warning developers about the different `i2c-dev.h` header
files which were shipped with the kernel and i2c-tools separately.

However, these commits in i2c-tools repository suggests that the header
files are now identical (in functionality) and `i2c_*` 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>
---
 Documentation/i2c/dev-interface | 29 ++++++++++++++++-------------
 1 file changed, 16 insertions(+), 13 deletions(-)

diff --git a/Documentation/i2c/dev-interface
b/Documentation/i2c/dev-interface index 5ff19447ac44..04d110697863
100644 --- a/Documentation/i2c/dev-interface
+++ b/Documentation/i2c/dev-interface
@@ -9,21 +9,24 @@ i2c adapters present on your system at a given time.
i2cdetect is part of the i2c-tools package.
 
 I2C device files are character device files with major device number 89
-and a minor device number corresponding to the number assigned as 
-explained above. They should be called "i2c-%d" (i2c-0, i2c-1, ..., 
+and a minor device number corresponding to the number assigned as
+explained above. They should be called "i2c-%d" (i2c-0, i2c-1, ...,
 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
 inspect /sys/class/i2c-dev/ or run "i2cdetect -l" to decide this.
@@ -35,7 +38,7 @@ Next thing, open the device file, as follows:
   int file;
   int adapter_nr = 2; /* probably dynamically determined */
   char filename[20];
-  
+
   snprintf(filename, 19, "/dev/i2c-%d", adapter_nr);
   file = open(filename, O_RDWR);
   if (file < 0) {
@@ -69,7 +72,7 @@ the device supports them. Both are illustrated below.
     /* res contains the read word */
   }
 
-  /* Using I2C Write, equivalent of 
+  /* Using I2C Write, equivalent of
      i2c_smbus_write_word_data(file, reg, 0x6543) */
   buf[0] = reg;
   buf[1] = 0x43;
@@ -144,7 +147,7 @@ You can do plain i2c transactions by using read(2)
and write(2) calls. You do not need to pass the address byte; instead,
set it through ioctl I2C_SLAVE before you try to access the device.
 
-You can do SMBus level transactions (see documentation file
smbus-protocol +You can do SMBus level transactions (see documentation
file smbus-protocol for details) through the following functions:
   __s32 i2c_smbus_write_quick(int file, __u8 value);
   __s32 i2c_smbus_read_byte(int file);
@@ -155,7 +158,7 @@ for details) through the following functions:
   __s32 i2c_smbus_write_word_data(int file, __u8 command, __u16 value);
   __s32 i2c_smbus_process_call(int file, __u8 command, __u16 value);
   __s32 i2c_smbus_read_block_data(int file, __u8 command, __u8
*values);
-  __s32 i2c_smbus_write_block_data(int file, __u8 command, __u8
length, 
+  __s32 i2c_smbus_write_block_data(int file, __u8 command, __u8 length,
                                    __u8 *values);
 All these transactions return -1 on failure; you can read errno to see
 what happened. The 'write' transactions return 0 on success; the
-- 
2.15.1

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

end of thread, other threads:[~2017-12-21 20:55 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-09 20:10 [PATCH] i2c: update i2c-dev.h warning in documentation Cengiz Can
2017-12-11 23:20 ` Jonathan Corbet
2017-12-12 16:43   ` [PATCH v2] " Cengiz C.
2017-12-21 19:38     ` Jonathan Corbet
2017-12-21 20:49       ` Cengiz Can
2017-12-21 20:54         ` Jonathan Corbet
  -- strict thread matches above, loose matches on Subject: below --
2017-12-09 19:59 [PATCH] " Cengiz Can

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).