Skip to content

Commit

Permalink
rpmsg: merge rpmsg_initialize_ept into rpmsg_register_endpoint
Browse files Browse the repository at this point in the history
so the service with preserved address could call rpmsg_register_endpoint only

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
  • Loading branch information
xiaoxiang781216 committed Jan 13, 2022
1 parent a12d03c commit c47d1ca
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 33 deletions.
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

0 comments on commit c47d1ca

Please sign in to comment.