Skip to contentSkip to conversation

i2c: Add i2c-pseudo driver for userspace I2C adapters.

PATCH Superseded Matthew Blecker 2 participants 5 messages May 7, 2020 – May 9, 2020

Subsystems (2)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

cover i2c: Add i2c-pseudo driver for userspace I2C adapters.

From: Matthew Blecker <[email protected]>

This patch adds i2c-pseudo, a module that provides I2C adapters backed by userspace programs. This allows for userspace implementations of functionality such as tunneling I2C through another communication channel, or mocking of real I2C devices whose behavior cannot be modeled with i2c-stub.

Module naming: A pseudo I2C adapter is analogous to a pseudo terminal.

In the Chromium OS ecosystem we are using this for a userspace I2C adapter built on top of an existing userspace I2C-over-USB implementation used with embedded debug devices that act as I2C master to a device under test (DUT). This arrangement is used for interacting with I2C slaves on the DUT, particularly for transferring firmware to an embedded controller IC which receives programming via I2C.

That I2C pseudo controller implementation is here:
https://chromium.googlesource.com/chromiumos/third_party/hdctools/+/refs/heads/master/servo/interface/i2c_pseudo.py

Matthew Blecker (1):
i2c: Add new i2c-pseudo driver for userspace I2C adapters.

 .../i2c/pseudo-controller-interface.rst       |  305 ++
 drivers/i2c/Kconfig                           |   17 +-
 drivers/i2c/Makefile                          |    1 +
 drivers/i2c/i2c-pseudo.c                      | 3198 +++++++++++++++++
 4 files changed, 3520 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/i2c/pseudo-controller-interface.rst
 create mode 100644 drivers/i2c/i2c-pseudo.c
Signature · 1 line
2.26.2.526.g744177e7f7-goog
#1 lore raw

PATCH 1/1 i2c: Add i2c-pseudo driver for userspace I2C adapters.

From: Matthew Blecker <[email protected]>

i2c: Add i2c-pseudo driver for userspace I2C adapters.

The i2c-pseudo module provides I2C adapters backed by userspace programs. This allows for userspace implementations of functionality such as tunneling I2C through another communication channel, or mocking of real I2C devices whose behavior cannot be modeled with i2c-stub.

---
 .../i2c/pseudo-controller-interface.rst       |  305 ++
 drivers/i2c/Kconfig                           |   17 +-
 drivers/i2c/Makefile                          |    1 +
 drivers/i2c/i2c-pseudo.c                      | 3198 +++++++++++++++++
 4 files changed, 3520 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/i2c/pseudo-controller-interface.rst
 create mode 100644 drivers/i2c/i2c-pseudo.c
Documentation/i2c/pseudo-controller-interface.rst new file +305 -0
new file mode 100644
index 000000000000..444f6cb2710c
@@ -0,0 +1,305 @@
+=================
+i2c-pseudo driver
+=================
+
+Usually I2C adapters are implemented in a kernel driver.  It is also possible to
+implement an adapter in userspace, through the /dev/i2c-pseudo-controller
+interface.  Load module i2c-pseudo for this.
+
+Use cases for this module include:
+
+- Using local I2C device drivers, particularly i2c-dev, with I2C busses on
+  remote systems.  For example, interacting with a Device Under Test (DUT)
+  connected to a Linux host through a debug interface, or interacting with a
+  remote host over a network.
+
+- Implementing I2C device driver tests that are impractical with the i2c-stub
+  module.  For example, when simulating an I2C device where its driver might
+  issue a sequence of reads and writes without interruption, and the value at a
+  certain address must change during the sequence.
+
+This is not intended to replace kernel drivers for actual I2C busses on the
+local host machine.
+
+
+Details
+=======
+
+Each time /dev/i2c-pseudo-controller is opened, and the correct initialization
+command is written to it (ADAPTER_START), a new I2C adapter is created.  The
+adapter will live until its file descriptor is closed.  Multiple pseudo adapters
+can co-exist simultaneously, controlled by the same or different userspace
+processes.  When an I2C device driver sends an I2C message to a pseudo adapter,
+the message becomes readable from its file descriptor.  If a reply is written
+before the adapter timeout expires, that reply will be sent back to the I2C
+device driver.
+
+Reads and writes are buffered inside i2c-pseudo such that userspace controllers
+may split them up into arbitrarily small chunks.  Multiple commands, or portions
+of multiple commands, may be read or written together.
+
+Blocking I/O is the default.  Non-blocking I/O is supported as well, enabled by
+O_NONBLOCK.  Polling is supported, with or without non-blocking I/O.  A special
+command (ADAPTER_SHUTDOWN) is available to unblock any pollers or blocked
+reads or writes, as a convenience for a multi-threaded or multi-process program
+that wants to exit.
+
+It is safe to access a single controller fd from multiple threads or processes
+concurrently, though it is up to the controller to ensure proper ordering, and
+to ensure that writes for different commands do not get interleaved.  However,
+it is recommended (not required) that controller implementations have only one
+reader thread and one writer thread, which may or may not be the same thread.
+Avoiding multiple readers and multiple writers greatly simplifies controller
+implementation, and there is likely no performance benefit to be gained from
+concurrent reads or concurrent writes due to how i2c-pseudo serializes them
+internally.  After all, on a real I2C bus only one I2C message can be active at
+a time.
+
+Commands are newline-terminated, both those read from the controller device, and
+those written to it.
+
+
+Read Commands
+=============
+
+The commands that may be read from a pseudo controller device are:
+
+----
+
+:Read Command: ``I2C_ADAPTER_NUM <num>``
+:Example: ``"I2C_ADAPTER_NUM 5\n"``
+:Details:
+  | This is read in response to the GET_ADAPTER_NUM command being written.
+    The number is the I2C adapter number in decimal.  This can only occur after
+    ADAPTER_START, because before that the number is not known and cannot be
+    predicted reliably.
+
+----
+
+:Read Command: ``I2C_PSEUDO_ID <num>``
+:Example: ``"I2C_PSEUDO_ID 98\n"``
+:Details:
+  | This is read in response to the GET_PSEUDO_ID command being written.
+    The number is the pseudo ID in decimal.
+
+----
+
+:Read Command: ``I2C_BEGIN_XFER``
+:Example: ``"I2C_BEGIN_XFER\n"``
+:Details:
+  | This indicates the start of an I2C transaction request, in other words
+    the start of the I2C messages from a single invocation of the I2C adapter's
+    master_xfer() callback.  This can only occur after ADAPTER_START.
+
+----
+
+:Read Command: ``I2C_XFER_REQ <xfer_id> <msg_id> <addr> <flags> <data_len> [<write_byte>[:...]]``
+:Example: ``"I2C_XFER_REQ 3 0 0x0070 0x0000 2 AB:9F\n"``
+:Example: ``"I2C_XFER_REQ 3 1 0x0070 0x0001 4\n"``
+:Details:
+  | This is a single I2C message that a device driver requested be sent on
+    the bus, in other words a single struct i2c_msg from master_xfer() msgs arg.
+  |
+  | The xfer_id is a number representing the whole I2C transaction, thus all
+    I2C_XFER_REQ between a I2C_BEGIN_XFER + I2C_COMMIT_XFER pair share an
+    xfer_id.  The purpose is to ensure replies from the userspace controller are
+    always properly matched to the intended master_xfer() request.  The first
+    transaction has xfer_id 0, and it increases by 1 with each transaction,
+    however it will eventually wrap back to 0 if enough transactions happen
+    during the lifetime of a pseudo adapter.  It is guaranteed to have a large
+    enough maximum value such that there can never be multiple outstanding
+    transactions with the same ID, due to an internal limit in i2c-pseudo that
+    will block master_xfer() calls when the controller is falling behind in its
+    replies.
+  |
+  | The msg_id is a decimal number representing the index of the I2C message
+    within its transaction, in other words the index in master_xfer() \*msgs
+    array arg.  This starts at 0 after each I2C_BEGIN_XFER.  This is guaranteed
+    to not wrap.
+  |
+  | The addr is the hexadecimal I2C address for this I2C message.
+  |
+  | The flags are the same bitmask flags used in struct i2c_msg, in hexadecimal
+    form.  Of particular importance to any pseudo controller is the read bit,
+    which is guaranteed to be 0x1 per Linux I2C documentation.
+  |
+  | The data_len is the decimal number of either how many bytes to write that
+    will follow, or how many bytes to read and reply with if this is a read
+    request.
+  |
+  | If this is a read, data_len will be the final field in this command.  If
+    this is a write, data_len will be followed by the given number of
+    colon-separated hexadecimal byte values, in the format shown in the example
+    above.
+
+----
+
+:Read Command: ``I2C_COMMIT_XFER``
+:Example: ``"I2C_COMMIT_XFER\n"``
+:Details:
+  | This indicates the end of an I2C transacton request, in other words the
+    end of the I2C messages from a single invocation of the I2C adapter's
+    master_xfer() callback.  This should be read exactly once after each
+    I2C_BEGIN_XFER, with a varying number of I2C_XFER_REQ between them.
+
+
+Write Commands
+==============
+
+The commands that may be written to a pseudo controller device are:
+
+
+:Write Command: ``SET_ADAPTER_NAME_SUFFIX <suffix>``
+:Example: ``"SET_ADAPTER_NAME_SUFFIX My Adapter\n"``
+:Details:
+  | Sets a suffix to append to the auto-generated I2C adapter name.  Only
+    valid before ADAPTER_START.  A space or other separator character will be
+    placed between the auto-generated name and the suffix, so there is no need
+    to include a leading separator in the suffix.  If the resulting name is too
+    long for the I2C adapter name field, it will be quietly truncated.
+
+----
+
+:Write Command: ``SET_ADAPTER_TIMEOUT_MS <ms>``
+:Example: ``"SET_ADAPTER_TIMEOUT_MS 2000\n"``
+:Details:
+  | Sets the timeout in milliseconds for each I2C transaction, in other words
+    for each master_xfer() reply.  Only valid before ADAPTER_START.  The I2C
+    subsystem will automatically time out transactions based on this setting.
+    Set to 0 to use the I2C subsystem default timeout.  The default timeout for
+    new pseudo adapters where this command has not been used is configurable at
+    i2c-pseudo module load time, and itself has a default independent from the
+    I2C subsystem default.  (If the i2c-pseudo module level default is set to 0,
+    that has the same meaning as here.)
+
+----
+
+:Write Command: ``ADAPTER_START``
+:Example: ``"ADAPTER_START\n"``
+:Details:
+  | Tells i2c-pseudo to actually create the I2C adapter.  Only valid once per
+    open controller fd.
+
+----
+
+:Write Command: ``GET_ADAPTER_NUM``
+:Example: ``"GET_ADAPTER_NUM\n"``
+:Details:
+  | Asks i2c-pseudo for the number assigned to this I2C adapter by the I2C
+    subsystem.  Only valid after ADAPTER_START, because before that the number
+    is not known and cannot be predicted reliably.
+
+----
+
+:Write Command: ``GET_PSEUDO_ID``
+:Example: ``"GET_PSEUDO_ID\n"``
+:Details:
+  | Asks i2c-pseudo for the pseudo ID of this I2C adapter.  The pseudo ID will
+    not be reused for the lifetime of the i2c-pseudo module, unless an internal
+    counter wraps.  I2C clients can use this to track specific instances of
+    pseudo adapters, even when adapter numbers have been reused.
+
+----
+
+:Write Command: ``I2C_XFER_REPLY <xfer_id> <msg_id> <addr> <flags> <errno> [<read_byte>[:...]]``
+:Example: ``"I2C_XFER_REPLY 3 0 0x0070 0x0000 0\n"``
+:Example: ``"I2C_XFER_REPLY 3 1 0x0070 0x0001 0 0B:29:02:D9\n"``
+:Details:
+  | This is how a pseudo controller can reply to I2C_XFER_REQ.  Only valid
+    after I2C_XFER_REQ.  A pseudo controller should write one of these for each
+    I2C_XFER_REQ it reads, including for failures, so that I2C device drivers
+    need not wait for the adapter timeout upon failure (if failure is known
+    sooner).
+  |
+  | The fields in common with I2C_XFER_REQ have their same meanings, and their
+    values are expected to exactly match what was read in the I2C_XFER_REQ
+    command that this is in reply to.
+  |
+  | The errno field is how the pseudo controller indicates success or failure
+    for this I2C message.  A 0 value indicates success.  A non-zero value
+    indicates a failure.  Pseudo controllers are encouraged to use errno values
+    to encode some meaning in a failure response, but that is not a requirement,
+    and the I2C adapter interface does not provide a way to pass per-message
+    errno values to a device driver anyways.
+  |
+  | Pseudo controllers are encouraged to reply in the same order as messages
+    were received, however i2c-pseudo will properly match up out-of-order
+    replies with their original requests.
+
+----
+
+:Write Command: ``ADAPTER_SHUTDOWN``
+:Example: ``"ADAPTER_SHUTDOWN\n"``
+:Details:
+  | This tells i2c-pseudo that the pseudo controller wants to shutdown and
+    intends to close the controller device fd soon.  Use of this is OPTIONAL, it
+    is perfectly valid to close the controller device fd without ever using this
+    command.
+  |
+  | This commands unblocks any blocked controller I/O (reads, writes, or polls),
+    and that is its main purpose.
+  |
+  | Any I2C transactions attempted by a device driver after this command will
+    fail, and will not be passed on to the userspace controller.
+  |
+  | This DOES NOT delete the I2C adapter.  Only closing the fd will do that.
+    That MAY CHANGE in the future, such that this does delete the I2C adapter.
+    (However this will never be required, it will always be okay to simply close
+    the fd.)
+
+
+Example userspace controller code
+=================================
+
+In C, a simple exchange between i2c-pseudo and userspace might look like the
+example below.  Note that for brevity this lacks any error checking and
+handling, which a real pseudo controller implementation should have.
+
+::
+
+  int fd;
+  char buf[1<<12];
+
+  fd = open("/dev/i2c-pseudo-controller", O_RDWR);
+  /* Create the I2C adapter. */
+  dprintf(fd, "ADAPTER_START\n");
+
+  /*
+   * Pretend this I2C adapter number is 5, and the first I2C xfer sent to it was
+   * from this command (using its i2c-dev interface):
+   * $ i2cset -y 5 0x70 0xC2
+   *
+   * Then this read would place the following into *buf:
+   * "I2C_BEGIN_XFER\n"
+   * "I2C_XFER_REQ 0 0 0x0070 0x0000 1 C2\n"
+   * "I2C_COMMIT_XFER\n"
+   */
+  read(fd, buf, sizeof(buf));
+
+  /* This reply would allow the i2cset command above to exit successfully. */
+  dprintf(fd, "I2C_XFER_REPLY 0 0 0x0070 0x0000 0\n");
+
+  /*
+   * Now pretend the next I2C xfer sent to this adapter was from:
+   * $ i2cget -y 5 0x70 0xAB
+   *
+   * Then this read would place the following into *buf:
+   * "I2C_BEGIN_XFER\n"
+   * "I2C_XFER_REQ 1 0 0x0070 0x0000 1 AB\n"
+   * "I2C_XFER_REQ 1 1 0x0070 0x0001 1\n'"
+   * "I2C_COMMIT_XFER\n"
+   */
+  read(fd, buf, sizeof(buf));
+
+  /*
+   * These replies would allow the i2cget command above to print the following to
+   * stdout and exit successfully:
+   * 0x0b
+   *
+   * Note that it is also valid to write these together in one write().
+   */
+  dprintf(fd, "I2C_XFER_REPLY 1 0 0x0070 0x0000 0\n");
+  dprintf(fd, "I2C_XFER_REPLY 1 1 0x0070 0x0001 0 0B\n");
+
+  /* Destroy the I2C adapter. */
+  close(fd);
drivers/i2c/Kconfig +16 -1
index 1474e57ecafc..78a6f909718a 100644
@@ -56,7 +56,7 @@ config I2C_CHARDEV
 	  programs use the I2C bus.  Information on how to do this is
 	  contained in the file <file:Documentation/i2c/dev-interface.rst>.
 
