virtio: wrap find_vqs
authorMichael S. Tsirkin <mst@redhat.com>
Mon, 6 Mar 2017 16:19:39 +0000 (18:19 +0200)
committerMichael S. Tsirkin <mst@redhat.com>
Tue, 2 May 2017 20:41:42 +0000 (23:41 +0300)
We are going to add more parameters to find_vqs, let's wrap the call so
we don't need to tweak all drivers every time.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
12 files changed:
drivers/block/virtio_blk.c
drivers/char/virtio_console.c
drivers/crypto/virtio/virtio_crypto_core.c
drivers/gpu/drm/virtio/virtgpu_kms.c
drivers/net/caif/caif_virtio.c
drivers/net/virtio_net.c
drivers/rpmsg/virtio_rpmsg_bus.c
drivers/scsi/virtio_scsi.c
drivers/virtio/virtio_balloon.c
drivers/virtio/virtio_input.c
include/linux/virtio_config.h
net/vmw_vsock/virtio_transport.c

index 1d4c9f8bc1e16e012aba5d98a54b3e0f55e40565..c08c30c35035af8017dc402a1236ca6a54676c6a 100644 (file)
@@ -455,8 +455,7 @@ static int init_vq(struct virtio_blk *vblk)
        }
 
        /* Discover virtqueues and write information to configuration.  */
-       err = vdev->config->find_vqs(vdev, num_vqs, vqs, callbacks, names,
-                       &desc);
+       err = virtio_find_vqs(vdev, num_vqs, vqs, callbacks, names, &desc);
        if (err)
                goto out;
 
index 87fe111d0be6b03ec8157f0a688046d490d7e887..d0699c5fec436b32b370423f08b87b0744fdd079 100644 (file)
@@ -1945,9 +1945,9 @@ static int init_vqs(struct ports_device *portdev)
                }
        }
        /* Find the queues. */
-       err = portdev->vdev->config->find_vqs(portdev->vdev, nr_queues, vqs,
-                                             io_callbacks,
-                                             (const char **)io_names, NULL);
+       err = virtio_find_vqs(portdev->vdev, nr_queues, vqs,
+                             io_callbacks,
+                             (const char **)io_names, NULL);
        if (err)
                goto free;
 
index 21472e427f6fe723f757a83f98c42c2f3ec78d68..a111cd72797b19e8a589ef846101d4589e90e199 100644 (file)
@@ -119,8 +119,7 @@ static int virtcrypto_find_vqs(struct virtio_crypto *vi)
                names[i] = vi->data_vq[i].name;
        }
 
-       ret = vi->vdev->config->find_vqs(vi->vdev, total_vqs, vqs, callbacks,
-                                        names, NULL);
+       ret = virtio_find_vqs(vi->vdev, total_vqs, vqs, callbacks, names, NULL);
        if (ret)
                goto err_find;
 
index 491866865c3397b4c2e73fdfc3444aac301f9ee4..1e1c90b30d4ad9b6cac056169d6f6eea7acede00 100644 (file)
@@ -175,8 +175,7 @@ int virtio_gpu_driver_load(struct drm_device *dev, unsigned long flags)
        DRM_INFO("virgl 3d acceleration not supported by guest\n");
 #endif
 
-       ret = vgdev->vdev->config->find_vqs(vgdev->vdev, 2, vqs,
-                                           callbacks, names, NULL);
+       ret = virtio_find_vqs(vgdev->vdev, 2, vqs, callbacks, names, NULL);
        if (ret) {
                DRM_ERROR("failed to find virt queues\n");
                goto err_vqs;
index bc0eb47ecceea7891c22e309f604ece0b0de9807..6122768c86444ec5b9c5fa67d7a63aa2690ba2f5 100644 (file)
@@ -679,8 +679,7 @@ static int cfv_probe(struct virtio_device *vdev)
                goto err;
 
        /* Get the TX virtio ring. This is a "guest side vring". */
-       err = vdev->config->find_vqs(vdev, 1, &cfv->vq_tx, &vq_cbs, &names,
-                       NULL);
+       err = virtio_find_vqs(vdev, 1, &cfv->vq_tx, &vq_cbs, &names, NULL);
        if (err)
                goto err;
 
index f36584616e7d6825c7e69137b4a31a3d55779688..71f447ab440e4049cc66918aed9472ff180dd0a5 100644 (file)
@@ -2079,8 +2079,7 @@ static int virtnet_find_vqs(struct virtnet_info *vi)
                names[txq2vq(i)] = vi->sq[i].name;
        }
 
