diff mbox series

[1/1] rpmsg: char - treat ENOMEM as EAGAIN

Message ID 20220313024541.1579848-2-tim@klingt.org (mailing list archive)
State Queued
Headers show
Series rpmsg: char - treat `ENOMEM` as `EAGAIN` | expand

Commit Message

Tim Blechmann March 13, 2022, 2:45 a.m. UTC
From: Tim Blechmann <tim@klingt.org>

rpmsg_trysend() returns -ENOMEM when no rpmsg buffer can be allocated.
this causes write to fail with this error as opposed to -EAGAIN.
this is what user space applications (and libraries like boost.asio)
would expect when using normal character devices.

Signed-off-by: Tim Blechmann <tim@klingt.org>
CC: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
---
 drivers/rpmsg/rpmsg_char.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/rpmsg/rpmsg_char.c b/drivers/rpmsg/rpmsg_char.c
index 5663cf799c95..5b9e708d595a 100644
--- a/drivers/rpmsg/rpmsg_char.c
+++ b/drivers/rpmsg/rpmsg_char.c
@@ -239,14 +239,17 @@  static ssize_t rpmsg_eptdev_write_iter(struct kiocb *iocb,
 
 	if (!eptdev->ept) {
 		ret = -EPIPE;
 		goto unlock_eptdev;
 	}
 
-	if (filp->f_flags & O_NONBLOCK)
+	if (filp->f_flags & O_NONBLOCK) {
 		ret = rpmsg_trysendto(eptdev->ept, kbuf, len, eptdev->chinfo.dst);
+		if (ret == -ENOMEM)
+			ret = -EAGAIN;
+	}
 	else
 		ret = rpmsg_sendto(eptdev->ept, kbuf, len, eptdev->chinfo.dst);
 
 unlock_eptdev:
 	mutex_unlock(&eptdev->ept_lock);