Skip to content

Commit

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

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
  • Loading branch information
xiaoxiang781216 committed Jan 10, 2022
1 parent 2a2a99a commit 3503ffc
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 13 deletions.
10 changes: 1 addition & 9 deletions lib/rpmsg/rpmsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -249,13 +249,6 @@ static void rpmsg_unregister_endpoint(struct rpmsg_endpoint *ept)
metal_mutex_release(&rdev->lock);
}

void rpmsg_register_endpoint(struct rpmsg_device *rdev,
struct rpmsg_endpoint *ept)
{
ept->rdev = rdev;
metal_list_add_tail(&rdev->endpoints, &ept->node);
}

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 unbind_cb)
Expand Down Expand Up @@ -293,8 +286,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_initialize_ept(ept, rdev, name, addr, dest, cb, unbind_cb);
metal_mutex_release(&rdev->lock);

/* Send NS announcement to remote processor */
Expand Down
5 changes: 3 additions & 2 deletions lib/rpmsg/rpmsg_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ struct rpmsg_ns_msg {
* destroyed.
*/
static inline void rpmsg_initialize_ept(struct rpmsg_endpoint *ept,
struct rpmsg_device *rdev,
const char *name,
uint32_t src, uint32_t dest,
rpmsg_ept_cb cb,
Expand All @@ -110,15 +111,15 @@ static inline void rpmsg_initialize_ept(struct rpmsg_endpoint *ept,
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);
}

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);

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_initialize_ept(&rdev->ns_ept, rdev, "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 3503ffc

Please sign in to comment.