-	  This support is also available as a module.  If so, the module 
+	  This support is also available as a module.  If so, the module
 	  will be called i2c-dev.
 
 config I2C_MUX
@@ -98,6 +98,21 @@ config I2C_SMBUS
 source "drivers/i2c/algos/Kconfig"
 source "drivers/i2c/busses/Kconfig"
 
+config I2C_PSEUDO
+	tristate "I2C userspace adapter interface"
+	depends on m
+	default 'n'
+	help
+	  Say Y here to have an i2c-pseudo-controller device file, usually
+	  found in the /dev directory on your system.  This makes it
+	  possible to have user-space programs implement an I2C bus
+	  (I2C adapter in kernel lingo).  Information on how to do this is
+	  contained in the file <file:Documentation/i2c/i2c-pseudo>.
+
+	  This support is only available as a module, called i2c-pseudo.
+
+	  If you don't know what to do here, definitely say N.
+
 config I2C_STUB
 	tristate "I2C/SMBus Test Stub"
 	depends on m
drivers/i2c/Makefile +1 -0
index bed6ba63c983..07d7bfea7358 100644
@@ -14,6 +14,7 @@ obj-$(CONFIG_I2C_SMBUS)		+= i2c-smbus.o
 obj-$(CONFIG_I2C_CHARDEV)	+= i2c-dev.o
 obj-$(CONFIG_I2C_MUX)		+= i2c-mux.o
 obj-y				+= algos/ busses/ muxes/
