rpmsg: char - treat `ENOMEM` as `EAGAIN`
cover rpmsg: char - treat `ENOMEM` as `EAGAIN`
This patch should allow the use of rpmsg_char character devices with libraries that do a poll/write loop and expect EAGAIN when sending fails and the user space application needs to poll to wait for more space to be available.boost::asio::write is a notable example of a library, which implements such a loop.
Tim Blechmann (1):
rpmsg: char - treat ENOMEM as EAGAIN
drivers/rpmsg/rpmsg_char.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
Signature · 1 line
2.35.1
PATCH 1/1 rpmsg: char - treat `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.
--- drivers/rpmsg/rpmsg_char.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/rpmsg/rpmsg_char.c +4 -1
@@ -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);
Signature · 1 line
2.35.1
Quoted 1 line · Tim Blechmann
rpmsg_trysendreturns-ENOMEMwhen no rpmsg buffer can be allocated.
Please use the form rpmsg_trysend() - without ``. You can omit that around -ENOMEM as well.
Quoted 1 line
this causes
::writeto fail with this error as opposed to-EAGAIN.
Please drop the :: here as well.
Quoted 4 lines
this is what user space applications (and libraries like boost.asio) would expect when using normal character devices.
Signed-off-by Tim Blechmann <[email protected]>
I attempted to fix up the above details, but unfortunately your Signed-off-by doesn't match your From:, so I can't apply the patch anyways.
Can you please resubmit this with appropriate author/s-o-b?
Quoted 14 lines
CC Arnaud Pouliquen <[email protected]>--- drivers/rpmsg/rpmsg_char.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/rpmsg/rpmsg_char.c +0
-0@@ -239,14 +239,17 @@ static ssize_t rpmsg_eptdev_write_iter(struct kiocb *iocb,if (!eptdev->ept) { ret = -EPIPE ; goto unlock_eptdev;
drivers/rpmsg/rpmsg_char.c static ssize_t rpmsg_eptdev_write_iter(struct kiocb *iocb, · line 251
Quoted 10 lines
drivers/rpmsg/rpmsg_char.c +4
-1} -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);
./script/checkpatch.pl --strict tells me that you should have {} around the else block as well..
Thanks,
Bjorn
Quoted 7 lines
drivers/rpmsg/rpmsg_char.c +0
-0unlock_eptdev:mutex_unlock (&eptdev->ept_lock);Signature · 1 line
2.35.1
v2 cover rpmsg: char - treat `ENOMEM` as `EAGAIN`
From: Tim Blechmann <[email protected]>
This patch should allow the use of rpmsg_char character devices with libraries that do a poll/write loop and expect EAGAIN when sending fails and the user space application needs to poll to wait for more space to be available.boost::asio::write is a notable example of a library, which implements such a loop.
Tim Blechmann (1):
rpmsg: char - treat ENOMEM as EAGAIN
drivers/rpmsg/rpmsg_char.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
Signature · 1 line
2.35.1
PATCH 1/1 rpmsg: char - treat ENOMEM as EAGAIN
From: Tim Blechmann <[email protected]>
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.
--- drivers/rpmsg/rpmsg_char.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/rpmsg/rpmsg_char.c +4 -1
@@ -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);
Signature · 1 line
2.35.1