Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'i2c/for-current' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux

Pull i2c fixes from Wolfram Sang:
"Two more I2C driver bugfixes"

* 'i2c/for-current' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux:
i2c: mpc: Use atomic read and fix break condition
i2c: virtio: fix completion handling

+13 -21
+1 -1
drivers/i2c/busses/i2c-mpc.c
··· 636 636 status = readb(i2c->base + MPC_I2C_SR); 637 637 if (status & CSR_MIF) { 638 638 /* Wait up to 100us for transfer to properly complete */ 639 - readb_poll_timeout(i2c->base + MPC_I2C_SR, status, !(status & CSR_MCF), 0, 100); 639 + readb_poll_timeout_atomic(i2c->base + MPC_I2C_SR, status, status & CSR_MCF, 0, 100); 640 640 writeb(0, i2c->base + MPC_I2C_SR); 641 641 mpc_i2c_do_intr(i2c, status); 642 642 return IRQ_HANDLED;
+12 -20
drivers/i2c/busses/i2c-virtio.c
··· 22 22 /** 23 23 * struct virtio_i2c - virtio I2C data 24 24 * @vdev: virtio device for this controller 25 - * @completion: completion of virtio I2C message 26 25 * @adap: I2C adapter for this controller 27 26 * @vq: the virtio virtqueue for communication 28 27 */ 29 28 struct virtio_i2c { 30 29 struct virtio_device *vdev; 31 - struct completion completion; 32 30 struct i2c_adapter adap; 33 31 struct virtqueue *vq; 34 32 }; 35 33 36 34 /** 37 35 * struct virtio_i2c_req - the virtio I2C request structure 36 + * @completion: completion of virtio I2C message 38 37 * @out_hdr: the OUT header of the virtio I2C message 39 38 * @buf: the buffer into which data is read, or from which it's written 40 39 * @in_hdr: the IN header of the virtio I2C message 41 40 */ 42 41 struct virtio_i2c_req { 42 + struct completion completion; 43 43 struct virtio_i2c_out_hdr out_hdr ____cacheline_aligned; 44 44 uint8_t *buf ____cacheline_aligned; 45 45 struct virtio_i2c_in_hdr in_hdr ____cacheline_aligned; ··· 47 47 48 48 static void virtio_i2c_msg_done(struct virtqueue *vq) 49 49 { 50 - struct virtio_i2c *vi = vq->vdev->priv; 50 + struct virtio_i2c_req *req; 51 + unsigned int len; 51 52 52 - complete(&vi->completion); 53 + while ((req = virtqueue_get_buf(vq, &len))) 54 + complete(&req->completion); 53 55 } 54 56 55 57 static int virtio_i2c_prepare_reqs(struct virtqueue *vq, ··· 63 61 64 62 for (i = 0; i < num; i++) { 65 63 int outcnt = 0, incnt = 0; 64 + 65 + init_completion(&reqs[i].completion); 66 66 67 67 /* 68 68 * Only 7-bit mode supported for this moment. For the address ··· 110 106 struct virtio_i2c_req *reqs, 111 107 struct i2c_msg *msgs, int num) 112 108 { 113 - struct virtio_i2c_req *req; 114 109 bool failed = false; 115 - unsigned int len; 116 110 int i, j = 0; 117 111 118 112 for (i = 0; i < num; i++) { 119 - /* Detach the ith request from the vq */ 120 - req = virtqueue_get_buf(vq, &len); 113 + struct virtio_i2c_req *req = &reqs[i]; 121 114 122 - /* 123 - * Condition req == &reqs[i] should always meet since we have 124 - * total num requests in the vq. reqs[i] can never be NULL here. 125 - */ 126 - if (!failed && (WARN_ON(req != &reqs[i]) || 127 - req->in_hdr.status != VIRTIO_I2C_MSG_OK)) 115 + wait_for_completion(&req->completion); 116 + 117 + if (!failed && req->in_hdr.status != VIRTIO_I2C_MSG_OK) 128 118 failed = true; 129 119 130 120 i2c_put_dma_safe_msg_buf(reqs[i].buf, &msgs[i], !failed); ··· 154 156 * remote here to clear the virtqueue, so we can try another set of 155 157 * messages later on. 156 158 */ 157 - 158 - reinit_completion(&vi->completion); 159 159 virtqueue_kick(vq); 160 - 161 - wait_for_completion(&vi->completion); 162 160 163 161 count = virtio_i2c_complete_reqs(vq, reqs, msgs, count); 164 162 ··· 203 209 204 210 vdev->priv = vi; 205 211 vi->vdev = vdev; 206 - 207 - init_completion(&vi->completion); 208 212 209 213 ret = virtio_i2c_setup_vqs(vi); 210 214 if (ret)