Commit 9b2bbdb2 authored by Michael S. Tsirkin's avatar Michael S. Tsirkin

virtio: wrap find_vqs

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: default avatarMichael S. Tsirkin <mst@redhat.com>
parent 4f6d9bfc
...@@ -455,8 +455,7 @@ static int init_vq(struct virtio_blk *vblk) ...@@ -455,8 +455,7 @@ static int init_vq(struct virtio_blk *vblk)
} }
/* Discover virtqueues and write information to configuration. */ /* Discover virtqueues and write information to configuration. */
err = vdev->config->find_vqs(vdev, num_vqs, vqs, callbacks, names, err = virtio_find_vqs(vdev, num_vqs, vqs, callbacks, names, &desc);
&desc);
if (err) if (err)
goto out; goto out;
......
...@@ -1945,9 +1945,9 @@ static int init_vqs(struct ports_device *portdev) ...@@ -1945,9 +1945,9 @@ static int init_vqs(struct ports_device *portdev)
} }
} }
/* Find the queues. */ /* Find the queues. */
err = portdev->vdev->config->find_vqs(portdev->vdev, nr_queues, vqs, err = virtio_find_vqs(portdev->vdev, nr_queues, vqs,
io_callbacks, io_callbacks,
(const char **)io_names, NULL); (const char **)io_names, NULL);
if (err) if (err)
goto free; goto free;
......
...@@ -119,8 +119,7 @@ static int virtcrypto_find_vqs(struct virtio_crypto *vi) ...@@ -119,8 +119,7 @@ static int virtcrypto_find_vqs(struct virtio_crypto *vi)
names[i] = vi->data_vq[i].name; names[i] = vi->data_vq[i].name;
} }
ret = vi->vdev->config->find_vqs(vi->vdev, total_vqs, vqs, callbacks, ret = virtio_find_vqs(vi->vdev, total_vqs, vqs, callbacks, names, NULL);
names, NULL);
if (ret) if (ret)
goto err_find; goto err_find;
......
...@@ -175,8 +175,7 @@ int virtio_gpu_driver_load(struct drm_device *dev, unsigned long flags) ...@@ -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"); DRM_INFO("virgl 3d acceleration not supported by guest\n");
#endif #endif
ret = vgdev->vdev->config->find_vqs(vgdev->vdev, 2, vqs, ret = virtio_find_vqs(vgdev->vdev, 2, vqs, callbacks, names, NULL);
callbacks, names, NULL);
if (ret) { if (ret) {
DRM_ERROR("failed to find virt queues\n"); DRM_ERROR("failed to find virt queues\n");
goto err_vqs; goto err_vqs;
......
...@@ -679,8 +679,7 @@ static int cfv_probe(struct virtio_device *vdev) ...@@ -679,8 +679,7 @@ static int cfv_probe(struct virtio_device *vdev)
goto err; goto err;
/* Get the TX virtio ring. This is a "guest side vring". */ /* Get the TX virtio ring. This is a "guest side vring". */
err = vdev->config->find_vqs(vdev, 1, &cfv->vq_tx, &vq_cbs, &names, err = virtio_find_vqs(vdev, 1, &cfv->vq_tx, &vq_cbs, &names, NULL);
NULL);
if (err) if (err)
goto err; goto err;
......
...@@ -2079,8 +2079,7 @@ static int virtnet_find_vqs(struct virtnet_info *vi) ...@@ -2079,8 +2079,7 @@ static int virtnet_find_vqs(struct virtnet_info *vi)
names[txq2vq(i)] = vi->sq[i].name; names[txq2vq(i)] = vi->sq[i].name;
} }
ret = vi->vdev->config->find_vqs(vi->vdev, total_vqs, vqs, callbacks, ret = virtio_find_vqs(vi->vdev, total_vqs, vqs, callbacks, names, NULL);
names, NULL);
if (ret) if (ret)
goto err_find; goto err_find;
......
...@@ -869,7 +869,7 @@ static int rpmsg_probe(struct virtio_device *vdev) ...@@ -869,7 +869,7 @@ static int rpmsg_probe(struct virtio_device *vdev)
init_waitqueue_head(&vrp->sendq); init_waitqueue_head(&vrp->sendq);
/* We expect two virtqueues, rx and tx (and in this order) */ /* 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) if (err)
goto free_vrp; goto free_vrp;
......
...@@ -870,8 +870,7 @@ static int virtscsi_init(struct virtio_device *vdev, ...@@ -870,8 +870,7 @@ static int virtscsi_init(struct virtio_device *vdev,
} }
/* Discover virtqueues and write information to configuration. */ /* Discover virtqueues and write information to configuration. */
err = vdev->config->find_vqs(vdev, num_vqs, vqs, callbacks, names, err = virtio_find_vqs(vdev, num_vqs, vqs, callbacks, names, &desc);
&desc);
if (err) if (err)
goto out; goto out;
......
...@@ -418,8 +418,7 @@ static int init_vqs(struct virtio_balloon *vb) ...@@ -418,8 +418,7 @@ static int init_vqs(struct virtio_balloon *vb)
* optionally stat. * optionally stat.
*/ */
nvqs = virtio_has_feature(vb->vdev, VIRTIO_BALLOON_F_STATS_VQ) ? 3 : 2; 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, err = virtio_find_vqs(vb->vdev, nvqs, vqs, callbacks, names, NULL);
NULL);
if (err) if (err)
return err; return err;
......
...@@ -173,8 +173,7 @@ static int virtinput_init_vqs(struct virtio_input *vi) ...@@ -173,8 +173,7 @@ static int virtinput_init_vqs(struct virtio_input *vi)
static const char * const names[] = { "events", "status" }; static const char * const names[] = { "events", "status" };
int err; int err;
err = vi->vdev->config->find_vqs(vi->vdev, 2, vqs, cbs, names, err = virtio_find_vqs(vi->vdev, 2, vqs, cbs, names, NULL);
NULL);
if (err) if (err)
return err; return err;
vi->evt = vqs[0]; vi->evt = vqs[0];
......
...@@ -179,6 +179,15 @@ struct virtqueue *virtio_find_single_vq(struct virtio_device *vdev, ...@@ -179,6 +179,15 @@ struct virtqueue *virtio_find_single_vq(struct virtio_device *vdev,
return vq; 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 * virtio_device_ready - enable vq use in probe function
* @vdev: the device * @vdev: the device
......
...@@ -573,9 +573,9 @@ static int virtio_vsock_probe(struct virtio_device *vdev) ...@@ -573,9 +573,9 @@ static int virtio_vsock_probe(struct virtio_device *vdev)
vsock->vdev = vdev; vsock->vdev = vdev;
ret = vsock->vdev->config->find_vqs(vsock->vdev, VSOCK_VQ_MAX, ret = virtio_find_vqs(vsock->vdev, VSOCK_VQ_MAX,
vsock->vqs, callbacks, names, vsock->vqs, callbacks, names,
NULL); NULL);
if (ret < 0) if (ret < 0)
goto out; goto out;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment