Patchwork [02/41] virtio: Teach virtio-blk about DO_UPCAST

login
register
mail settings
Submitter Juan Quintela
Date Dec. 2, 2009, 12:04 p.m.
Message ID <d9bac9ee113374c9eac6998fe2b5f488f373eba0.1259754426.git.quintela@redhat.com>
Download mbox | patch
Permalink /patch/40007/
State New
Headers show

Comments

Juan Quintela - Dec. 2, 2009, 12:04 p.m.
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/virtio-blk.c |   11 +++--------
 1 files changed, 3 insertions(+), 8 deletions(-)

Patch

diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c
index 42b766f..39ebc37 100644
--- a/hw/virtio-blk.c
+++ b/hw/virtio-blk.c
@@ -30,11 +30,6 @@  typedef struct VirtIOBlock
     size_t config_size;
 } VirtIOBlock;

-static VirtIOBlock *to_virtio_blk(VirtIODevice *vdev)
-{
-    return (VirtIOBlock *)vdev;
-}
-
 /* store identify data in little endian format
  */
 static inline void put_le16(uint16_t *p, unsigned int v)
@@ -319,7 +314,7 @@  static void virtio_blk_handle_read(VirtIOBlockReq *req)

 static void virtio_blk_handle_output(VirtIODevice *vdev, VirtQueue *vq)
 {
-    VirtIOBlock *s = to_virtio_blk(vdev);
+    VirtIOBlock *s = DO_UPCAST(VirtIOBlock, vdev, vdev);
     VirtIOBlockReq *req;
     BlockRequest blkreq[32];
     int num_writes = 0;
@@ -409,7 +404,7 @@  static void virtio_blk_reset(VirtIODevice *vdev)
  */
 static void virtio_blk_update_config(VirtIODevice *vdev, uint8_t *config)
 {
-    VirtIOBlock *s = to_virtio_blk(vdev);
+    VirtIOBlock *s = DO_UPCAST(VirtIOBlock, vdev, vdev);
     struct virtio_blk_config blkcfg;
     uint64_t capacity;
     int cylinders, heads, secs;
@@ -431,7 +426,7 @@  static void virtio_blk_update_config(VirtIODevice *vdev, uint8_t *config)

 static uint32_t virtio_blk_get_features(VirtIODevice *vdev)
 {
-    VirtIOBlock *s = to_virtio_blk(vdev);
+    VirtIOBlock *s = DO_UPCAST(VirtIOBlock, vdev, vdev);
     uint32_t features = 0;

     features |= (1 << VIRTIO_BLK_F_SEG_MAX);