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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 2021/7/1 14:18, Viresh Kumar wrote:
On 01-07-21, 14:10, Jie Deng wrote:
I think a fixed number of sgs will make things easier to develop backend.
Yeah, but it looks awkward to send a message buffer which isn't used
at all. From protocol's point of view, it just looks wrong/buggy.

The backend can just look at the number of elements received, they
can either be 2 (in case of zero-length) transfer, or 3 (for
read/write) and any other number is invalid.


OK. Let's add the following two lines to make sure that msg_buf is only
sent when the msgs len is not zero. And backend judges whether it is
a zero-length request by checking the number of elements received.

 + if (msgs[i].len) {
           reqs[i].buf = i2c_get_dma_safe_msg_buf(&msgs[i], 1);
           if (!reqs[i].buf)
                   break;

          sg_init_one(&msg_buf, reqs[i].buf, msgs[i].len);

          if (msgs[i].flags & I2C_M_RD)
                  sgs[outcnt + incnt++] = &msg_buf;
          else
                  sgs[outcnt++] = &msg_buf;
+}


_______________________________________________
Virtualization mailing list
Virtualization@xxxxxxxxxxxxxxxxxxxxxxxxxx
https://lists.linuxfoundation.org/mailman/listinfo/virtualization




[Index of Archives]     [KVM Development]     [Libvirt Development]     [Libvirt Users]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux