Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use priv data for name-service callback #567

Merged
merged 3 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/rpmsg/rpmsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,14 +273,16 @@ void rpmsg_register_endpoint(struct rpmsg_device *rdev,
const char *name,
uint32_t src, uint32_t dest,
rpmsg_ept_cb cb,
rpmsg_ns_unbind_cb ns_unbind_cb)
rpmsg_ns_unbind_cb ns_unbind_cb,
void *priv)
arnopo marked this conversation as resolved.
Show resolved Hide resolved
{
strncpy(ept->name, name ? name : "", sizeof(ept->name));
ept->refcnt = 1;
ept->addr = src;
ept->dest_addr = dest;
ept->cb = cb;
ept->ns_unbind_cb = ns_unbind_cb;
ept->priv = priv;
ept->rdev = rdev;
metal_list_add_tail(&rdev->endpoints, &ept->node);
}
Expand Down Expand Up @@ -323,7 +325,7 @@ int rpmsg_create_ept(struct rpmsg_endpoint *ept, struct rpmsg_device *rdev,
*/
}

rpmsg_register_endpoint(rdev, ept, name, addr, dest, cb, unbind_cb);
rpmsg_register_endpoint(rdev, ept, name, addr, dest, cb, unbind_cb, NULL);
metal_mutex_release(&rdev->lock);

/* Send NS announcement to remote processor */
Expand Down
3 changes: 2 additions & 1 deletion lib/rpmsg/rpmsg_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ void rpmsg_register_endpoint(struct rpmsg_device *rdev,
const char *name,
uint32_t src, uint32_t dest,
rpmsg_ept_cb cb,
rpmsg_ns_unbind_cb ns_unbind_cb);
rpmsg_ns_unbind_cb ns_unbind_cb,
void *priv);

static inline struct rpmsg_endpoint *
rpmsg_get_ept_from_addr(struct rpmsg_device *rdev, uint32_t addr)
Expand Down
10 changes: 6 additions & 4 deletions lib/rpmsg/rpmsg_virtio.c
Original file line number Diff line number Diff line change
Expand Up @@ -638,16 +638,18 @@ static void rpmsg_virtio_rx_callback(struct virtqueue *vq)
static int rpmsg_virtio_ns_callback(struct rpmsg_endpoint *ept, void *data,
size_t len, uint32_t src, void *priv)
{
struct rpmsg_device *rdev = ept->rdev;
struct rpmsg_virtio_device *rvdev = (struct rpmsg_virtio_device *)rdev;
struct rpmsg_device *rdev = priv;
struct rpmsg_virtio_device *rvdev = metal_container_of(rdev,
struct rpmsg_virtio_device,
rdev);
struct metal_io_region *io = rvdev->shbuf_io;
struct rpmsg_endpoint *_ept;
struct rpmsg_ns_msg *ns_msg;
uint32_t dest;
bool ept_to_release;
char name[RPMSG_NAME_SIZE];

(void)priv;
(void)ept;
(void)src;

ns_msg = data;
Expand Down Expand Up @@ -964,7 +966,7 @@ int rpmsg_init_vdev_with_config(struct rpmsg_virtio_device *rvdev,
if (rdev->support_ns) {
rpmsg_register_endpoint(rdev, &rdev->ns_ept, "NS",
RPMSG_NS_EPT_ADDR, RPMSG_NS_EPT_ADDR,
rpmsg_virtio_ns_callback, NULL);
rpmsg_virtio_ns_callback, NULL, rvdev);
}

#ifndef VIRTIO_DEVICE_ONLY
Expand Down
Loading