summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorJiri Pirko <jiri@nvidia.com>2024-07-08 09:48:12 +0200
committerMichael S. Tsirkin <mst@redhat.com>2024-07-17 05:20:58 -0400
commitc95e67bac42d7e671e6a2c14548b6a7f76e71235 (patch)
treef0fc2e0608f068a3f99dd700850554baa968a4f5 /drivers
parent7221922da2a1eb8bbc8d6570cec1197c8f484517 (diff)
downloadlwn-c95e67bac42d7e671e6a2c14548b6a7f76e71235.tar.gz
lwn-c95e67bac42d7e671e6a2c14548b6a7f76e71235.zip
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>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/bluetooth/virtio_bt.c14
-rw-r--r--drivers/firmware/arm_scmi/virtio.c11
-rw-r--r--drivers/gpio/gpio-virtio.c10
-rw-r--r--drivers/gpu/drm/virtio/virtgpu_kms.c9
-rw-r--r--drivers/iommu/virtio-iommu.c11
-rw-r--r--drivers/net/wireless/virtual/mac80211_hwsim.c14
-rw-r--r--drivers/rpmsg/virtio_rpmsg_bus.c8
-rw-r--r--drivers/virtio/virtio_input.c9
8 files changed, 38 insertions, 48 deletions
diff --git a/drivers/bluetooth/virtio_bt.c b/drivers/bluetooth/virtio_bt.c
index 40bd83825c29..79574855ed54 100644
--- a/drivers/bluetooth/virtio_bt.c
+++ b/drivers/bluetooth/virtio_bt.c
@@ -254,13 +254,9 @@ static void virtbt_rx_done(struct virtqueue *vq)
static int virtbt_probe(struct virtio_device *vdev)
{
- vq_callback_t *callbacks[VIRTBT_NUM_VQS] = {
- [VIRTBT_VQ_TX] = virtbt_tx_done,
- [VIRTBT_VQ_RX] = virtbt_rx_done,
- };
- const char *names[VIRTBT_NUM_VQS] = {
- [VIRTBT_VQ_TX] = "tx",
- [VIRTBT_VQ_RX] = "rx",
+ struct virtqueue_info vqs_info[VIRTBT_NUM_VQS] = {
+ [VIRTBT_VQ_TX] = { "tx", virtbt_tx_done },
+ [VIRTBT_VQ_RX] = { "rx", virtbt_rx_done },
};
struct virtio_bluetooth *vbt;
struct hci_dev *hdev;
@@ -288,8 +284,8 @@ static int virtbt_probe(struct virtio_device *vdev)
INIT_WORK(&vbt->rx, virtbt_rx_work);
- err = virtio_find_vqs(vdev, VIRTBT_NUM_VQS, vbt->vqs, callbacks,
- names, NULL);
+ err = virtio_find_vqs_info(vdev, VIRTBT_NUM_VQS, vbt->vqs,
+ vqs_info, NULL);
if (err)
return err;
diff --git a/drivers/firmware/arm_scmi/virtio.c b/drivers/firmware/arm_scmi/virtio.c
index 4892058445ce..d7cdefb6bd54 100644
--- a/drivers/firmware/arm_scmi/virtio.c
+++ b/drivers/firmware/arm_scmi/virtio.c
@@ -354,11 +354,9 @@ static void scmi_vio_deferred_tx_worker(struct work_struct *work)
scmi_vio_channel_release(vioch);
}
-static const char *const scmi_vio_vqueue_names[] = { "tx", "rx" };
-
-static vq_callback_t *scmi_vio_complete_callbacks[] = {
- scmi_vio_complete_cb,
- scmi_vio_complete_cb
+static struct virtqueue_info scmi_vio_vqs_info[] = {
+ { "tx", scmi_vio_complete_cb },
+ { "rx", scmi_vio_complete_cb },
};
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)
channels[VIRTIO_SCMI_VQ_RX].is_rx = true;
- ret = virtio_find_vqs(vdev, vq_cnt, vqs, scmi_vio_complete_callbacks,
- scmi_vio_vqueue_names, NULL);
+ ret = virtio_find_vqs_info(vdev, vq_cnt, vqs, scmi_vio_vqs_info, NULL);
if (ret) {
dev_err(dev, "Failed to get %d virtqueue(s)\n", vq_cnt);
return ret;
diff --git a/drivers/gpio/gpio-virtio.c b/drivers/gpio/gpio-virtio.c
index 9fae8e396c58..d11464420797 100644
--- a/drivers/gpio/gpio-virtio.c
+++ b/drivers/gpio/gpio-virtio.c
@@ -457,15 +457,15 @@ static void virtio_gpio_free_vqs(struct virtio_device *vdev)
static int virtio_gpio_alloc_vqs(struct virtio_gpio *vgpio,
struct virtio_device *vdev)
{
- const char * const names[] = { "requestq", "eventq" };
- vq_callback_t *cbs[] = {
- virtio_gpio_request_vq,
- virtio_gpio_event_vq,
+ struct virtqueue_info vqs_info[] = {
+ { "requestq", virtio_gpio_request_vq },
+ { "eventq", virtio_gpio_event_vq },
};
struct virtqueue *vqs[2] = { NULL, NULL };
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) {
dev_err(&vdev->dev, "failed to find vqs: %d\n", ret);
return ret;
diff --git a/drivers/gpu/drm/virtio/virtgpu_kms.c b/drivers/gpu/drm/virtio/virtgpu_kms.c
index 5a3b5aaed1f3..1590fc180c66 100644
--- a/drivers/gpu/drm/virtio/virtgpu_kms.c
+++ b/drivers/gpu/drm/virtio/virtgpu_kms.c
@@ -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)
{
- static vq_callback_t *callbacks[] = {
- virtio_gpu_ctrl_ack, virtio_gpu_cursor_ack
+ struct virtqueue_info vqs_info[] = {
+ { "control", virtio_gpu_ctrl_ack },
+ { "cursor", virtio_gpu_cursor_ack },
};
- static const char * const names[] = { "control", "cursor" };
-
struct virtio_gpu_device *vgdev;
/* this will expand later */
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",
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) {
DRM_ERROR("failed to find virt queues\n");
goto err_vqs;
diff --git a/drivers/iommu/virtio-iommu.c b/drivers/iommu/virtio-iommu.c
index 36d680826b57..d3c7877a3806 100644
--- a/drivers/iommu/virtio-iommu.c
+++ b/drivers/iommu/virtio-iommu.c
@@ -1084,14 +1084,13 @@ static struct iommu_ops viommu_ops = {
static int viommu_init_vqs(struct viommu_dev *viommu)
{
struct virtio_device *vdev = dev_to_virtio(viommu->dev);
- const char *names[] = { "request", "event" };
- vq_callback_t *callbacks[] = {
- NULL, /* No async requests */
- viommu_event_handler,
+ struct virtqueue_info vqs_info[] = {
+ { "request" },
+ { "event", viommu_event_handler },
};
- return virtio_find_vqs(vdev, VIOMMU_NR_VQS, viommu->vqs, callbacks,
- names, NULL);
+ return virtio_find_vqs_info(vdev, VIOMMU_NR_VQS, viommu->vqs,
+ vqs_info, NULL);
}
static int viommu_fill_evtq(struct viommu_dev *viommu)
diff --git a/drivers/net/wireless/virtual/mac80211_hwsim.c b/drivers/net/wireless/virtual/mac80211_hwsim.c
index c5d896994e70..7bda786631ba 100644
--- a/drivers/net/wireless/virtual/mac80211_hwsim.c
+++ b/drivers/net/wireless/virtual/mac80211_hwsim.c
@@ -6574,17 +6574,13 @@ static void hwsim_virtio_rx_done(struct virtqueue *vq)
static int init_vqs(struct virtio_device *vdev)
{
- vq_callback_t *callbacks[HWSIM_NUM_VQS] = {
- [HWSIM_VQ_TX] = hwsim_virtio_tx_done,
- [HWSIM_VQ_RX] = hwsim_virtio_rx_done,
- };
- const char *names[HWSIM_NUM_VQS] = {
- [HWSIM_VQ_TX] = "tx",
- [HWSIM_VQ_RX] = "rx",
+ struct virtqueue_info vqs_info[HWSIM_NUM_VQS] = {
+ [HWSIM_VQ_TX] = { "tx", hwsim_virtio_tx_done },
+ [HWSIM_VQ_RX] = { "rx", hwsim_virtio_rx_done },
};
- return virtio_find_vqs(vdev, HWSIM_NUM_VQS,
- hwsim_vqs, callbacks, names, NULL);
+ return virtio_find_vqs_info(vdev, HWSIM_NUM_VQS,
+ hwsim_vqs, vqs_info, NULL);
}
static int fill_vq(struct virtqueue *vq)
diff --git a/drivers/rpmsg/virtio_rpmsg_bus.c b/drivers/rpmsg/virtio_rpmsg_bus.c
index e9e8c1f7829f..fb466ef20f07 100644
--- a/drivers/rpmsg/virtio_rpmsg_bus.c
+++ b/drivers/rpmsg/virtio_rpmsg_bus.c
@@ -868,8 +868,10 @@ static void rpmsg_virtio_del_ctrl_dev(struct rpmsg_device *rpdev_ctrl)
static int rpmsg_probe(struct virtio_device *vdev)
{
- vq_callback_t *vq_cbs[] = { rpmsg_recv_done, rpmsg_xmit_done };
- static const char * const names[] = { "input", "output" };
+ struct virtqueue_info vqs_info[] = {
+ { "input", rpmsg_recv_done },
+ { "output", rpmsg_xmit_done },
+ };
struct virtqueue *vqs[2];
struct virtproc_info *vrp;
struct virtio_rpmsg_channel *vch = NULL;
@@ -891,7 +893,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 = virtio_find_vqs(vdev, 2, vqs, vq_cbs, names, NULL);
+ err = virtio_find_vqs_info(vdev, 2, vqs, vqs_info, NULL);
if (err)
goto free_vrp;
diff --git a/drivers/virtio/virtio_input.c b/drivers/virtio/virtio_input.c
index 1a730d6c0b55..6f803dc3d0f9 100644
--- a/drivers/virtio/virtio_input.c
+++ b/drivers/virtio/virtio_input.c
@@ -185,13 +185,14 @@ static void virtinput_cfg_abs(struct virtio_input *vi, int abs)
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];
- vq_callback_t *cbs[] = { virtinput_recv_events,
- virtinput_recv_status };
- static const char * const names[] = { "events", "status" };
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)
return err;
vi->evt = vqs[0];