Skip to content

Commit

Permalink
rpmsg: char: treat rpmsg_trysend() ENOMEM as EAGAIN
Browse files Browse the repository at this point in the history
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>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Link: https://lore.kernel.org/r/20220313024541.1579848-2-tim@klingt.org
  • Loading branch information
Tim Blechmann authored and Bjorn Andersson committed Mar 13, 2022
1 parent db64e7e commit cbf5825
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions drivers/rpmsg/rpmsg_char.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit cbf5825

Please sign in to comment.