aboutsummaryrefslogtreecommitdiff
path: root/hw/virtio/virtio.c
diff options
context:
space:
mode:
authorKONRAD Frederic <fred.konrad@greensocs.com>2013-04-24 10:21:20 +0200
committerAnthony Liguori <aliguori@us.ibm.com>2013-04-24 11:50:20 -0500
commit181103cd52710b987799ae980bb92407994243bc (patch)
tree9442542631a8ef1920719cfaddebad25a7d17c0a /hw/virtio/virtio.c
parenta2f1078b70b6cfc98ed795f17f9d975b1dec1f65 (diff)
downloadqemu-181103cd52710b987799ae980bb92407994243bc.zip
qemu-181103cd52710b987799ae980bb92407994243bc.tar.gz
qemu-181103cd52710b987799ae980bb92407994243bc.tar.bz2
virtio: remove the function pointer.
This remove the function pointer in VirtIODevice, and use only VirtioDeviceClass function pointer. Signed-off-by: KONRAD Frederic <fred.konrad@greensocs.com> Message-id: 1366791683-5350-5-git-send-email-fred.konrad@greensocs.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw/virtio/virtio.c')
-rw-r--r--hw/virtio/virtio.c43
1 files changed, 28 insertions, 15 deletions
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index 1c2282c..de54b41 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -519,10 +519,11 @@ void virtio_update_irq(VirtIODevice *vdev)
void virtio_set_status(VirtIODevice *vdev, uint8_t val)
{
+ VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev);
trace_virtio_set_status(vdev, val);
- if (vdev->set_status) {
- vdev->set_status(vdev, val);
+ if (k->set_status) {
+ k->set_status(vdev, val);
}
vdev->status = val;
}
@@ -530,12 +531,14 @@ void virtio_set_status(VirtIODevice *vdev, uint8_t val)
void virtio_reset(void *opaque)
{
VirtIODevice *vdev = opaque;
+ VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev);
int i;
virtio_set_status(vdev, 0);
- if (vdev->reset)
- vdev->reset(vdev);
+ if (k->reset) {
+ k->reset(vdev);
+ }
vdev->guest_features = 0;
vdev->queue_sel = 0;
@@ -559,9 +562,10 @@ void virtio_reset(void *opaque)
uint32_t virtio_config_readb(VirtIODevice *vdev, uint32_t addr)
{
+ VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev);
uint8_t val;
- vdev->get_config(vdev, vdev->config);
+ k->get_config(vdev, vdev->config);
if (addr > (vdev->config_len - sizeof(val)))
return (uint32_t)-1;
@@ -572,9 +576,10 @@ uint32_t virtio_config_readb(VirtIODevice *vdev, uint32_t addr)
uint32_t virtio_config_readw(VirtIODevice *vdev, uint32_t addr)
{
+ VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev);
uint16_t val;
- vdev->get_config(vdev, vdev->config);
+ k->get_config(vdev, vdev->config);
if (addr > (vdev->config_len - sizeof(val)))
return (uint32_t)-1;
@@ -585,9 +590,10 @@ uint32_t virtio_config_readw(VirtIODevice *vdev, uint32_t addr)
uint32_t virtio_config_readl(VirtIODevice *vdev, uint32_t addr)
{
+ VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev);
uint32_t val;
- vdev->get_config(vdev, vdev->config);
+ k->get_config(vdev, vdev->config);
if (addr > (vdev->config_len - sizeof(val)))
return (uint32_t)-1;
@@ -598,6 +604,7 @@ uint32_t virtio_config_readl(VirtIODevice *vdev, uint32_t addr)
void virtio_config_writeb(VirtIODevice *vdev, uint32_t addr, uint32_t data)
{
+ VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev);
uint8_t val = data;
if (addr > (vdev->config_len - sizeof(val)))
@@ -605,12 +612,14 @@ void virtio_config_writeb(VirtIODevice *vdev, uint32_t addr, uint32_t data)
stb_p(vdev->config + addr, val);
- if (vdev->set_config)
- vdev->set_config(vdev, vdev->config);
+ if (k->set_config) {
+ k->set_config(vdev, vdev->config);
+ }
}
void virtio_config_writew(VirtIODevice *vdev, uint32_t addr, uint32_t data)
{
+ VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev);
uint16_t val = data;
if (addr > (vdev->config_len - sizeof(val)))
@@ -618,12 +627,14 @@ void virtio_config_writew(VirtIODevice *vdev, uint32_t addr, uint32_t data)
stw_p(vdev->config + addr, val);
- if (vdev->set_config)
- vdev->set_config(vdev, vdev->config);
+ if (k->set_config) {
+ k->set_config(vdev, vdev->config);
+ }
}
void virtio_config_writel(VirtIODevice *vdev, uint32_t addr, uint32_t data)
{
+ VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev);
uint32_t val = data;
if (addr > (vdev->config_len - sizeof(val)))
@@ -631,8 +642,9 @@ void virtio_config_writel(VirtIODevice *vdev, uint32_t addr, uint32_t data)
stl_p(vdev->config + addr, val);
- if (vdev->set_config)
- vdev->set_config(vdev, vdev->config);
+ if (k->set_config) {
+ k->set_config(vdev, vdev->config);
+ }
}
void virtio_queue_set_addr(VirtIODevice *vdev, int n, hwaddr addr)
@@ -810,13 +822,14 @@ void virtio_save(VirtIODevice *vdev, QEMUFile *f)
int virtio_set_features(VirtIODevice *vdev, uint32_t val)
{
+ VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev);
uint32_t supported_features =
vdev->binding->get_features(vdev->binding_opaque);
bool bad = (val & ~supported_features) != 0;
val &= supported_features;
- if (vdev->set_features) {
- vdev->set_features(vdev, val);
+ if (k->set_features) {
+ k->set_features(vdev, val);
}
vdev->guest_features = val;
return bad ? -1 : 0;