Skip to content

Commit f16a19c

Browse files
jacksonc-xlnxcarlescufi
authored andcommitted
ipc_service: Add ipc_rpmsg_deinit function
This function does the opposite of the ipc_rpmsg_init function and allows the rpmsg instance to be torndown in the case that the application wishes to do so. It is intended to be used by the ipc_service subsystem. Signed-off-by: Jackson Cooper-Driver <[email protected]>
1 parent f09220d commit f16a19c

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

include/zephyr/ipc/ipc_rpmsg.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,20 @@ int ipc_rpmsg_init(struct ipc_rpmsg_instance *instance,
113113
void *shb, size_t size,
114114
rpmsg_ns_bind_cb ns_bind_cb);
115115

116+
117+
/** @brief
118+
*
119+
* Deinit an RPMsg instance
120+
*
121+
* @param instance Pointer to the RPMsg instance struct.
122+
* @param role Host / Remote role.
123+
*
124+
* @retval -EINVAL When some parameter is missing
125+
* @retval 0 If successful
126+
*/
127+
int ipc_rpmsg_deinit(struct ipc_rpmsg_instance *instance,
128+
unsigned int role);
129+
116130
/** @brief Register an endpoint.
117131
*
118132
* Register an endpoint to a provided RPMsg instance.

subsys/ipc/ipc_service/lib/ipc_rpmsg.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,19 @@ int ipc_rpmsg_init(struct ipc_rpmsg_instance *instance,
102102
return rpmsg_init_vdev(&instance->rvdev, vdev, bind_cb, shm_io, NULL);
103103
}
104104
}
105+
106+
int ipc_rpmsg_deinit(struct ipc_rpmsg_instance *instance,
107+
unsigned int role)
108+
{
109+
if (!instance) {
110+
return -EINVAL;
111+
}
112+
113+
rpmsg_deinit_vdev(&instance->rvdev);
114+
115+
if (role == RPMSG_HOST) {
116+
memset(&instance->shm_pool, 0, sizeof(struct rpmsg_virtio_shm_pool));
117+
}
118+
119+
return 0;
120+
}

0 commit comments

Comments
 (0)