Skip to content

Commit

Permalink
rpmsg: Replace rvdev->vdev with vdev in rpmsg_init_vdev_with_config
Browse files Browse the repository at this point in the history
vdev is passed by argument, so we don't need accees it indirectly

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
  • Loading branch information
xiaoxiang781216 authored and arnopo committed Oct 9, 2024
1 parent c468328 commit e7e7593
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions lib/rpmsg/rpmsg_virtio.c
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,7 @@ int rpmsg_init_vdev_with_config(struct rpmsg_virtio_device *rvdev,
rdev->ops.get_rx_buffer_size = rpmsg_virtio_get_rx_buffer_size;
rdev->ops.get_tx_buffer_size = rpmsg_virtio_get_tx_buffer_size;

if (VIRTIO_ROLE_IS_DRIVER(rvdev->vdev)) {
if (VIRTIO_ROLE_IS_DRIVER(vdev)) {
/*
* The virtio configuration contains only options applicable to
* a virtio driver, implying rpmsg host role.
Expand All @@ -817,19 +817,19 @@ int rpmsg_init_vdev_with_config(struct rpmsg_virtio_device *rvdev,
rvdev->config = *config;
}

if (VIRTIO_ROLE_IS_DEVICE(rvdev->vdev)) {
if (VIRTIO_ROLE_IS_DEVICE(vdev)) {
/* wait synchro with the host */
status = rpmsg_virtio_wait_remote_ready(rvdev);
if (status)
return status;
}

status = virtio_get_features(rvdev->vdev, &features);
status = virtio_get_features(vdev, &features);
if (status)
return status;
rdev->support_ns = !!(features & (1 << VIRTIO_RPMSG_F_NS));

if (VIRTIO_ROLE_IS_DRIVER(rvdev->vdev)) {
if (VIRTIO_ROLE_IS_DRIVER(vdev)) {
/*
* Since device is RPMSG Remote so we need to manage the
* shared buffers. Create shared memory pool to handle buffers.
Expand All @@ -846,7 +846,7 @@ int rpmsg_init_vdev_with_config(struct rpmsg_virtio_device *rvdev,
callback[1] = rpmsg_virtio_tx_callback;
}

if (VIRTIO_ROLE_IS_DEVICE(rvdev->vdev)) {
if (VIRTIO_ROLE_IS_DEVICE(vdev)) {
vq_names[0] = "tx_vq";
vq_names[1] = "rx_vq";
callback[0] = rpmsg_virtio_tx_callback;
Expand All @@ -857,18 +857,18 @@ int rpmsg_init_vdev_with_config(struct rpmsg_virtio_device *rvdev,
metal_list_init(&rvdev->reclaimer);

/* Create virtqueues for remote device */
status = virtio_create_virtqueues(rvdev->vdev, 0, RPMSG_NUM_VRINGS,
status = virtio_create_virtqueues(vdev, 0, RPMSG_NUM_VRINGS,
vq_names, callback, NULL);
if (status != RPMSG_SUCCESS)
return status;

/* Create virtqueue success, assign back the virtqueue */
if (VIRTIO_ROLE_IS_DRIVER(rvdev->vdev)) {
if (VIRTIO_ROLE_IS_DRIVER(vdev)) {
rvdev->rvq = vdev->vrings_info[0].vq;
rvdev->svq = vdev->vrings_info[1].vq;
}

if (VIRTIO_ROLE_IS_DEVICE(rvdev->vdev)) {
if (VIRTIO_ROLE_IS_DEVICE(vdev)) {
rvdev->rvq = vdev->vrings_info[1].vq;
rvdev->svq = vdev->vrings_info[0].vq;
}
Expand All @@ -887,7 +887,7 @@ int rpmsg_init_vdev_with_config(struct rpmsg_virtio_device *rvdev,
vq->shm_io = shm_io;
}

if (VIRTIO_ROLE_IS_DRIVER(rvdev->vdev)) {
if (VIRTIO_ROLE_IS_DRIVER(vdev)) {
struct virtqueue_buf vqbuf;
unsigned int idx;
void *buffer;
Expand Down Expand Up @@ -932,16 +932,16 @@ int rpmsg_init_vdev_with_config(struct rpmsg_virtio_device *rvdev,
rpmsg_virtio_ns_callback, NULL, rvdev);
}

if (VIRTIO_ROLE_IS_DRIVER(rvdev->vdev)) {
status = virtio_set_status(rvdev->vdev, VIRTIO_CONFIG_STATUS_DRIVER_OK);
if (VIRTIO_ROLE_IS_DRIVER(vdev)) {
status = virtio_set_status(vdev, VIRTIO_CONFIG_STATUS_DRIVER_OK);
if (status)
goto err;
}

return RPMSG_SUCCESS;

err:
virtio_delete_virtqueues(rvdev->vdev);
virtio_delete_virtqueues(vdev);
return status;
}

Expand Down

0 comments on commit e7e7593

Please sign in to comment.