diff --git a/drivers/rpmsg/rpmsg.c b/drivers/rpmsg/rpmsg.c index 5adab0d869e..132cdb87fc3 100644 --- a/drivers/rpmsg/rpmsg.c +++ b/drivers/rpmsg/rpmsg.c @@ -229,7 +229,7 @@ int rpmsg_register_callback(FAR void *priv, FAR struct rpmsg_s *rpmsg = metal_container_of(node, struct rpmsg_s, node); - if (rpmsg->rdev->ns_unbind_cb == NULL) + if (!rpmsg->init) { continue; } @@ -307,7 +307,7 @@ void rpmsg_unregister_callback(FAR void *priv, FAR struct rpmsg_s *rpmsg = metal_container_of(pnode, struct rpmsg_s, node); - if (rpmsg->rdev->ns_unbind_cb) + if (rpmsg->init) { device_destroy(rpmsg->rdev, priv); } @@ -397,6 +397,7 @@ void rpmsg_device_created(FAR struct rpmsg_s *rpmsg) } } + rpmsg->init = true; nxrmutex_unlock(&g_rpmsg_lock); #ifdef CONFIG_RPMSG_PING diff --git a/include/nuttx/rpmsg/rpmsg.h b/include/nuttx/rpmsg/rpmsg.h index c8be7e01480..1964a7fcb4b 100644 --- a/include/nuttx/rpmsg/rpmsg.h +++ b/include/nuttx/rpmsg/rpmsg.h @@ -47,6 +47,7 @@ struct rpmsg_s { + bool init; struct metal_list bind; rmutex_t lock; struct metal_list node;