* [PATCH] i2c: i2c-stub: support for I2C_FUNC_I2C
@ 2026-05-14 8:11 Peter Bohner
2026-05-15 9:54 ` kernel test robot
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Peter Bohner @ 2026-05-14 8:11 UTC (permalink / raw)
To: Wolfram Sang, Jean Delvare, linux-i2c; +Cc: Peter Bohner
Make the i2c-stub driver optionally minimal support I2C transactions, when
enabling I2C_FUNC_I2C.
I2C reads/writes act on a dynamically expanded buffer that is separate
from the data of the SMBus commands.
Signed-off-by: Peter Bohner <peter@bohner.me>
---
Documentation/i2c/i2c-stub.rst | 8 ++-
drivers/i2c/i2c-stub.c | 90 +++++++++++++++++++++++++++++-----
2 files changed, 85 insertions(+), 13 deletions(-)
diff --git a/Documentation/i2c/i2c-stub.rst b/Documentation/i2c/i2c-stub.rst
index a6fc6916d6bc..8b427a9579dd 100644
--- a/Documentation/i2c/i2c-stub.rst
+++ b/Documentation/i2c/i2c-stub.rst
@@ -7,7 +7,8 @@ Description
This module is a very simple fake I2C/SMBus driver. It implements six
types of SMBus commands: write quick, (r/w) byte, (r/w) byte data, (r/w)
-word data, (r/w) I2C block data, and (r/w) SMBus block data.
+word data, (r/w) I2C block data, and (r/w) SMBus block data, as-well as
+I2C transactions.
You need to provide chip addresses as a module parameter when loading this
driver, which will then only react to SMBus commands to these addresses.
@@ -30,6 +31,11 @@ SMBus block commands must be written to configure an SMBus command for
SMBus block operations. Writes can be partial. Block read commands always
return the number of bytes selected with the largest write so far.
+Support for I2C transactions using the I2C_RDWR ioctl must also be explicitly
+enabled by setting I2C_FUNC_I2C (0x00000001) in the functionality parameter.
+When enabled, the message data is written to and read from the beginning of a
+buffer, that is separate from the SMBus commands.
+
The typical use-case is like this:
1. load this module
diff --git a/drivers/i2c/i2c-stub.c b/drivers/i2c/i2c-stub.c
index 04314e3ed24c..bf718bd6110c 100644
--- a/drivers/i2c/i2c-stub.c
+++ b/drivers/i2c/i2c-stub.c
@@ -4,7 +4,7 @@
Copyright (c) 2004 Mark M. Hoffman <mhoffman@lightlink.com>
Copyright (C) 2007-2014 Jean Delvare <jdelvare@suse.de>
-
+ Copyright (c) 2026 Peter Bohner <peter@bohner.me>
*/
#define pr_fmt(fmt) "i2c-stub: " fmt
@@ -23,6 +23,7 @@
* Support for I2C_FUNC_SMBUS_BLOCK_DATA is disabled by default and must
* be enabled explicitly by setting the I2C_FUNC_SMBUS_BLOCK_DATA bits
* in the 'functionality' module parameter.
+ * The same applies to I2C_FUNC_I2C.
*/
#define STUB_FUNC_DEFAULT \
(I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | \
@@ -30,7 +31,7 @@
I2C_FUNC_SMBUS_I2C_BLOCK)
#define STUB_FUNC_ALL \
- (STUB_FUNC_DEFAULT | I2C_FUNC_SMBUS_BLOCK_DATA)
+ (STUB_FUNC_DEFAULT | I2C_FUNC_SMBUS_BLOCK_DATA | I2C_FUNC_I2C)
static unsigned short chip_addr[MAX_CHIPS];
module_param_array(chip_addr, ushort, NULL, S_IRUGO);
@@ -81,6 +82,9 @@ struct stub_chip {
u8 bank_end;
u16 bank_size;
u16 *bank_words; /* Room for bank_mask * bank_size registers */
+
+ u8 *i2c_rw_data;
+ u16 i2c_rw_size;
};
static struct stub_chip *stub_chips;
@@ -119,23 +123,82 @@ static u16 *stub_get_wordp(struct stub_chip *chip, u8 offset)
return chip->words + offset;
}
-/* Return negative errno on error. */
-static s32 stub_xfer(struct i2c_adapter *adap, u16 addr, unsigned short flags,
- char read_write, u8 command, int size, union i2c_smbus_data *data)
+static struct stub_chip *stub_addr_to_chip(u16 addr)
{
- s32 ret;
- int i, len;
+ int i;
struct stub_chip *chip = NULL;
- struct smbus_block_data *b;
- u16 *wordp;
- /* Search for the right chip */
for (i = 0; i < stub_chips_nr; i++) {
+ /* we do not need to handle I2C_FUNC_10BIT_ADDR explicitly */
if (addr == chip_addr[i]) {
chip = stub_chips + i;
break;
}
}
+ return chip;
+}
+
+static s32 stub_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
+{
+ int i;
+ u8 *new_rw_mem;
+ struct stub_chip *chip = NULL;
+ struct i2c_msg *msg;
+
+ for (i = 0; i < num; i++) {
+ msg = msgs + i;
+ chip = stub_addr_to_chip(msg->addr);
+ if (!chip)
+ return -ENODEV;
+
+ /* len is guaranteed to be <= 8192 by i2cdev_ioctl_rdwr */
+ if (chip->i2c_rw_size < msg->len) {
+ new_rw_mem =
+ krelloc_array(chip->i2c_rw_data, msg->len, 1,
+ GFP_KERNEL | __GFP_ZERO);
+ if (!new_rw_mem)
+ return -ENOMEM;
+ chip->i2c_rw_data = new_rw_mem;
+ chip->i2c_rw_size = msg->len;
+ }
+
+ /* read, size determined by slave */
+ if ((msg->flags & I2C_M_RD) && (msg->flags & I2C_M_RECV_LEN)) {
+ /* i2cdev_ioctl_rdwr expects this as a maximum, even
+ * though 0xff would be the theoretically possible
+ */
+ msg->len = min(chip->i2c_rw_size, I2C_SMBUS_BLOCK_MAX);
+ msg->buf[0] = msg->len - 1;
+ dev_dbg(&adap->dev,
+ "i2c read with RECV_LEN - addr 0x%02x, read %u bytes\n",
+ msg->addr, msg->len);
+ memcpy(msg->buf + 1, chip->i2c_rw_data, msg->len - 1);
+ } else if (msg->flags & I2C_M_RD) {
+ dev_dbg(&adap->dev,
+ "i2c read - addr 0x%02x, read %u bytes\n",
+ msg->addr, msg->len);
+ memcpy(msg->buf, chip->i2c_rw_data, msg->len);
+ } else {
+ dev_dbg(&adap->dev,
+ "i2c write - addr 0x%02x, wrote %u bytes\n",
+ msg->addr, msg->len);
+ memcpy(chip->i2c_rw_data, msg->buf, msg->len);
+ }
+ }
+ return num;
+}
+
+/* Return negative errno on error. */
+static s32 stub_smbus_xfer(struct i2c_adapter *adap, u16 addr, unsigned short flags,
+ char read_write, u8 command, int size, union i2c_smbus_data *data)
+{
+ s32 ret;
+ int i, len;
+ struct stub_chip *chip;
+ struct smbus_block_data *b;
+ u16 *wordp;
+
+ chip = stub_addr_to_chip(addr);
if (!chip)
return -ENODEV;
@@ -308,7 +371,8 @@ static u32 stub_func(struct i2c_adapter *adapter)
static const struct i2c_algorithm smbus_algorithm = {
.functionality = stub_func,
- .smbus_xfer = stub_xfer,
+ .smbus_xfer = stub_smbus_xfer,
+ .xfer = stub_xfer,
};
static struct i2c_adapter stub_adapter = {
@@ -351,8 +415,10 @@ static void i2c_stub_free(void)
{
int i;
- for (i = 0; i < stub_chips_nr; i++)
+ for (i = 0; i < stub_chips_nr; i++) {
kfree(stub_chips[i].bank_words);
+ kfree(stub_chips[i].i2c_rw_data);
+ }
kfree(stub_chips);
}
--
2.54.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] i2c: i2c-stub: support for I2C_FUNC_I2C
2026-05-14 8:11 [PATCH] i2c: i2c-stub: support for I2C_FUNC_I2C Peter Bohner
@ 2026-05-15 9:54 ` kernel test robot
2026-05-15 10:05 ` kernel test robot
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: kernel test robot @ 2026-05-15 9:54 UTC (permalink / raw)
To: Peter Bohner, Wolfram Sang, Jean Delvare, linux-i2c
Cc: oe-kbuild-all, Peter Bohner
Hi Peter,
kernel test robot noticed the following build errors:
[auto build test ERROR on wsa/i2c/for-next]
[also build test ERROR on linus/master v7.1-rc3 next-20260508]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Peter-Bohner/i2c-i2c-stub-support-for-I2C_FUNC_I2C/20260515-113705
base: https://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git i2c/for-next
patch link: https://lore.kernel.org/r/20260514081100.381043-1-peter%40bohner.me
patch subject: [PATCH] i2c: i2c-stub: support for I2C_FUNC_I2C
config: m68k-randconfig-r062-20260515 (https://download.01.org/0day-ci/archive/20260515/202605151724.yb2Dto9Q-lkp@intel.com/config)
compiler: m68k-linux-gcc (GCC) 8.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260515/202605151724.yb2Dto9Q-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202605151724.yb2Dto9Q-lkp@intel.com/
All error/warnings (new ones prefixed by >>):
drivers/i2c/i2c-stub.c: In function 'stub_xfer':
>> drivers/i2c/i2c-stub.c:157:5: error: implicit declaration of function 'krelloc_array'; did you mean 'krealloc_array'? [-Werror=implicit-function-declaration]
krelloc_array(chip->i2c_rw_data, msg->len, 1,
^~~~~~~~~~~~~
krealloc_array
>> drivers/i2c/i2c-stub.c:156:15: warning: assignment to 'u8 *' {aka 'unsigned char *'} from 'int' makes pointer from integer without a cast [-Wint-conversion]
new_rw_mem =
^
cc1: some warnings being treated as errors
vim +157 drivers/i2c/i2c-stub.c
140
141 static s32 stub_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
142 {
143 int i;
144 u8 *new_rw_mem;
145 struct stub_chip *chip = NULL;
146 struct i2c_msg *msg;
147
148 for (i = 0; i < num; i++) {
149 msg = msgs + i;
150 chip = stub_addr_to_chip(msg->addr);
151 if (!chip)
152 return -ENODEV;
153
154 /* len is guaranteed to be <= 8192 by i2cdev_ioctl_rdwr */
155 if (chip->i2c_rw_size < msg->len) {
> 156 new_rw_mem =
> 157 krelloc_array(chip->i2c_rw_data, msg->len, 1,
158 GFP_KERNEL | __GFP_ZERO);
159 if (!new_rw_mem)
160 return -ENOMEM;
161 chip->i2c_rw_data = new_rw_mem;
162 chip->i2c_rw_size = msg->len;
163 }
164
165 /* read, size determined by slave */
166 if ((msg->flags & I2C_M_RD) && (msg->flags & I2C_M_RECV_LEN)) {
167 /* i2cdev_ioctl_rdwr expects this as a maximum, even
168 * though 0xff would be the theoretically possible
169 */
170 msg->len = min(chip->i2c_rw_size, I2C_SMBUS_BLOCK_MAX);
171 msg->buf[0] = msg->len - 1;
172 dev_dbg(&adap->dev,
173 "i2c read with RECV_LEN - addr 0x%02x, read %u bytes\n",
174 msg->addr, msg->len);
175 memcpy(msg->buf + 1, chip->i2c_rw_data, msg->len - 1);
176 } else if (msg->flags & I2C_M_RD) {
177 dev_dbg(&adap->dev,
178 "i2c read - addr 0x%02x, read %u bytes\n",
179 msg->addr, msg->len);
180 memcpy(msg->buf, chip->i2c_rw_data, msg->len);
181 } else {
182 dev_dbg(&adap->dev,
183 "i2c write - addr 0x%02x, wrote %u bytes\n",
184 msg->addr, msg->len);
185 memcpy(chip->i2c_rw_data, msg->buf, msg->len);
186 }
187 }
188 return num;
189 }
190
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] i2c: i2c-stub: support for I2C_FUNC_I2C
2026-05-14 8:11 [PATCH] i2c: i2c-stub: support for I2C_FUNC_I2C Peter Bohner
2026-05-15 9:54 ` kernel test robot
@ 2026-05-15 10:05 ` kernel test robot
2026-05-15 12:53 ` kernel test robot
2026-05-15 16:05 ` kernel test robot
3 siblings, 0 replies; 5+ messages in thread
From: kernel test robot @ 2026-05-15 10:05 UTC (permalink / raw)
To: Peter Bohner, Wolfram Sang, Jean Delvare, linux-i2c
Cc: oe-kbuild-all, Peter Bohner
Hi Peter,
kernel test robot noticed the following build errors:
[auto build test ERROR on wsa/i2c/for-next]
[also build test ERROR on linus/master v7.1-rc3 next-20260508]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Peter-Bohner/i2c-i2c-stub-support-for-I2C_FUNC_I2C/20260515-113705
base: https://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git i2c/for-next
patch link: https://lore.kernel.org/r/20260514081100.381043-1-peter%40bohner.me
patch subject: [PATCH] i2c: i2c-stub: support for I2C_FUNC_I2C
config: x86_64-rhel-9.4 (https://download.01.org/0day-ci/archive/20260515/202605151823.UX1Nue5m-lkp@intel.com/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260515/202605151823.UX1Nue5m-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202605151823.UX1Nue5m-lkp@intel.com/
All errors (new ones prefixed by >>):
drivers/i2c/i2c-stub.c: In function 'stub_xfer':
drivers/i2c/i2c-stub.c:157:33: error: implicit declaration of function 'krelloc_array'; did you mean 'krealloc_array'? [-Wimplicit-function-declaration]
157 | krelloc_array(chip->i2c_rw_data, msg->len, 1,
| ^~~~~~~~~~~~~
| krealloc_array
>> drivers/i2c/i2c-stub.c:156:36: error: assignment to 'u8 *' {aka 'unsigned char *'} from 'int' makes pointer from integer without a cast [-Wint-conversion]
156 | new_rw_mem =
| ^
vim +156 drivers/i2c/i2c-stub.c
140
141 static s32 stub_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
142 {
143 int i;
144 u8 *new_rw_mem;
145 struct stub_chip *chip = NULL;
146 struct i2c_msg *msg;
147
148 for (i = 0; i < num; i++) {
149 msg = msgs + i;
150 chip = stub_addr_to_chip(msg->addr);
151 if (!chip)
152 return -ENODEV;
153
154 /* len is guaranteed to be <= 8192 by i2cdev_ioctl_rdwr */
155 if (chip->i2c_rw_size < msg->len) {
> 156 new_rw_mem =
157 krelloc_array(chip->i2c_rw_data, msg->len, 1,
158 GFP_KERNEL | __GFP_ZERO);
159 if (!new_rw_mem)
160 return -ENOMEM;
161 chip->i2c_rw_data = new_rw_mem;
162 chip->i2c_rw_size = msg->len;
163 }
164
165 /* read, size determined by slave */
166 if ((msg->flags & I2C_M_RD) && (msg->flags & I2C_M_RECV_LEN)) {
167 /* i2cdev_ioctl_rdwr expects this as a maximum, even
168 * though 0xff would be the theoretically possible
169 */
170 msg->len = min(chip->i2c_rw_size, I2C_SMBUS_BLOCK_MAX);
171 msg->buf[0] = msg->len - 1;
172 dev_dbg(&adap->dev,
173 "i2c read with RECV_LEN - addr 0x%02x, read %u bytes\n",
174 msg->addr, msg->len);
175 memcpy(msg->buf + 1, chip->i2c_rw_data, msg->len - 1);
176 } else if (msg->flags & I2C_M_RD) {
177 dev_dbg(&adap->dev,
178 "i2c read - addr 0x%02x, read %u bytes\n",
179 msg->addr, msg->len);
180 memcpy(msg->buf, chip->i2c_rw_data, msg->len);
181 } else {
182 dev_dbg(&adap->dev,
183 "i2c write - addr 0x%02x, wrote %u bytes\n",
184 msg->addr, msg->len);
185 memcpy(chip->i2c_rw_data, msg->buf, msg->len);
186 }
187 }
188 return num;
189 }
190
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] i2c: i2c-stub: support for I2C_FUNC_I2C
2026-05-14 8:11 [PATCH] i2c: i2c-stub: support for I2C_FUNC_I2C Peter Bohner
2026-05-15 9:54 ` kernel test robot
2026-05-15 10:05 ` kernel test robot
@ 2026-05-15 12:53 ` kernel test robot
2026-05-15 16:05 ` kernel test robot
3 siblings, 0 replies; 5+ messages in thread
From: kernel test robot @ 2026-05-15 12:53 UTC (permalink / raw)
To: Peter Bohner, Wolfram Sang, Jean Delvare, linux-i2c
Cc: oe-kbuild-all, Peter Bohner
Hi Peter,
kernel test robot noticed the following build errors:
[auto build test ERROR on wsa/i2c/for-next]
[also build test ERROR on linus/master v6.16-rc1 next-20260508]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Peter-Bohner/i2c-i2c-stub-support-for-I2C_FUNC_I2C/20260515-113705
base: https://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git i2c/for-next
patch link: https://lore.kernel.org/r/20260514081100.381043-1-peter%40bohner.me
patch subject: [PATCH] i2c: i2c-stub: support for I2C_FUNC_I2C
config: x86_64-rhel-9.4 (https://download.01.org/0day-ci/archive/20260515/202605151418.JKwPcs0v-lkp@intel.com/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260515/202605151418.JKwPcs0v-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202605151418.JKwPcs0v-lkp@intel.com/
All errors (new ones prefixed by >>):
drivers/i2c/i2c-stub.c: In function 'stub_xfer':
>> drivers/i2c/i2c-stub.c:157:33: error: implicit declaration of function 'krelloc_array'; did you mean 'krealloc_array'? [-Wimplicit-function-declaration]
157 | krelloc_array(chip->i2c_rw_data, msg->len, 1,
| ^~~~~~~~~~~~~
| krealloc_array
>> drivers/i2c/i2c-stub.c:156:36: error: assignment to 'u8 *' {aka 'unsigned char *'} from 'int' makes pointer from integer without a cast [-Wint-conversion]
156 | new_rw_mem =
| ^
vim +157 drivers/i2c/i2c-stub.c
140
141 static s32 stub_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
142 {
143 int i;
144 u8 *new_rw_mem;
145 struct stub_chip *chip = NULL;
146 struct i2c_msg *msg;
147
148 for (i = 0; i < num; i++) {
149 msg = msgs + i;
150 chip = stub_addr_to_chip(msg->addr);
151 if (!chip)
152 return -ENODEV;
153
154 /* len is guaranteed to be <= 8192 by i2cdev_ioctl_rdwr */
155 if (chip->i2c_rw_size < msg->len) {
> 156 new_rw_mem =
> 157 krelloc_array(chip->i2c_rw_data, msg->len, 1,
158 GFP_KERNEL | __GFP_ZERO);
159 if (!new_rw_mem)
160 return -ENOMEM;
161 chip->i2c_rw_data = new_rw_mem;
162 chip->i2c_rw_size = msg->len;
163 }
164
165 /* read, size determined by slave */
166 if ((msg->flags & I2C_M_RD) && (msg->flags & I2C_M_RECV_LEN)) {
167 /* i2cdev_ioctl_rdwr expects this as a maximum, even
168 * though 0xff would be the theoretically possible
169 */
170 msg->len = min(chip->i2c_rw_size, I2C_SMBUS_BLOCK_MAX);
171 msg->buf[0] = msg->len - 1;
172 dev_dbg(&adap->dev,
173 "i2c read with RECV_LEN - addr 0x%02x, read %u bytes\n",
174 msg->addr, msg->len);
175 memcpy(msg->buf + 1, chip->i2c_rw_data, msg->len - 1);
176 } else if (msg->flags & I2C_M_RD) {
177 dev_dbg(&adap->dev,
178 "i2c read - addr 0x%02x, read %u bytes\n",
179 msg->addr, msg->len);
180 memcpy(msg->buf, chip->i2c_rw_data, msg->len);
181 } else {
182 dev_dbg(&adap->dev,
183 "i2c write - addr 0x%02x, wrote %u bytes\n",
184 msg->addr, msg->len);
185 memcpy(chip->i2c_rw_data, msg->buf, msg->len);
186 }
187 }
188 return num;
189 }
190
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] i2c: i2c-stub: support for I2C_FUNC_I2C
2026-05-14 8:11 [PATCH] i2c: i2c-stub: support for I2C_FUNC_I2C Peter Bohner
` (2 preceding siblings ...)
2026-05-15 12:53 ` kernel test robot
@ 2026-05-15 16:05 ` kernel test robot
3 siblings, 0 replies; 5+ messages in thread
From: kernel test robot @ 2026-05-15 16:05 UTC (permalink / raw)
To: Peter Bohner, Wolfram Sang, Jean Delvare, linux-i2c
Cc: llvm, oe-kbuild-all, Peter Bohner
Hi Peter,
kernel test robot noticed the following build errors:
[auto build test ERROR on wsa/i2c/for-next]
[also build test ERROR on linus/master v7.1-rc3 next-20260508]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Peter-Bohner/i2c-i2c-stub-support-for-I2C_FUNC_I2C/20260515-113705
base: https://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git i2c/for-next
patch link: https://lore.kernel.org/r/20260514081100.381043-1-peter%40bohner.me
patch subject: [PATCH] i2c: i2c-stub: support for I2C_FUNC_I2C
config: x86_64-rhel-9.4-rust (https://download.01.org/0day-ci/archive/20260515/202605151757.fT8a2zYC-lkp@intel.com/config)
compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261)
rustc: rustc 1.88.0 (6b00bc388 2025-06-23)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260515/202605151757.fT8a2zYC-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202605151757.fT8a2zYC-lkp@intel.com/
All errors (new ones prefixed by >>):
>> drivers/i2c/i2c-stub.c:157:5: error: call to undeclared function 'krelloc_array'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
157 | krelloc_array(chip->i2c_rw_data, msg->len, 1,
| ^
>> drivers/i2c/i2c-stub.c:156:15: error: incompatible integer to pointer conversion assigning to 'u8 *' (aka 'unsigned char *') from 'int' [-Wint-conversion]
156 | new_rw_mem =
| ^
157 | krelloc_array(chip->i2c_rw_data, msg->len, 1,
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
158 | GFP_KERNEL | __GFP_ZERO);
| ~~~~~~~~~~~~~~~~~~~~~~~~
2 errors generated.
vim +/krelloc_array +157 drivers/i2c/i2c-stub.c
140
141 static s32 stub_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
142 {
143 int i;
144 u8 *new_rw_mem;
145 struct stub_chip *chip = NULL;
146 struct i2c_msg *msg;
147
148 for (i = 0; i < num; i++) {
149 msg = msgs + i;
150 chip = stub_addr_to_chip(msg->addr);
151 if (!chip)
152 return -ENODEV;
153
154 /* len is guaranteed to be <= 8192 by i2cdev_ioctl_rdwr */
155 if (chip->i2c_rw_size < msg->len) {
> 156 new_rw_mem =
> 157 krelloc_array(chip->i2c_rw_data, msg->len, 1,
158 GFP_KERNEL | __GFP_ZERO);
159 if (!new_rw_mem)
160 return -ENOMEM;
161 chip->i2c_rw_data = new_rw_mem;
162 chip->i2c_rw_size = msg->len;
163 }
164
165 /* read, size determined by slave */
166 if ((msg->flags & I2C_M_RD) && (msg->flags & I2C_M_RECV_LEN)) {
167 /* i2cdev_ioctl_rdwr expects this as a maximum, even
168 * though 0xff would be the theoretically possible
169 */
170 msg->len = min(chip->i2c_rw_size, I2C_SMBUS_BLOCK_MAX);
171 msg->buf[0] = msg->len - 1;
172 dev_dbg(&adap->dev,
173 "i2c read with RECV_LEN - addr 0x%02x, read %u bytes\n",
174 msg->addr, msg->len);
175 memcpy(msg->buf + 1, chip->i2c_rw_data, msg->len - 1);
176 } else if (msg->flags & I2C_M_RD) {
177 dev_dbg(&adap->dev,
178 "i2c read - addr 0x%02x, read %u bytes\n",
179 msg->addr, msg->len);
180 memcpy(msg->buf, chip->i2c_rw_data, msg->len);
181 } else {
182 dev_dbg(&adap->dev,
183 "i2c write - addr 0x%02x, wrote %u bytes\n",
184 msg->addr, msg->len);
185 memcpy(chip->i2c_rw_data, msg->buf, msg->len);
186 }
187 }
188 return num;
189 }
190
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-05-15 16:06 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-14 8:11 [PATCH] i2c: i2c-stub: support for I2C_FUNC_I2C Peter Bohner
2026-05-15 9:54 ` kernel test robot
2026-05-15 10:05 ` kernel test robot
2026-05-15 12:53 ` kernel test robot
2026-05-15 16:05 ` kernel test robot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox