Skip to content

Commit 78995ff

Browse files
piotrkoziarrlubos
authored andcommitted
[nrf fromlist] ipc: fix return code of icbmsg backend send operation.
Upstream PR: zephyrproject-rtos/zephyr#73156 This commit fixes the issue where a serialization error was reported after properly sending a data with 'icbmsg' backend. The icbmsg send function's return code is set to the sent data's len as in other backends. The related docs were fixed and updated. Signed-off-by: Piotr Koziar <piotr.koziar@nordicsemi.no>
1 parent 4f8c7a6 commit 78995ff

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

include/zephyr/ipc/icmsg.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ int icmsg_close(const struct icmsg_config_t *conf,
111111
* @param[in] len Size of data in the @p msg buffer.
112112
*
113113
*
114-
* @retval 0 on success.
114+
* @retval Number of sent bytes.
115115
* @retval -EBUSY when the instance has not finished handshake with the remote
116116
* instance.
117117
* @retval -ENODATA when the requested data to send is empty.

subsys/ipc/ipc_service/backends/ipc_icbmsg.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ static int send_control_message(struct backend_data *dev_data, enum msg_type msg
501501
r = icmsg_send(&conf->control_config, &dev_data->control_data, &message,
502502
sizeof(message));
503503
k_mutex_unlock(&dev_data->mutex);
504-
if (r < 0) {
504+
if (r < sizeof(message)) {
505505
LOG_ERR("Cannot send over ICMsg, err %d", r);
506506
}
507507
return r;
@@ -541,7 +541,7 @@ static int send_release(struct backend_data *dev_data, const uint8_t *buffer,
541541
* @param[in] size Actual size of the data, can be smaller than allocated,
542542
* but it cannot change number of required blocks.
543543
*
544-
* @return O or negative error code.
544+
* @return number of bytes sent in the message or negative error code.
545545
*/
546546
static int send_block(struct backend_data *dev_data, enum msg_type msg_type,
547547
uint8_t ept_addr, size_t tx_block_index, size_t size)
@@ -656,7 +656,7 @@ static int match_bound_msg(struct backend_data *dev_data, size_t rx_block_index,
656656
*
657657
* @param[in] ept Endpoint to use.
658658
*
659-
* @return O or negative error code.
659+
* @return non-negative value in case of success or negative error code.
660660
*/
661661
static int send_bound_message(struct backend_data *dev_data, struct ept_data *ept)
662662
{
@@ -992,7 +992,12 @@ static int send(const struct device *instance, void *token, const void *msg, siz
992992
memcpy(buffer, msg, len);
993993

994994
/* Send data message. */
995-
return send_block(dev_data, MSG_DATA, ept->addr, r, len);
995+
r = send_block(dev_data, MSG_DATA, ept->addr, r, len);
996+
if (r < 0) {
997+
return r;
998+
}
999+
1000+
return len;
9961001
}
9971002

9981003
/**

0 commit comments

Comments
 (0)