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

rpmsg: merge rpmsg_initialize_ept into rpmsg_register_endpoint #331

Merged
merged 1 commit into from
Jan 25, 2022
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
14 changes: 11 additions & 3 deletions lib/rpmsg/rpmsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,17 @@ static void rpmsg_unregister_endpoint(struct rpmsg_endpoint *ept)
}

void rpmsg_register_endpoint(struct rpmsg_device *rdev,
struct rpmsg_endpoint *ept)
struct rpmsg_endpoint *ept,
const char *name,
uint32_t src, uint32_t dest,
rpmsg_ept_cb cb,
rpmsg_ns_unbind_cb ns_unbind_cb)
{
strncpy(ept->name, name ? name : "", sizeof(ept->name));
ept->addr = src;
ept->dest_addr = dest;
ept->cb = cb;
ept->ns_unbind_cb = ns_unbind_cb;
ept->rdev = rdev;
metal_list_add_tail(&rdev->endpoints, &ept->node);
}
Expand Down Expand Up @@ -293,8 +302,7 @@ int rpmsg_create_ept(struct rpmsg_endpoint *ept, struct rpmsg_device *rdev,
*/
}

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

/* Send NS announcement to remote processor */
Expand Down
33 changes: 5 additions & 28 deletions lib/rpmsg/rpmsg_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,40 +85,17 @@ struct rpmsg_ns_msg {
uint32_t flags;
} METAL_PACKED_END;

/**
* rpmsg_initialize_ept - initialize rpmsg endpoint
*
* Initialize an RPMsg endpoint with a name, source address,
* remoteproc address, endpoint callback, and destroy endpoint callback.
*
* @ept: pointer to rpmsg endpoint
* @name: service name associated to the endpoint
* @src: local address of the endpoint
* @dest: target address of the endpoint
* @cb: endpoint callback
* @ns_unbind_cb: end point service unbind callback, called when remote ept is
* destroyed.
*/
static inline void rpmsg_initialize_ept(struct rpmsg_endpoint *ept,
const char *name,
uint32_t src, uint32_t dest,
rpmsg_ept_cb cb,
rpmsg_ns_unbind_cb ns_unbind_cb)
{
strncpy(ept->name, name ? name : "", sizeof(ept->name));
ept->addr = src;
ept->dest_addr = dest;
ept->cb = cb;
ept->ns_unbind_cb = ns_unbind_cb;
}

int rpmsg_send_ns_message(struct rpmsg_endpoint *ept, unsigned long flags);

struct rpmsg_endpoint *rpmsg_get_endpoint(struct rpmsg_device *rvdev,
const char *name, uint32_t addr,
uint32_t dest_addr);
void rpmsg_register_endpoint(struct rpmsg_device *rdev,
struct rpmsg_endpoint *ept);
struct rpmsg_endpoint *ept,
const char *name,
uint32_t src, uint32_t dest,
rpmsg_ept_cb cb,
rpmsg_ns_unbind_cb ns_unbind_cb);

static inline struct rpmsg_endpoint *
rpmsg_get_ept_from_addr(struct rpmsg_device *rdev, uint32_t addr)
Expand Down
3 changes: 1 addition & 2 deletions lib/rpmsg/rpmsg_virtio.c
Original file line number Diff line number Diff line change
Expand Up @@ -763,10 +763,9 @@ int rpmsg_init_vdev_with_config(struct rpmsg_virtio_device *rvdev,
* service announcement feature.
*/
if (rdev->support_ns) {
rpmsg_initialize_ept(&rdev->ns_ept, "NS",
rpmsg_register_endpoint(rdev, &rdev->ns_ept, "NS",
RPMSG_NS_EPT_ADDR, RPMSG_NS_EPT_ADDR,
rpmsg_virtio_ns_callback, NULL);
rpmsg_register_endpoint(rdev, &rdev->ns_ept);
}

#ifndef VIRTIO_SLAVE_ONLY
Expand Down