From 77dd7693c52d002d24be6842fb0b766116a6079f Mon Sep 17 00:00:00 2001 From: Sasha Levin Date: Sun, 14 Aug 2011 17:52:33 +0300 Subject: virtio-net: Use virtio_config_val() for retrieving config This patch modifies virtio-net to use virtio_config_val() instead of a 'if(virtio_has_feature()) vdev->config->get()' construct to retrieve optional values from the config space. Cc: Amit Shah Cc: "Michael S. Tsirkin" Cc: Rusty Russell Cc: virtualization@lists.linux-foundation.org Signed-off-by: Sasha Levin Signed-off-by: Rusty Russell --- drivers/net/virtio_net.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'drivers/net/virtio_net.c') diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 91039ab16728..6ee8410443c4 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -925,12 +925,10 @@ static void virtnet_update_status(struct virtnet_info *vi) { u16 v; - if (!virtio_has_feature(vi->vdev, VIRTIO_NET_F_STATUS)) - return; - - vi->vdev->config->get(vi->vdev, + if (virtio_config_val(vi->vdev, VIRTIO_NET_F_STATUS, offsetof(struct virtio_net_config, status), - &v, sizeof(v)); + &v) < 0) + return; /* Ignore unknown (future) status bits */ v &= VIRTIO_NET_S_LINK_UP; @@ -1006,11 +1004,9 @@ static int virtnet_probe(struct virtio_device *vdev) } /* Configuration may specify what MAC to use. Otherwise random. */ - if (virtio_has_feature(vdev, VIRTIO_NET_F_MAC)) { - vdev->config->get(vdev, + if (virtio_config_val_len(vdev, VIRTIO_NET_F_MAC, offsetof(struct virtio_net_config, mac), - dev->dev_addr, dev->addr_len); - } else + dev->dev_addr, dev->addr_len) < 0) random_ether_addr(dev->dev_addr); /* Set up our device-specific information */ -- cgit v1.2.3