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 <ccaione@baylibre.com>
This commit is contained in:
Carlo Caione 2022-05-16 13:04:24 +02:00 committed by Carles Cufí
commit 11f0bb9d1a
3 changed files with 11 additions and 1 deletions

View file

@ -233,6 +233,7 @@ int ipc_service_register_endpoint(const struct device *instance,
* @retval -EBADMSG when the data is invalid (i.e. invalid data format,
* invalid length, ...)
* @retval -EBUSY when the instance is busy.
* @retval -ENOMEM when no memory / buffers are available.
*
* @retval bytes number of bytes sent.
* @retval other errno codes depending on the implementation of the backend.

View file

@ -47,6 +47,7 @@ struct ipc_service_backend {
* @retval -EINVAL when instance is invalid.
* @retval -EBADMSG when the message is invalid.
* @retval -EBUSY when the instance is busy or not ready.
* @retval -ENOMEM when no memory / buffers are available.
*
* @retval bytes number of bytes sent.
* @retval other errno codes depending on the implementation of the

View file

@ -394,6 +394,7 @@ static int send(const struct device *instance, void *token,
{
struct backend_data_t *data = instance->data;
struct ipc_rpmsg_ept *rpmsg_ept;
int ret;
/* Instance is not ready */
if (atomic_get(&data->state) != STATE_INITED) {
@ -407,7 +408,14 @@ static int send(const struct device *instance, void *token,
rpmsg_ept = (struct ipc_rpmsg_ept *) token;
return rpmsg_send(&rpmsg_ept->ep, msg, len);
ret = rpmsg_send(&rpmsg_ept->ep, msg, len);
/* No buffers available */
if (ret == RPMSG_ERR_NO_BUFF) {
return -ENOMEM;
}
return ret;
}
static int send_nocopy(const struct device *instance, void *token,