Patchwork [PATCHv2,5/5] virtio-blk: remove layout assumption

login
register
mail settings
Submitter Michael S. Tsirkin
Date March 18, 2010, 9:42 a.m.
Message ID <2dcc2f1126686553a64d0a3c0ba82ded54a3e08f.1268905075.git.mst@redhat.com>
Download mbox | patch
Permalink /patch/48018/
State New
Headers show

Comments

Michael S. Tsirkin - March 18, 2010, 9:42 a.m.
Use container_of to remove assumption that vdev
is 1st member of device state.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 hw/virtio-blk.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Patch

diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c
index 5f61469..ab52d1d 100644
--- a/hw/virtio-blk.c
+++ b/hw/virtio-blk.c
@@ -32,7 +32,7 @@  typedef struct VirtIOBlock
 
 static VirtIOBlock *to_virtio_blk(VirtIODevice *vdev)
 {
-    return (VirtIOBlock *)vdev;
+    return container_of(vdev, VirtIOBlock, vdev);
 }
 
 typedef struct VirtIOBlockReq