+obj-$(CONFIG_I2C_PSEUDO)	+= i2c-pseudo.o
 obj-$(CONFIG_I2C_STUB)		+= i2c-stub.o
 obj-$(CONFIG_I2C_SLAVE_EEPROM)	+= i2c-slave-eeprom.o
 
drivers/i2c/i2c-pseudo.c new file +3198 -0

2,659 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.26.2.526.g744177e7f7-goog

Part of the diff is not shown here. View the raw message.

#2 lore raw
Thank you for the patch! Yet something to improve:

Hi Matthew,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on wsa/i2c/for-next]
[also build test ERROR on v5.7-rc4 next-20200508]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Matthew-Blecker/i2c-Add-i2c-pseudo-driver-for-userspace-I2C-adapters/20200509-011221
base:   https://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git i2c/for-next
config: um-allmodconfig (attached as .config)
compiler: gcc-7 (Ubuntu 7.5.0-6ubuntu2) 7.5.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=um 

If you fix the issue, kindly add following tag as appropriate

All errors (new ones prefixed by >>):

>> drivers/i2c/i2c-pseudo.c:1855:15: error: initializer element is not constant
      .cmd_size = strlen(I2CP_MXFER_REPLY_CMD),
                  ^~~~~~
   drivers/i2c/i2c-pseudo.c:1855:15: note: (near initialization for 'i2cp_cmds[0].cmd_size')
   drivers/i2c/i2c-pseudo.c:1865:15: error: initializer element is not constant
      .cmd_size = strlen(I2CP_ADAP_START_CMD),
                  ^~~~~~
   drivers/i2c/i2c-pseudo.c:1865:15: note: (near initialization for 'i2cp_cmds[1].cmd_size')
   drivers/i2c/i2c-pseudo.c:1872:15: error: initializer element is not constant
      .cmd_size = strlen(I2CP_ADAP_SHUTDOWN_CMD),
                  ^~~~~~
   drivers/i2c/i2c-pseudo.c:1872:15: note: (near initialization for 'i2cp_cmds[2].cmd_size')
   drivers/i2c/i2c-pseudo.c:1879:15: error: initializer element is not constant
      .cmd_size = strlen(I2CP_GET_NUMBER_CMD),
                  ^~~~~~
   drivers/i2c/i2c-pseudo.c:1879:15: note: (near initialization for 'i2cp_cmds[3].cmd_size')
   drivers/i2c/i2c-pseudo.c:1886:15: error: initializer element is not constant
      .cmd_size = strlen(I2CP_GET_PSEUDO_ID_CMD),
                  ^~~~~~

drivers/i2c/i2c-pseudo.c:1886:15: note: (near initialization for 'i2cp_cmds[4].cmd_size') drivers/i2c/i2c-pseudo.c:1893:15: error: initializer element is not constant
.cmd_size = strlen(I2CP_SET_NAME_SUFFIX_CMD),
^~~~~~
drivers/i2c/i2c-pseudo.c:1893:15: note: (near initialization for 'i2cp_cmds[5].cmd_size') drivers/i2c/i2c-pseudo.c:1902:15: error: initializer element is not constant
.cmd_size = strlen(I2CP_SET_TIMEOUT_CMD),
^~~~~~
drivers/i2c/i2c-pseudo.c:1902:15: note: (near initialization for 'i2cp_cmds[6].cmd_size')

vim +1855 drivers/i2c/i2c-pseudo.c

1849
1850 /* Command names are matched in this order, so sort by expected frequency. */
1851 /* All elements should be initialized in their I2CP_CMD_*_IDX position. */
1852 static const struct i2cp_cmd i2cp_cmds[] = {
1853 [I2CP_CMD_MXFER_REPLY_IDX] = {
1854 .cmd_string = I2CP_MXFER_REPLY_CMD,

> 1855			.cmd_size = strlen(I2CP_MXFER_REPLY_CMD),

1856 .data_creator = i2cp_cmd_mxfer_reply_data_creator,
1857 .data_shutdown = i2cp_cmd_mxfer_reply_data_shutdown,
1858 .data_destroyer = i2cp_cmd_mxfer_reply_data_destroyer,
1859 .header_receiver = i2cp_cmd_mxfer_reply_header_receiver,
1860 .data_receiver = i2cp_cmd_mxfer_reply_data_receiver,
1861 .cmd_completer = i2cp_cmd_mxfer_reply_cmd_completer,
1862 },
1863 [I2CP_CMD_ADAP_START_IDX] = {
1864 .cmd_string = I2CP_ADAP_START_CMD,
1865 .cmd_size = strlen(I2CP_ADAP_START_CMD),
1866 .header_receiver = i2cp_cmd_adap_start_header_receiver,
1867 .data_receiver = i2cp_cmd_adap_start_data_receiver,
1868 .cmd_completer = i2cp_cmd_adap_start_cmd_completer,
1869 },
1870 [I2CP_CMD_ADAP_SHUTDOWN_IDX] = {
1871 .cmd_string = I2CP_ADAP_SHUTDOWN_CMD,
1872 .cmd_size = strlen(I2CP_ADAP_SHUTDOWN_CMD),
1873 .header_receiver = i2cp_cmd_adap_shutdown_header_receiver,
1874 .data_receiver = i2cp_cmd_adap_shutdown_data_receiver,
1875 .cmd_completer = i2cp_cmd_adap_shutdown_cmd_completer,
1876 },
1877 [I2CP_CMD_GET_NUMBER_IDX] = {
1878 .cmd_string = I2CP_GET_NUMBER_CMD,
1879 .cmd_size = strlen(I2CP_GET_NUMBER_CMD),
1880 .header_receiver = i2cp_cmd_get_number_header_receiver,
1881 .data_receiver = i2cp_cmd_get_number_data_receiver,
1882 .cmd_completer = i2cp_cmd_get_number_cmd_completer,
1883 },
1884 [I2CP_CMD_GET_PSEUDO_ID_IDX] = {
1885 .cmd_string = I2CP_GET_PSEUDO_ID_CMD,
1886 .cmd_size = strlen(I2CP_GET_PSEUDO_ID_CMD),
1887 .header_receiver = i2cp_cmd_get_pseudo_id_header_receiver,
1888 .data_receiver = i2cp_cmd_get_pseudo_id_data_receiver,
1889 .cmd_completer = i2cp_cmd_get_pseudo_id_cmd_completer,
1890 },
1891 [I2CP_CMD_SET_NAME_SUFFIX_IDX] = {
1892 .cmd_string = I2CP_SET_NAME_SUFFIX_CMD,
1893 .cmd_size = strlen(I2CP_SET_NAME_SUFFIX_CMD),
1894 .data_creator = i2cp_cmd_set_name_suffix_data_creator,
1895 .data_destroyer = i2cp_cmd_set_name_suffix_data_destroyer,
1896 .header_receiver = i2cp_cmd_set_name_suffix_header_receiver,
1897 .data_receiver = i2cp_cmd_set_name_suffix_data_receiver,
1898 .cmd_completer = i2cp_cmd_set_name_suffix_cmd_completer,
1899 },
1900 [I2CP_CMD_SET_TIMEOUT_IDX] = {
1901 .cmd_string = I2CP_SET_TIMEOUT_CMD,
1902 .cmd_size = strlen(I2CP_SET_TIMEOUT_CMD),
1903 .data_creator = i2cp_cmd_set_timeout_data_creator,
1904 .data_destroyer = i2cp_cmd_set_timeout_data_destroyer,
1905 .header_receiver = i2cp_cmd_set_timeout_header_receiver,
1906 .data_receiver = i2cp_cmd_set_timeout_data_receiver,
1907 .cmd_completer = i2cp_cmd_set_timeout_cmd_completer,
1908 },
1909 };
1910

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

