Skip to content

Commit 11f0bb9

Browse files
carlocaionecarlescufi
authored andcommitted
ipc: static_vrings: Add -ENOMEM case
Sometimes it is important to know when the backend fails to send out data because no memory / buffers are available. Return -ENOMEM in that case. Signed-off-by: Carlo Caione <[email protected]>
1 parent ba14fc4 commit 11f0bb9

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

include/zephyr/ipc/ipc_service.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ int ipc_service_register_endpoint(const struct device *instance,
233233
* @retval -EBADMSG when the data is invalid (i.e. invalid data format,
234234
* invalid length, ...)
235235
* @retval -EBUSY when the instance is busy.
236+
* @retval -ENOMEM when no memory / buffers are available.
236237
*
237238
* @retval bytes number of bytes sent.
238239
* @retval other errno codes depending on the implementation of the backend.

include/zephyr/ipc/ipc_service_backend.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ struct ipc_service_backend {
4747
* @retval -EINVAL when instance is invalid.
4848
* @retval -EBADMSG when the message is invalid.
4949
* @retval -EBUSY when the instance is busy or not ready.
50+
* @retval -ENOMEM when no memory / buffers are available.
5051
*
5152
* @retval bytes number of bytes sent.
5253
* @retval other errno codes depending on the implementation of the

subsys/ipc/ipc_service/backends/ipc_rpmsg_static_vrings.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,7 @@ static int send(const struct device *instance, void *token,
394394
{
395395
struct backend_data_t *data = instance->data;
396396
struct ipc_rpmsg_ept *rpmsg_ept;
397+
int ret;
397398

398399
/* Instance is not ready */
399400
if (atomic_get(&data->state) != STATE_INITED) {
@@ -407,7 +408,14 @@ static int send(const struct device *instance, void *token,
407408

408409
rpmsg_ept = (struct ipc_rpmsg_ept *) token;
409410

410-
return rpmsg_send(&rpmsg_ept->ep, msg, len);
411+
ret = rpmsg_send(&rpmsg_ept->ep, msg, len);
412+
413+
/* No buffers available */
414+
if (ret == RPMSG_ERR_NO_BUFF) {
415+
return -ENOMEM;
416+
}
417+
418+
return ret;
411419
}
412420

413421
static int send_nocopy(const struct device *instance, void *token,

0 commit comments

Comments
 (0)