Commit 2b07f54a80710c4ee0dc3edc5870ca8714ae5ed3
Committed by
Suman Anna
1 parent
40fe1cae1f
Exists in
ti-lsk-linux-4.1.y
and in
5 other branches
virtio_ring: break out vring descriptor setup code
Break out the vring descriptor setup into a separate inline function. No functional change. This will be used later to deal with potential non-linear addresses used by virtio-rpmsg. Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> [s-anna@ti.com: fixup flags type, revise commit log] Signed-off-by: Suman Anna <s-anna@ti.com>
Showing 1 changed file with 14 additions and 6 deletions Side-by-side Diff
drivers/virtio/virtio_ring.c
... | ... | @@ -120,6 +120,16 @@ |
120 | 120 | return desc; |
121 | 121 | } |
122 | 122 | |
123 | +static inline void vring_desc_set(struct virtio_device *vdev, | |
124 | + struct vring_desc *desc, | |
125 | + struct scatterlist *sg, | |
126 | + u16 flags) | |
127 | +{ | |
128 | + desc->flags = cpu_to_virtio16(vdev, flags); | |
129 | + desc->addr = cpu_to_virtio64(vdev, sg_phys(sg)); | |
130 | + desc->len = cpu_to_virtio32(vdev, sg->length); | |
131 | +} | |
132 | + | |
123 | 133 | static inline int virtqueue_add(struct virtqueue *_vq, |
124 | 134 | struct scatterlist *sgs[], |
125 | 135 | unsigned int total_sg, |
126 | 136 | |
... | ... | @@ -205,18 +215,16 @@ |
205 | 215 | |
206 | 216 | for (n = 0; n < out_sgs; n++) { |
207 | 217 | for (sg = sgs[n]; sg; sg = sg_next(sg)) { |
208 | - desc[i].flags = cpu_to_virtio16(_vq->vdev, VRING_DESC_F_NEXT); | |
209 | - desc[i].addr = cpu_to_virtio64(_vq->vdev, sg_phys(sg)); | |
210 | - desc[i].len = cpu_to_virtio32(_vq->vdev, sg->length); | |
218 | + vring_desc_set(_vq->vdev, desc + i, sg, | |
219 | + VRING_DESC_F_NEXT); | |
211 | 220 | prev = i; |
212 | 221 | i = virtio16_to_cpu(_vq->vdev, desc[i].next); |
213 | 222 | } |
214 | 223 | } |
215 | 224 | for (; n < (out_sgs + in_sgs); n++) { |
216 | 225 | for (sg = sgs[n]; sg; sg = sg_next(sg)) { |
217 | - desc[i].flags = cpu_to_virtio16(_vq->vdev, VRING_DESC_F_NEXT | VRING_DESC_F_WRITE); | |
218 | - desc[i].addr = cpu_to_virtio64(_vq->vdev, sg_phys(sg)); | |
219 | - desc[i].len = cpu_to_virtio32(_vq->vdev, sg->length); | |
226 | + vring_desc_set(_vq->vdev, desc + i, sg, | |
227 | + VRING_DESC_F_NEXT | VRING_DESC_F_WRITE); | |
220 | 228 | prev = i; |
221 | 229 | i = virtio16_to_cpu(_vq->vdev, desc[i].next); |
222 | 230 | } |