#3 lore raw
In reply to Matthew Blecker
Thank you for the patch! Perhaps something to improve:

Hi Matthew,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on wsa/i2c/for-next]
[also build test WARNING on v5.7-rc4 next-20200508]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Matthew-Blecker/i2c-Add-i2c-pseudo-driver-for-userspace-I2C-adapters/20200509-011221
base:   https://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git i2c/for-next

If you fix the issue, kindly add following tag as appropriate

coccinelle warnings: (new ones prefixed by >>)

>> drivers/i2c/i2c-pseudo.c:2897:8-15: WARNING opportunity for memdup_user
--
>> drivers/i2c/i2c-pseudo.c:2206:1-17: ERROR: i2cp_fileops: .read() can deadlock .write(); change nonseekable_open -> stream_open to fix.

Please review and possibly fold the followup patch.

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

#4 lore raw

[PATCH] i2c: fix stream_open.cocci warnings

In reply to Matthew Blecker
drivers/i2c/i2c-pseudo.c:2206:1-17: ERROR: i2cp_fileops: .read() can deadlock .write(); change nonseekable_open -> stream_open to fix.

From: kbuild test robot <[email protected]>

drivers/i2c/i2c-pseudo.c:2206:1-17: ERROR: i2cp_fileops: .read() can deadlock .write(); change nonseekable_open -> stream_open to fix.

Generated by: scripts/coccinelle/api/stream_open.cocci

---

url:    https://github.com/0day-ci/linux/commits/Matthew-Blecker/i2c-Add-i2c-pseudo-driver-for-userspace-I2C-adapters/20200509-011221
base:   https://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git i2c/for-next

Please take the patch only if it's a positive warning. Thanks!

 i2c-pseudo.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/i2c-pseudo.c +1 -1
@@ -2203,7 +2203,7 @@ static int i2cp_cdev_open(struct inode *
 	this_pseudo = i2cp_device;
 
 	/* I2C pseudo adapter controllers are not seekable. */
-	nonseekable_open(inodep, filep);
+	stream_open(inodep, filep);
 	/* Refuse fsnotify events.  Modeled after /dev/ptmx implementation. */
 	filep->f_mode |= FMODE_NONOTIFY;