You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2024/04/23 14:02:11 UTC
(nuttx) 02/11: drivers/usbdev_fs: report POLLHUP when disconnect
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 070ecb480a8ab0b0bbd176d2deabe429c3f42135
Author: dongjiuzhu1 <do...@xiaomi.com>
AuthorDate: Wed Nov 29 10:01:23 2023 +0800
drivers/usbdev_fs: report POLLHUP when disconnect
Signed-off-by: dongjiuzhu1 <do...@xiaomi.com>
---
drivers/usbdev/usbdev_fs.c | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
diff --git a/drivers/usbdev/usbdev_fs.c b/drivers/usbdev/usbdev_fs.c
index e7b1bc0982..5f07883a23 100644
--- a/drivers/usbdev/usbdev_fs.c
+++ b/drivers/usbdev/usbdev_fs.c
@@ -786,14 +786,6 @@ static int usbdev_fs_poll(FAR struct file *filep, FAR struct pollfd *fds,
return ret;
}
- /* Check if the usbdev device has been unbind */
-
- if (fs_ep->unlinked)
- {
- nxmutex_unlock(&fs_ep->lock);
- return -ENOTCONN;
- }
-
if (!setup)
{
/* This is a request to tear down the poll. */
@@ -838,9 +830,16 @@ static int usbdev_fs_poll(FAR struct file *filep, FAR struct pollfd *fds,
eventset = 0;
+ /* Check if the usbdev device has been unbind */
+
+ if (fs_ep->unlinked)
+ {
+ eventset |= POLLHUP;
+ }
+
/* Notify the POLLIN/POLLOUT event if at least one request is available */
- if (!sq_empty(&fs_ep->reqq))
+ else if (!sq_empty(&fs_ep->reqq))
{
if (USB_ISEPIN(fs_ep->ep->eplog))
{