virtio: convert the rest virtio_find_vqs() users to virtio_find_vqs_info()
Instead of passing separate names and callbacks arrays to virtio_find_vqs(), have one of virtual_queue_info structs and pass it to virtio_find_vqs_info(). Suggested-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com> Signed-off-by: Jiri Pirko <jiri@nvidia.com> Message-Id: <20240708074814.1739223-18-jiri@resnulli.us> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
7221922da2
commit
c95e67bac4
@ -567,12 +567,14 @@ struct device_node *pcibios_get_phb_of_node(struct pci_bus *bus)
|
|||||||
|
|
||||||
static int um_pci_init_vqs(struct um_pci_device *dev)
|
static int um_pci_init_vqs(struct um_pci_device *dev)
|
||||||
{
|
{
|
||||||
|
struct virtqueue_info vqs_info[] = {
|
||||||
|
{ "cmd", um_pci_cmd_vq_cb },
|
||||||
|
{ "irq", um_pci_irq_vq_cb },
|
||||||
|
};
|
||||||
struct virtqueue *vqs[2];
|
struct virtqueue *vqs[2];
|
||||||
static const char *const names[2] = { "cmd", "irq" };
|
|
||||||
vq_callback_t *cbs[2] = { um_pci_cmd_vq_cb, um_pci_irq_vq_cb };
|
|
||||||
int err, i;
|
int err, i;
|
||||||
|
|
||||||
err = virtio_find_vqs(dev->vdev, 2, vqs, cbs, names, NULL);
|
err = virtio_find_vqs_info(dev->vdev, 2, vqs, vqs_info, NULL);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
|
@ -254,13 +254,9 @@ static void virtbt_rx_done(struct virtqueue *vq)
|
|||||||
|
|
||||||
static int virtbt_probe(struct virtio_device *vdev)
|
static int virtbt_probe(struct virtio_device *vdev)
|
||||||
{
|
{
|
||||||
vq_callback_t *callbacks[VIRTBT_NUM_VQS] = {
|
struct virtqueue_info vqs_info[VIRTBT_NUM_VQS] = {
|
||||||
[VIRTBT_VQ_TX] = virtbt_tx_done,
|
[VIRTBT_VQ_TX] = { "tx", virtbt_tx_done },
|
||||||
[VIRTBT_VQ_RX] = virtbt_rx_done,
|
[VIRTBT_VQ_RX] = { "rx", virtbt_rx_done },
|
||||||
};
|
|
||||||
const char *names[VIRTBT_NUM_VQS] = {
|
|
||||||
[VIRTBT_VQ_TX] = "tx",
|
|
||||||
[VIRTBT_VQ_RX] = "rx",
|
|
||||||
};
|
};
|
||||||
struct virtio_bluetooth *vbt;
|
struct virtio_bluetooth *vbt;
|
||||||
struct hci_dev *hdev;
|
struct hci_dev *hdev;
|
||||||
@ -288,8 +284,8 @@ static int virtbt_probe(struct virtio_device *vdev)
|
|||||||
|
|
||||||
INIT_WORK(&vbt->rx, virtbt_rx_work);
|
INIT_WORK(&vbt->rx, virtbt_rx_work);
|
||||||
|
|
||||||
err = virtio_find_vqs(vdev, VIRTBT_NUM_VQS, vbt->vqs, callbacks,
|
err = virtio_find_vqs_info(vdev, VIRTBT_NUM_VQS, vbt->vqs,
|
||||||
names, NULL);
|
vqs_info, NULL);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
|
@ -354,11 +354,9 @@ static void scmi_vio_deferred_tx_worker(struct work_struct *work)
|
|||||||
scmi_vio_channel_release(vioch);
|
scmi_vio_channel_release(vioch);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *const scmi_vio_vqueue_names[] = { "tx", "rx" };
|
static struct virtqueue_info scmi_vio_vqs_info[] = {
|
||||||
|
{ "tx", scmi_vio_complete_cb },
|
||||||
static vq_callback_t *scmi_vio_complete_callbacks[] = {
|
{ "rx", scmi_vio_complete_cb },
|
||||||
scmi_vio_complete_cb,
|
|
||||||
scmi_vio_complete_cb
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static unsigned int virtio_get_max_msg(struct scmi_chan_info *base_cinfo)
|
static unsigned int virtio_get_max_msg(struct scmi_chan_info *base_cinfo)
|
||||||
@ -831,8 +829,7 @@ static int scmi_vio_probe(struct virtio_device *vdev)
|
|||||||
if (have_vq_rx)
|
if (have_vq_rx)
|
||||||
channels[VIRTIO_SCMI_VQ_RX].is_rx = true;
|
channels[VIRTIO_SCMI_VQ_RX].is_rx = true;
|
||||||
|
|
||||||
ret = virtio_find_vqs(vdev, vq_cnt, vqs, scmi_vio_complete_callbacks,
|
ret = virtio_find_vqs_info(vdev, vq_cnt, vqs, scmi_vio_vqs_info, NULL);
|
||||||
scmi_vio_vqueue_names, NULL);
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(dev, "Failed to get %d virtqueue(s)\n", vq_cnt);
|
dev_err(dev, "Failed to get %d virtqueue(s)\n", vq_cnt);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -457,15 +457,15 @@ static void virtio_gpio_free_vqs(struct virtio_device *vdev)
|
|||||||
static int virtio_gpio_alloc_vqs(struct virtio_gpio *vgpio,
|
static int virtio_gpio_alloc_vqs(struct virtio_gpio *vgpio,
|
||||||
struct virtio_device *vdev)
|
struct virtio_device *vdev)
|
||||||
{
|
{
|
||||||
const char * const names[] = { "requestq", "eventq" };
|
struct virtqueue_info vqs_info[] = {
|
||||||
vq_callback_t *cbs[] = {
|
{ "requestq", virtio_gpio_request_vq },
|
||||||
virtio_gpio_request_vq,
|
{ "eventq", virtio_gpio_event_vq },
|
||||||
virtio_gpio_event_vq,
|
|
||||||
};
|
};
|
||||||
struct virtqueue *vqs[2] = { NULL, NULL };
|
struct virtqueue *vqs[2] = { NULL, NULL };
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = virtio_find_vqs(vdev, vgpio->irq_lines ? 2 : 1, vqs, cbs, names, NULL);
|
ret = virtio_find_vqs_info(vdev, vgpio->irq_lines ? 2 : 1, vqs,
|
||||||
|
vqs_info, NULL);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(&vdev->dev, "failed to find vqs: %d\n", ret);
|
dev_err(&vdev->dev, "failed to find vqs: %d\n", ret);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -116,11 +116,10 @@ static void virtio_gpu_get_capsets(struct virtio_gpu_device *vgdev,
|
|||||||
|
|
||||||
int virtio_gpu_init(struct virtio_device *vdev, struct drm_device *dev)
|
int virtio_gpu_init(struct virtio_device *vdev, struct drm_device *dev)
|
||||||
{
|
{
|
||||||
static vq_callback_t *callbacks[] = {
|
struct virtqueue_info vqs_info[] = {
|
||||||
virtio_gpu_ctrl_ack, virtio_gpu_cursor_ack
|
{ "control", virtio_gpu_ctrl_ack },
|
||||||
|
{ "cursor", virtio_gpu_cursor_ack },
|
||||||
};
|
};
|
||||||
static const char * const names[] = { "control", "cursor" };
|
|
||||||
|
|
||||||
struct virtio_gpu_device *vgdev;
|
struct virtio_gpu_device *vgdev;
|
||||||
/* this will expand later */
|
/* this will expand later */
|
||||||
struct virtqueue *vqs[2];
|
struct virtqueue *vqs[2];
|
||||||
@ -207,7 +206,7 @@ int virtio_gpu_init(struct virtio_device *vdev, struct drm_device *dev)
|
|||||||
DRM_INFO("features: %ccontext_init\n",
|
DRM_INFO("features: %ccontext_init\n",
|
||||||
vgdev->has_context_init ? '+' : '-');
|
vgdev->has_context_init ? '+' : '-');
|
||||||
|
|
||||||
ret = virtio_find_vqs(vgdev->vdev, 2, vqs, callbacks, names, NULL);
|
ret = virtio_find_vqs_info(vgdev->vdev, 2, vqs, vqs_info, 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;
|
||||||
|
@ -1084,14 +1084,13 @@ static struct iommu_ops viommu_ops = {
|
|||||||
static int viommu_init_vqs(struct viommu_dev *viommu)
|
static int viommu_init_vqs(struct viommu_dev *viommu)
|
||||||
{
|
{
|
||||||
struct virtio_device *vdev = dev_to_virtio(viommu->dev);
|
struct virtio_device *vdev = dev_to_virtio(viommu->dev);
|
||||||
const char *names[] = { "request", "event" };
|
struct virtqueue_info vqs_info[] = {
|
||||||
vq_callback_t *callbacks[] = {
|
{ "request" },
|
||||||
NULL, /* No async requests */
|
{ "event", viommu_event_handler },
|
||||||
viommu_event_handler,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return virtio_find_vqs(vdev, VIOMMU_NR_VQS, viommu->vqs, callbacks,
|
return virtio_find_vqs_info(vdev, VIOMMU_NR_VQS, viommu->vqs,
|
||||||
names, NULL);
|
vqs_info, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int viommu_fill_evtq(struct viommu_dev *viommu)
|
static int viommu_fill_evtq(struct viommu_dev *viommu)
|
||||||
|
@ -6574,17 +6574,13 @@ static void hwsim_virtio_rx_done(struct virtqueue *vq)
|
|||||||
|
|
||||||
static int init_vqs(struct virtio_device *vdev)
|
static int init_vqs(struct virtio_device *vdev)
|
||||||
{
|
{
|
||||||
vq_callback_t *callbacks[HWSIM_NUM_VQS] = {
|
struct virtqueue_info vqs_info[HWSIM_NUM_VQS] = {
|
||||||
[HWSIM_VQ_TX] = hwsim_virtio_tx_done,
|
[HWSIM_VQ_TX] = { "tx", hwsim_virtio_tx_done },
|
||||||
[HWSIM_VQ_RX] = hwsim_virtio_rx_done,
|
[HWSIM_VQ_RX] = { "rx", hwsim_virtio_rx_done },
|
||||||
};
|
|
||||||
const char *names[HWSIM_NUM_VQS] = {
|
|
||||||
[HWSIM_VQ_TX] = "tx",
|
|
||||||
[HWSIM_VQ_RX] = "rx",
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return virtio_find_vqs(vdev, HWSIM_NUM_VQS,
|
return virtio_find_vqs_info(vdev, HWSIM_NUM_VQS,
|
||||||
hwsim_vqs, callbacks, names, NULL);
|
hwsim_vqs, vqs_info, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int fill_vq(struct virtqueue *vq)
|
static int fill_vq(struct virtqueue *vq)
|
||||||
|
@ -868,8 +868,10 @@ static void rpmsg_virtio_del_ctrl_dev(struct rpmsg_device *rpdev_ctrl)
|
|||||||
|
|
||||||
static int rpmsg_probe(struct virtio_device *vdev)
|
static int rpmsg_probe(struct virtio_device *vdev)
|
||||||
{
|
{
|
||||||
vq_callback_t *vq_cbs[] = { rpmsg_recv_done, rpmsg_xmit_done };
|
struct virtqueue_info vqs_info[] = {
|
||||||
static const char * const names[] = { "input", "output" };
|
{ "input", rpmsg_recv_done },
|
||||||
|
{ "output", rpmsg_xmit_done },
|
||||||
|
};
|
||||||
struct virtqueue *vqs[2];
|
struct virtqueue *vqs[2];
|
||||||
struct virtproc_info *vrp;
|
struct virtproc_info *vrp;
|
||||||
struct virtio_rpmsg_channel *vch = NULL;
|
struct virtio_rpmsg_channel *vch = NULL;
|
||||||
@ -891,7 +893,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 = virtio_find_vqs(vdev, 2, vqs, vq_cbs, names, NULL);
|
err = virtio_find_vqs_info(vdev, 2, vqs, vqs_info, NULL);
|
||||||
if (err)
|
if (err)
|
||||||
goto free_vrp;
|
goto free_vrp;
|
||||||
|
|
||||||
|
@ -185,13 +185,14 @@ static void virtinput_cfg_abs(struct virtio_input *vi, int abs)
|
|||||||
|
|
||||||
static int virtinput_init_vqs(struct virtio_input *vi)
|
static int virtinput_init_vqs(struct virtio_input *vi)
|
||||||
{
|
{
|
||||||
|
struct virtqueue_info vqs_info[] = {
|
||||||
|
{ "events", virtinput_recv_events },
|
||||||
|
{ "status", virtinput_recv_status },
|
||||||
|
};
|
||||||
struct virtqueue *vqs[2];
|
struct virtqueue *vqs[2];
|
||||||
vq_callback_t *cbs[] = { virtinput_recv_events,
|
|
||||||
virtinput_recv_status };
|
|
||||||
static const char * const names[] = { "events", "status" };
|
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
err = virtio_find_vqs(vi->vdev, 2, vqs, cbs, names, NULL);
|
err = virtio_find_vqs_info(vi->vdev, 2, vqs, vqs_info, NULL);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
vi->evt = vqs[0];
|
vi->evt = vqs[0];
|
||||||
|
@ -617,20 +617,15 @@ out:
|
|||||||
static int virtio_vsock_vqs_init(struct virtio_vsock *vsock)
|
static int virtio_vsock_vqs_init(struct virtio_vsock *vsock)
|
||||||
{
|
{
|
||||||
struct virtio_device *vdev = vsock->vdev;
|
struct virtio_device *vdev = vsock->vdev;
|
||||||
static const char * const names[] = {
|
struct virtqueue_info vqs_info[] = {
|
||||||
"rx",
|
{ "rx", virtio_vsock_rx_done },
|
||||||
"tx",
|
{ "tx", virtio_vsock_tx_done },
|
||||||
"event",
|
{ "event", virtio_vsock_event_done },
|
||||||
};
|
|
||||||
vq_callback_t *callbacks[] = {
|
|
||||||
virtio_vsock_rx_done,
|
|
||||||
virtio_vsock_tx_done,
|
|
||||||
virtio_vsock_event_done,
|
|
||||||
};
|
};
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = virtio_find_vqs(vdev, VSOCK_VQ_MAX, vsock->vqs, callbacks, names,
|
ret = virtio_find_vqs_info(vdev, VSOCK_VQ_MAX, vsock->vqs, vqs_info,
|
||||||
NULL);
|
NULL);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
@ -110,25 +110,22 @@ static void virtsnd_event_notify_cb(struct virtqueue *vqueue)
|
|||||||
static int virtsnd_find_vqs(struct virtio_snd *snd)
|
static int virtsnd_find_vqs(struct virtio_snd *snd)
|
||||||
{
|
{
|
||||||
struct virtio_device *vdev = snd->vdev;
|
struct virtio_device *vdev = snd->vdev;
|
||||||
static vq_callback_t *callbacks[VIRTIO_SND_VQ_MAX] = {
|
struct virtqueue_info vqs_info[VIRTIO_SND_VQ_MAX] = {
|
||||||
[VIRTIO_SND_VQ_CONTROL] = virtsnd_ctl_notify_cb,
|
[VIRTIO_SND_VQ_CONTROL] = { "virtsnd-ctl",
|
||||||
[VIRTIO_SND_VQ_EVENT] = virtsnd_event_notify_cb,
|
virtsnd_ctl_notify_cb },
|
||||||
[VIRTIO_SND_VQ_TX] = virtsnd_pcm_tx_notify_cb,
|
[VIRTIO_SND_VQ_EVENT] = { "virtsnd-event",
|
||||||
[VIRTIO_SND_VQ_RX] = virtsnd_pcm_rx_notify_cb
|
virtsnd_event_notify_cb },
|
||||||
};
|
[VIRTIO_SND_VQ_TX] = { "virtsnd-tx",
|
||||||
static const char *names[VIRTIO_SND_VQ_MAX] = {
|
virtsnd_pcm_tx_notify_cb },
|
||||||
[VIRTIO_SND_VQ_CONTROL] = "virtsnd-ctl",
|
[VIRTIO_SND_VQ_RX] = { "virtsnd-rx",
|
||||||
[VIRTIO_SND_VQ_EVENT] = "virtsnd-event",
|
virtsnd_pcm_rx_notify_cb },
|
||||||
[VIRTIO_SND_VQ_TX] = "virtsnd-tx",
|
|
||||||
[VIRTIO_SND_VQ_RX] = "virtsnd-rx"
|
|
||||||
};
|
};
|
||||||
struct virtqueue *vqs[VIRTIO_SND_VQ_MAX] = { 0 };
|
struct virtqueue *vqs[VIRTIO_SND_VQ_MAX] = { 0 };
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
unsigned int n;
|
unsigned int n;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
rc = virtio_find_vqs(vdev, VIRTIO_SND_VQ_MAX, vqs, callbacks, names,
|
rc = virtio_find_vqs_info(vdev, VIRTIO_SND_VQ_MAX, vqs, vqs_info, NULL);
|
||||||
NULL);
|
|
||||||
if (rc) {
|
if (rc) {
|
||||||
dev_err(&vdev->dev, "failed to initialize virtqueues\n");
|
dev_err(&vdev->dev, "failed to initialize virtqueues\n");
|
||||||
return rc;
|
return rc;
|
||||||
|
Loading…
Reference in New Issue
Block a user