Skip to content

Commit

Permalink
shouldn't generate any namespace message if the endpoint name is empty
Browse files Browse the repository at this point in the history
and add rpmsg_create_anon_ept to simplify the anonymous endpoint creation.
with the new API, the user should:
1.call rpmsg_create_ept for the main named service endpoint
2.call rpmsg_create_anon_ept for the aided service endpoint

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
  • Loading branch information
xiaoxiang781216 committed Feb 6, 2019
1 parent 61e4c75 commit 0664e23
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
27 changes: 26 additions & 1 deletion lib/include/openamp/rpmsg.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ static inline void rpmsg_init_ept(struct rpmsg_endpoint *ept,
rpmsg_ept_cb cb,
rpmsg_ns_unbind_cb ns_unbind_cb)
{
strncpy(ept->name, name, sizeof(ept->name));
strncpy(ept->name, name ? name : "", sizeof(ept->name));
ept->addr = src;
ept->dest_addr = dest;
ept->cb = cb;
Expand Down Expand Up @@ -325,6 +325,31 @@ int rpmsg_create_ept(struct rpmsg_endpoint *ept, 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_create_anon_ept - like rpmsg_create_ept but without name
*
* Create a RPMsg endpoint, initialize it with source address,
* remoteproc address and endpoint callback, and register it to
* the RPMsg device.
*
* @ept: pointer to rpmsg endpoint
* @src: local address of the endpoint
* @dest: target address of the endpoint
* @cb: endpoint callback
*
* In essence, an rpmsg endpoint represents a listener on the rpmsg bus, as
* it binds an rpmsg address with an rx callback handler.
*/

static inline int rpmsg_create_anon_ept(struct rpmsg_endpoint *ept,
struct rpmsg_device *rdev,
uint32_t src, uint32_t dest,
rpmsg_ept_cb cb)
{
return rpmsg_create_ept(ept, rdev, NULL, src, dest, cb, NULL);
}

/**
* rpmsg_destroy_ept - destroy rpmsg endpoint and unregister it from rpmsg
* device
Expand Down
4 changes: 2 additions & 2 deletions lib/rpmsg/rpmsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ int rpmsg_create_ept(struct rpmsg_endpoint *ept, struct rpmsg_device *rdev,
rpmsg_init_ept(ept, name, addr, dest, cb, unbind_cb);
rpmsg_register_endpoint(rdev, ept);

if (rdev->support_ns && ept->dest_addr == RPMSG_ADDR_ANY) {
if (ept->name[0] && rdev->support_ns && ept->dest_addr == RPMSG_ADDR_ANY) {
/* Send NS announcement to remote processor */
metal_mutex_release(&rdev->lock);
status = rpmsg_send_ns_message(ept, RPMSG_NS_CREATE);
Expand Down Expand Up @@ -257,7 +257,7 @@ void rpmsg_destroy_ept(struct rpmsg_endpoint *ept)
return;

rdev = ept->rdev;
if (rdev->support_ns && ept->addr != RPMSG_NS_EPT_ADDR)
if (ept->name[0] && rdev->support_ns && ept->addr != RPMSG_NS_EPT_ADDR)
(void)rpmsg_send_ns_message(ept, RPMSG_NS_DESTROY);
metal_mutex_acquire(&rdev->lock);
rpmsg_unregister_endpoint(ept);
Expand Down

0 comments on commit 0664e23

Please sign in to comment.