ipc: fix return code of icbmsg backend send operation.

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>
This commit is contained in:
Piotr Koziar 2024-05-15 16:10:59 +02:00 committed by Johan Hedberg
parent 89c4afa3b8
commit e66b382639
2 changed files with 10 additions and 5 deletions

View file

@ -111,7 +111,7 @@ int icmsg_close(const struct icmsg_config_t *conf,
* @param[in] len Size of data in the @p msg buffer.
*
*
* @retval 0 on success.
* @retval Number of sent bytes.
* @retval -EBUSY when the instance has not finished handshake with the remote
* instance.
* @retval -ENODATA when the requested data to send is empty.

View file

@ -501,7 +501,7 @@ static int send_control_message(struct backend_data *dev_data, enum msg_type msg
r = icmsg_send(&conf->control_config, &dev_data->control_data, &message,
sizeof(message));
k_mutex_unlock(&dev_data->mutex);
if (r < 0) {
if (r < sizeof(message)) {
LOG_ERR("Cannot send over ICMsg, err %d", r);
}
return r;
@ -541,7 +541,7 @@ static int send_release(struct backend_data *dev_data, const uint8_t *buffer,
* @param[in] size Actual size of the data, can be smaller than allocated,
* but it cannot change number of required blocks.
*
* @return O or negative error code.
* @return number of bytes sent in the message or negative error code.
*/
static int send_block(struct backend_data *dev_data, enum msg_type msg_type,
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,
*
* @param[in] ept Endpoint to use.
*
* @return O or negative error code.
* @return non-negative value in case of success or negative error code.
*/
static int send_bound_message(struct backend_data *dev_data, struct ept_data *ept)
{
@ -992,7 +992,12 @@ static int send(const struct device *instance, void *token, const void *msg, siz
memcpy(buffer, msg, len);
/* Send data message. */
return send_block(dev_data, MSG_DATA, ept->addr, r, len);
r = send_block(dev_data, MSG_DATA, ept->addr, r, len);
if (r < 0) {
return r;
}
return len;
}
/**