Commit 210a70f2 authored by Jiri Pirko's avatar Jiri Pirko Committed by Michael S. Tsirkin

virtio_crypto: convert to use virtio_find_vqs_info()

Instead of passing separate names and callbacks arrays
to virtio_find_vqs(), allocate one of virtual_queue_info structs and
pass it to virtio_find_vqs_info().
Suggested-by: default avatarXuan Zhuo <xuanzhuo@linux.alibaba.com>
Signed-off-by: default avatarJiri Pirko <jiri@nvidia.com>
Message-Id: <20240708074814.1739223-13-jiri@resnulli.us>
Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
parent cd54c623
...@@ -96,11 +96,10 @@ static void virtcrypto_dataq_callback(struct virtqueue *vq) ...@@ -96,11 +96,10 @@ static void virtcrypto_dataq_callback(struct virtqueue *vq)
static int virtcrypto_find_vqs(struct virtio_crypto *vi) static int virtcrypto_find_vqs(struct virtio_crypto *vi)
{ {
vq_callback_t **callbacks; struct virtqueue_info *vqs_info;
struct virtqueue **vqs; struct virtqueue **vqs;
int ret = -ENOMEM; int ret = -ENOMEM;
int i, total_vqs; int i, total_vqs;
const char **names;
struct device *dev = &vi->vdev->dev; struct device *dev = &vi->vdev->dev;
/* /*
...@@ -114,26 +113,23 @@ static int virtcrypto_find_vqs(struct virtio_crypto *vi) ...@@ -114,26 +113,23 @@ static int virtcrypto_find_vqs(struct virtio_crypto *vi)
vqs = kcalloc(total_vqs, sizeof(*vqs), GFP_KERNEL); vqs = kcalloc(total_vqs, sizeof(*vqs), GFP_KERNEL);
if (!vqs) if (!vqs)
goto err_vq; goto err_vq;
callbacks = kcalloc(total_vqs, sizeof(*callbacks), GFP_KERNEL); vqs_info = kcalloc(total_vqs, sizeof(*vqs_info), GFP_KERNEL);
if (!callbacks) if (!vqs_info)
goto err_callback; goto err_vqs_info;
names = kcalloc(total_vqs, sizeof(*names), GFP_KERNEL);
if (!names)
goto err_names;
/* Parameters for control virtqueue */ /* Parameters for control virtqueue */
callbacks[total_vqs - 1] = virtcrypto_ctrlq_callback; vqs_info[total_vqs - 1].callback = virtcrypto_ctrlq_callback;
names[total_vqs - 1] = "controlq"; vqs_info[total_vqs - 1].name = "controlq";
/* Allocate/initialize parameters for data virtqueues */ /* Allocate/initialize parameters for data virtqueues */
for (i = 0; i < vi->max_data_queues; i++) { for (i = 0; i < vi->max_data_queues; i++) {
callbacks[i] = virtcrypto_dataq_callback; vqs_info[i].callback = virtcrypto_dataq_callback;
snprintf(vi->data_vq[i].name, sizeof(vi->data_vq[i].name), snprintf(vi->data_vq[i].name, sizeof(vi->data_vq[i].name),
"dataq.%d", i); "dataq.%d", i);
names[i] = vi->data_vq[i].name; vqs_info[i].name = vi->data_vq[i].name;
} }
ret = virtio_find_vqs(vi->vdev, total_vqs, vqs, callbacks, names, NULL); ret = virtio_find_vqs_info(vi->vdev, total_vqs, vqs, vqs_info, NULL);
if (ret) if (ret)
goto err_find; goto err_find;
...@@ -153,18 +149,15 @@ static int virtcrypto_find_vqs(struct virtio_crypto *vi) ...@@ -153,18 +149,15 @@ static int virtcrypto_find_vqs(struct virtio_crypto *vi)
(unsigned long)&vi->data_vq[i]); (unsigned long)&vi->data_vq[i]);
} }
kfree(names); kfree(vqs_info);
kfree(callbacks);
kfree(vqs); kfree(vqs);
return 0; return 0;
err_engine: err_engine:
err_find: err_find:
kfree(names); kfree(vqs_info);
err_names: err_vqs_info:
kfree(callbacks);
err_callback:
kfree(vqs); kfree(vqs);
err_vq: err_vq:
return ret; return ret;
......
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