Patchwork [3/9] virtio: Teach virtio-blk about DO_UPCAST

login
register
mail settings
Submitter Juan Quintela
Date March 16, 2010, 6:51 p.m.
Message ID <40b733d50215c872dd4c84f05d56eb6880a7e2bf.1268765204.git.quintela@redhat.com>
Download mbox | patch
Permalink /patch/47892/
State New
Headers show

Comments

Juan Quintela - March 16, 2010, 6:51 p.m.
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/virtio-blk.c |   11 +++--------
 1 files changed, 3 insertions(+), 8 deletions(-)
Michael S. Tsirkin - March 18, 2010, 7:29 a.m.
On Tue, Mar 16, 2010 at 07:51:19PM +0100, Juan Quintela wrote:
> Signed-off-by: Juan Quintela <quintela@redhat.com>


Sent a replacement patch for this.

> ---
>  hw/virtio-blk.c |   11 +++--------
>  1 files changed, 3 insertions(+), 8 deletions(-)
> 
> diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c
> index 8939bb2..ce8b604 100644
> --- a/hw/virtio-blk.c
> +++ b/hw/virtio-blk.c
> @@ -29,11 +29,6 @@ typedef struct VirtIOBlock
>      BlockConf *conf;
>  } VirtIOBlock;
> 
> -static VirtIOBlock *to_virtio_blk(VirtIODevice *vdev)
> -{
> -    return (VirtIOBlock *)vdev;
> -}
> -
>  typedef struct VirtIOBlockReq
>  {
>      VirtIOBlock *dev;
> @@ -320,7 +315,7 @@ static void virtio_blk_handle_request(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;
>      MultiReqBuffer mrb = {
>          .num_writes = 0,
> @@ -392,7 +387,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;
> @@ -415,7 +410,7 @@ static void virtio_blk_update_config(VirtIODevice *vdev, uint8_t *config)
> 
>  static uint32_t virtio_blk_get_features(VirtIODevice *vdev, uint32_t features)
>  {
> -    VirtIOBlock *s = to_virtio_blk(vdev);
> +    VirtIOBlock *s = DO_UPCAST(VirtIOBlock, vdev, vdev);
> 
>      features |= (1 << VIRTIO_BLK_F_SEG_MAX);
>      features |= (1 << VIRTIO_BLK_F_GEOMETRY);
> -- 
> 1.6.6.1
> 
>

Patch

diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c
index 8939bb2..ce8b604 100644
--- a/hw/virtio-blk.c
+++ b/hw/virtio-blk.c
@@ -29,11 +29,6 @@  typedef struct VirtIOBlock
     BlockConf *conf;
 } VirtIOBlock;

-static VirtIOBlock *to_virtio_blk(VirtIODevice *vdev)
-{
-    return (VirtIOBlock *)vdev;
-}
-
 typedef struct VirtIOBlockReq
 {
     VirtIOBlock *dev;
@@ -320,7 +315,7 @@  static void virtio_blk_handle_request(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;
     MultiReqBuffer mrb = {
         .num_writes = 0,
@@ -392,7 +387,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;
@@ -415,7 +410,7 @@  static void virtio_blk_update_config(VirtIODevice *vdev, uint8_t *config)

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

     features |= (1 << VIRTIO_BLK_F_SEG_MAX);
     features |= (1 << VIRTIO_BLK_F_GEOMETRY);