[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-id: <1427881176-30522-1-git-send-email-r.baldyga@samsung.com>
Date: Wed, 01 Apr 2015 11:39:36 +0200
From: Robert Baldyga <r.baldyga@...sung.com>
To: balbi@...com
Cc: gregkh@...uxfoundation.org, mina86@...a86.com,
linux-usb@...r.kernel.org, linux-kernel@...r.kernel.org,
Robert Baldyga <r.baldyga@...sung.com>
Subject: [PATCH] usb: gadget: ffs: don't allow to open with O_NONBLOCK flag
FunctionFS can't support O_NONBLOCK because read/write operatons are
directly translated into USB requests which are asynchoronous, so we
can't know how long we will have to wait for request completion. For
this reason in case of open with O_NONBLOCK flag we return -EWOULDBLOCK.
Signed-off-by: Robert Baldyga <r.baldyga@...sung.com>
---
drivers/usb/gadget/function/f_fs.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
index 175c995..1014911 100644
--- a/drivers/usb/gadget/function/f_fs.c
+++ b/drivers/usb/gadget/function/f_fs.c
@@ -538,6 +538,14 @@ static int ffs_ep0_open(struct inode *inode, struct file *file)
if (unlikely(ffs->state == FFS_CLOSING))
return -EBUSY;
+ /*
+ * We are not supporting O_NONBLOCK because read/write operatons are
+ * directly translated into USB requests which are asynchoronous, so
+ * we can't know how long we will have to wait for request completion.
+ */
+ if (unlikely(file->f_flags & O_NONBLOCK))
+ return -EWOULDBLOCK;
+
file->private_data = ffs;
ffs_data_opened(ffs);
@@ -874,6 +882,14 @@ ffs_epfile_open(struct inode *inode, struct file *file)
if (WARN_ON(epfile->ffs->state != FFS_ACTIVE))
return -ENODEV;
+ /*
+ * We are not supporting O_NONBLOCK because read/write operatons are
+ * directly translated into USB requests which are asynchoronous, so
+ * we can't know how long we will have to wait for request completion.
+ */
+ if (unlikely(file->f_flags & O_NONBLOCK))
+ return -EWOULDBLOCK;
+
file->private_data = epfile;
ffs_data_opened(epfile->ffs);
--
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists