Re: [PATCH v6] i2c: virtio: add a virtio i2c frontend driver

From: kernel test robot
Date: Thu Mar 04 2021 - 00:54:43 EST


Hi Jie,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on wsa/i2c/for-next]
[also build test WARNING on vhost/linux-next linux/master linus/master v5.12-rc1 next-20210303]
[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]

url: https://github.com/0day-ci/linux/commits/Jie-Deng/i2c-virtio-add-a-virtio-i2c-frontend-driver/20210304-100543
base: https://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git i2c/for-next
config: xtensa-randconfig-s031-20210304 (attached as .config)
compiler: xtensa-linux-gcc (GCC) 9.3.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.3-245-gacc5c298-dirty
# https://github.com/0day-ci/linux/commit/bb645653b6d7750a026229726f8d9d0371457ac6
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Jie-Deng/i2c-virtio-add-a-virtio-i2c-frontend-driver/20210304-100543
git checkout bb645653b6d7750a026229726f8d9d0371457ac6
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=xtensa

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>


"sparse warnings: (new ones prefixed by >>)"
>> drivers/i2c/busses/i2c-virtio.c:78:47: sparse: sparse: invalid assignment: |=
>> drivers/i2c/busses/i2c-virtio.c:78:47: sparse: left side has type restricted __le32
>> drivers/i2c/busses/i2c-virtio.c:78:47: sparse: right side has type int

vim +78 drivers/i2c/busses/i2c-virtio.c

59
60 static int virtio_i2c_send_reqs(struct virtqueue *vq,
61 struct virtio_i2c_req *reqs,
62 struct i2c_msg *msgs, int nr)
63 {
64 struct scatterlist *sgs[3], out_hdr, msg_buf, in_hdr;
65 int i, outcnt, incnt, err = 0;
66 u8 *buf;
67
68 for (i = 0; i < nr; i++) {
69 if (!msgs[i].len)
70 break;
71
72 /* Only 7-bit mode supported for this moment. For the address format,
73 * Please check the Virtio I2C Specification.
74 */
75 reqs[i].out_hdr.addr = cpu_to_le16(msgs[i].addr << 1);
76
77 if (i != nr - 1)
> 78 reqs[i].out_hdr.flags |= VIRTIO_I2C_FLAGS_FAIL_NEXT;
79
80 outcnt = incnt = 0;
81 sg_init_one(&out_hdr, &reqs[i].out_hdr, sizeof(reqs[i].out_hdr));
82 sgs[outcnt++] = &out_hdr;
83
84 buf = kzalloc(msgs[i].len, GFP_KERNEL);
85 if (!buf)
86 break;
87
88 reqs[i].buf = buf;
89 sg_init_one(&msg_buf, reqs[i].buf, msgs[i].len);
90
91 if (msgs[i].flags & I2C_M_RD) {
92 sgs[outcnt + incnt++] = &msg_buf;
93 } else {
94 memcpy(reqs[i].buf, msgs[i].buf, msgs[i].len);
95 sgs[outcnt++] = &msg_buf;
96 }
97
98 sg_init_one(&in_hdr, &reqs[i].in_hdr, sizeof(reqs[i].in_hdr));
99 sgs[outcnt + incnt++] = &in_hdr;
100
101 err = virtqueue_add_sgs(vq, sgs, outcnt, incnt, &reqs[i], GFP_KERNEL);
102 if (err < 0) {
103 pr_err("failed to add msg[%d] to virtqueue.\n", i);
104 kfree(reqs[i].buf);
105 reqs[i].buf = NULL;
106 break;
107 }
108 }
109
110 return i;
111 }
112

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

Attachment: .config.gz
Description: application/gzip