aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael S. Tsirkin <mst@redhat.com>2014-12-11 08:54:07 -0500
committerMichael S. Tsirkin <mst@redhat.com>2014-12-11 13:04:38 -0500
commit3d2667826cbb5e2eb8d8c7ee92f74bcb00b36a2f (patch)
tree1494ba27477b1307d40e7d80ebf41161e43f5ed1
parent30683a8cce8019aa4314c37e629da5c185017166 (diff)
virtio_config: fix virtio_cread_bytes
virtio_cread_bytes is implemented incorrectly in case length happens to be 2,4 or 8 bytes: transports and devices will assume it's an integer value that has to be converted to LE format. Let's just do multiple 1-byte reads: this also makes life easier for transports who only need to implement 1,2,4 and 8 byte reads. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
-rw-r--r--include/linux/virtio_config.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/include/linux/virtio_config.h b/include/linux/virtio_config.h
index 7979f850e7ac..a61cd37f088c 100644
--- a/include/linux/virtio_config.h
+++ b/include/linux/virtio_config.h
@@ -305,7 +305,10 @@ static inline void virtio_cread_bytes(struct virtio_device *vdev,
305 unsigned int offset, 305 unsigned int offset,
306 void *buf, size_t len) 306 void *buf, size_t len)
307{ 307{
308 vdev->config->get(vdev, offset, buf, len); 308 int i;
309
310 for (i = 0; i < len; i++)
311 vdev->config->get(vdev, offset + i, buf + i, 1);
309} 312}
310 313
311static inline void virtio_cwrite8(struct virtio_device *vdev, 314static inline void virtio_cwrite8(struct virtio_device *vdev,