Skip to content

Commit aa9a8c8

Browse files
rakonsrlubos
authored andcommitted
event_manager_proxy: Check if remote instance was added already
This commit adds handling of the situation if remote instance was added already and returns -EALREADY in such situation. Signed-off-by: Radoslaw Koppel <[email protected]>
1 parent ba272a2 commit aa9a8c8

File tree

4 files changed

+7
-2
lines changed

4 files changed

+7
-2
lines changed

include/event_manager_proxy.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
* This function registers endpoint used to communication with another core.
4040
*
4141
* @param instance The instance used for IPC service to transfer data between cores.
42+
* @retval -EALREADY Given remote instance was added already.
4243
* @retval -ENOMEM No place for the new endpoint. See @kconfig{CONFIG_EVENT_MANAGER_PROXY_CH_COUNT}.
4344
* @retval -EIO Comes from IPC service,
4445
* see ipc_service_open_instance or ipc_service_register_endpoint.

samples/event_manager_proxy/remote/src/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ void main(void)
3434
LOG_INF("Event manager initialized");
3535

3636
ret = event_manager_proxy_add_remote(ipc_instance);
37-
if (ret) {
37+
if (ret && ret != -EALREADY) {
3838
LOG_ERR("Cannot add remote: %d", ret);
3939
__ASSERT_NO_MSG(false);
4040
return;

samples/event_manager_proxy/src/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ void main(void)
3939
LOG_INF("Event manager initialized");
4040

4141
ret = event_manager_proxy_add_remote(ipc_instance);
42-
if (ret) {
42+
if (ret && ret != -EALREADY) {
4343
LOG_ERR("Cannot add remote: %d", ret);
4444
__ASSERT_NO_MSG(false);
4545
return;

subsys/event_manager_proxy/event_manager_proxy.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,10 @@ int event_manager_proxy_add_remote(const struct device *instance)
363363
{
364364
__ASSERT_NO_MSG(find_ipc_by_instance(instance) == NULL);
365365

366+
if (find_ipc_by_instance(instance) != NULL) {
367+
return -EALREADY;
368+
}
369+
366370
for (size_t i = 0; i < ARRAY_SIZE(emp_ipc_data); ++i) {
367371
if (!emp_ipc_data[i].used) {
368372
return add_ipc_instace(&emp_ipc_data[i], instance);

0 commit comments

Comments
 (0)