From: Jiri Pirko <jiri@xxxxxxxxxx> 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(). Signed-off-by: Jiri Pirko <jiri@xxxxxxxxxx> --- drivers/scsi/virtio_scsi.c | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c index 89ca26945721..416c6820b537 100644 --- a/drivers/scsi/virtio_scsi.c +++ b/drivers/scsi/virtio_scsi.c @@ -841,19 +841,16 @@ static int virtscsi_init(struct virtio_device *vdev, int err; u32 i; u32 num_vqs, num_poll_vqs, num_req_vqs; - vq_callback_t **callbacks; - const char **names; + struct virtio_queue_info *vqs_info; struct virtqueue **vqs; struct irq_affinity desc = { .pre_vectors = 2 }; num_req_vqs = vscsi->num_queues; num_vqs = num_req_vqs + VIRTIO_SCSI_VQ_BASE; vqs = kmalloc_array(num_vqs, sizeof(struct virtqueue *), GFP_KERNEL); - callbacks = kmalloc_array(num_vqs, sizeof(vq_callback_t *), - GFP_KERNEL); - names = kmalloc_array(num_vqs, sizeof(char *), GFP_KERNEL); + vqs_info = kcalloc(num_vqs, sizeof(*vqs_info), GFP_KERNEL); - if (!callbacks || !vqs || !names) { + if (!vqs || !vqs_info) { err = -ENOMEM; goto out; } @@ -869,22 +866,20 @@ static int virtscsi_init(struct virtio_device *vdev, vscsi->io_queues[HCTX_TYPE_READ], vscsi->io_queues[HCTX_TYPE_POLL]); - callbacks[0] = virtscsi_ctrl_done; - callbacks[1] = virtscsi_event_done; - names[0] = "control"; - names[1] = "event"; + vqs_info[0].callback = virtscsi_ctrl_done; + vqs_info[0].name = "control"; + vqs_info[1].callback = virtscsi_event_done; + vqs_info[1].name = "event"; for (i = VIRTIO_SCSI_VQ_BASE; i < num_vqs - num_poll_vqs; i++) { - callbacks[i] = virtscsi_req_done; - names[i] = "request"; + vqs_info[i].callback = virtscsi_req_done; + vqs_info[i].name = "request"; } - for (; i < num_vqs; i++) { - callbacks[i] = NULL; - names[i] = "request_poll"; - } + for (; i < num_vqs; i++) + vqs_info[i].name = "request_poll"; /* Discover virtqueues and write information to configuration. */ - err = virtio_find_vqs(vdev, num_vqs, vqs, callbacks, names, &desc); + err = virtio_find_vqs_info(vdev, num_vqs, vqs, vqs_info, &desc); if (err) goto out; @@ -900,8 +895,7 @@ static int virtscsi_init(struct virtio_device *vdev, err = 0; out: - kfree(names); - kfree(callbacks); + kfree(vqs_info); kfree(vqs); if (err) virtscsi_remove_vqs(vdev); -- 2.45.2