-       ret = vi->vdev->config->find_vqs(vi->vdev, total_vqs, vqs, callbacks,
-                                        names, NULL);
+       ret = virtio_find_vqs(vi->vdev, total_vqs, vqs, callbacks, names, NULL);
        if (ret)
                goto err_find;
 
index 5e66e081027e56ce00ac9273752a5c2bc34ea7c6..f7cade09d38a3d3476a14dfef67adba84bfad90f 100644 (file)
@@ -869,7 +869,7 @@ static int rpmsg_probe(struct virtio_device *vdev)
        init_waitqueue_head(&vrp->sendq);
 
        /* We expect two virtqueues, rx and tx (and in this order) */
-       err = vdev->config->find_vqs(vdev, 2, vqs, vq_cbs, names, NULL);
+       err = virtio_find_vqs(vdev, 2, vqs, vq_cbs, names, NULL);
        if (err)
                goto free_vrp;
 
index 939c47df73fa9756faa94fb7eede86a919f1144a..e9222dcb970793832babddbc320f06cd9875ceb1 100644 (file)
@@ -870,8 +870,7 @@ static int virtscsi_init(struct virtio_device *vdev,
        }
 
        /* Discover virtqueues and write information to configuration.  */
-       err = vdev->config->find_vqs(vdev, num_vqs, vqs, callbacks, names,
-                       &desc);
+       err = virtio_find_vqs(vdev, num_vqs, vqs, callbacks, names, &desc);
        if (err)
                goto out;
 
index 34adf9b9c0538815db33f62ed842de49be5222e7..408c174ef0d5c076dc2f51da612b8e0f3dfa8269 100644 (file)
@@ -418,8 +418,7 @@ static int init_vqs(struct virtio_balloon *vb)
         * optionally stat.
         */
        nvqs = virtio_has_feature(vb->vdev, VIRTIO_BALLOON_F_STATS_VQ) ? 3 : 2;
-       err = vb->vdev->config->find_vqs(vb->vdev, nvqs, vqs, callbacks, names,
-                       NULL);
+       err = virtio_find_vqs(vb->vdev, nvqs, vqs, callbacks, names, NULL);
        if (err)
                return err;
 
index 79f1293cda9327a051feef083871bdbc62038496..3a0468f2ceb08a3c4cd3eac033477b8049ebd89d 100644 (file)
@@ -173,8 +173,7 @@ static int virtinput_init_vqs(struct virtio_input *vi)
        static const char * const names[] = { "events", "status" };
        int err;
 
-       err = vi->vdev->config->find_vqs(vi->vdev, 2, vqs, cbs, names,
-                       NULL);
+       err = virtio_find_vqs(vi->vdev, 2, vqs, cbs, names, NULL);
        if (err)
                return err;
        vi->evt = vqs[0];
index 8355bab175e1d8fb27ac9e0860465ba8afc36076..47f3d805c290041a38f30d7dae618f8697cfaee8 100644 (file)
@@ -179,6 +179,15 @@ struct virtqueue *virtio_find_single_vq(struct virtio_device *vdev,
        return vq;
 }
 
+static inline
+int virtio_find_vqs(struct virtio_device *vdev, unsigned nvqs,
+                       struct virtqueue *vqs[], vq_callback_t *callbacks[],
+                       const char * const names[],
+                       struct irq_affinity *desc)
+{
+       return vdev->config->find_vqs(vdev, nvqs, vqs, callbacks, names, desc);
+}
+
 /**
  * virtio_device_ready - enable vq use in probe function
  * @vdev: the device
index 68675a151f22b8b63c02b25a67b833d9a6046d84..97e26e2955e157d05fb3f4f830f1f690b9dda0e7 100644 (file)
@@ -573,9 +573,9 @@ static int virtio_vsock_probe(struct virtio_device *vdev)
 
        vsock->vdev = vdev;
 
-       ret = vsock->vdev->config->find_vqs(vsock->vdev, VSOCK_VQ_MAX,
-                                           vsock->vqs, callbacks, names,
-                                           NULL);
+       ret = virtio_find_vqs(vsock->vdev, VSOCK_VQ_MAX,
+                             vsock->vqs, callbacks, names,
+                             NULL);
        if (ret < 0)
                goto out;