From cbf58250b33e26d7e8e84919ee71eb1129f91f12 Mon Sep 17 00:00:00 2001 From: Tim Blechmann Date: Sun, 13 Mar 2022 10:45:41 +0800 Subject: rpmsg: char: treat rpmsg_trysend() ENOMEM as EAGAIN 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 Cc: Arnaud Pouliquen Signed-off-by: Bjorn Andersson Link: https://lore.kernel.org/r/20220313024541.1579848-2-tim@klingt.org --- drivers/rpmsg/rpmsg_char.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/rpmsg/rpmsg_char.c b/drivers/rpmsg/rpmsg_char.c index 5663cf799c95..434dc8a741cc 100644 --- a/drivers/rpmsg/rpmsg_char.c +++ b/drivers/rpmsg/rpmsg_char.c @@ -242,10 +242,13 @@ static ssize_t rpmsg_eptdev_write_iter(struct kiocb *iocb, 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); - else + if (ret == -ENOMEM) + ret = -EAGAIN; + } else { ret = rpmsg_sendto(eptdev->ept, kbuf, len, eptdev->chinfo.dst); + } unlock_eptdev: mutex_unlock(&eptdev->ept_lock); -- cgit v1.2.3