diff options
author | Nikunj A Dadhania <nikunj@linux.vnet.ibm.com> | 2016-02-01 11:17:59 +0530 |
---|---|---|
committer | Alexey Kardashevskiy <aik@ozlabs.ru> | 2016-02-08 16:40:38 +1100 |
commit | a936ccce6e0f5e38d0da544c92262c0cac241a02 (patch) | |
tree | c69015937111b29f0f7e6ff8a1adb20a7160b58c /lib/libvirtio/virtio-blk.c | |
parent | fdb62149dc88c8003f1c2273f6becca08629910a (diff) | |
download | SLOF-a936ccce6e0f5e38d0da544c92262c0cac241a02.zip SLOF-a936ccce6e0f5e38d0da544c92262c0cac241a02.tar.gz SLOF-a936ccce6e0f5e38d0da544c92262c0cac241a02.tar.bz2 |
virtio-{net,blk,scsi,9p}: use status variable
The virtio_set_status lines were getting too long because of OR'ing the
status on the same line of the call. Moreover, going forward we need to
add FEATURES_OK status as well. The state progress is quite straight
forward, so use status variable instead. Code looks cleaner and can easily
make out the change in the state.
Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Diffstat (limited to 'lib/libvirtio/virtio-blk.c')
-rw-r--r-- | lib/libvirtio/virtio-blk.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/lib/libvirtio/virtio-blk.c b/lib/libvirtio/virtio-blk.c index d7a3039..26c9685 100644 --- a/lib/libvirtio/virtio-blk.c +++ b/lib/libvirtio/virtio-blk.c @@ -31,32 +31,31 @@ virtioblk_init(struct virtio_device *dev) struct vring_avail *vq_avail; int blk_size = DEFAULT_SECTOR_SIZE; int features; + int status = VIRTIO_STAT_ACKNOWLEDGE; /* Reset device */ virtio_reset_device(dev); /* Acknowledge device. */ - virtio_set_status(dev, VIRTIO_STAT_ACKNOWLEDGE); + virtio_set_status(dev, status); /* Tell HV that we know how to drive the device. */ - virtio_set_status(dev, VIRTIO_STAT_ACKNOWLEDGE|VIRTIO_STAT_DRIVER); + status |= VIRTIO_STAT_DRIVER; + virtio_set_status(dev, status); /* Device specific setup - we support F_BLK_SIZE */ virtio_set_guest_features(dev, VIRTIO_BLK_F_BLK_SIZE); - if (virtio_queue_init_vq(dev, &vq, 0)) { - virtio_set_status(dev, VIRTIO_STAT_ACKNOWLEDGE|VIRTIO_STAT_DRIVER - |VIRTIO_STAT_FAILED); - return 0; - } + if (virtio_queue_init_vq(dev, &vq, 0)) + goto dev_error; vq_avail = virtio_get_vring_avail(dev, 0); vq_avail->flags = VRING_AVAIL_F_NO_INTERRUPT; vq_avail->idx = 0; /* Tell HV that setup succeeded */ - virtio_set_status(dev, VIRTIO_STAT_ACKNOWLEDGE|VIRTIO_STAT_DRIVER - |VIRTIO_STAT_DRIVER_OK); + status |= VIRTIO_STAT_DRIVER_OK; + virtio_set_status(dev, status); virtio_get_host_features(dev, &features); if (features & VIRTIO_BLK_F_BLK_SIZE) { @@ -66,6 +65,11 @@ virtioblk_init(struct virtio_device *dev) } return blk_size; +dev_error: + printf("%s: failed\n", __func__); + status |= VIRTIO_STAT_FAILED; + virtio_set_status(dev, status); + return 0; } |