[PATCH] usb: gadget: f_fs: Send a create event for endpoint files

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Jerry Zhang <jerry@xxxxxxxxxx>

If userspace is creating a composite gadget with one or
more functionfs functions, it generally goes through a process of:

1. mount functionfs devices
2. start up driver processes
3. driver processes open ep0 and write descriptors
4. once all descriptors are written, enable gadget

The user may want the gadget to be enabled as soon as possible.
However there is no race-free way to know when to enable the gadget
since the gadget enable process doesn't know the status of the
other driver processes. Furthermore, other driver processes
may be fixed binaries, so there may not be an opportunity to
modify their source to use a cooperative synchronization method.

This can be resolved by enabling inotify create events for endpoint
files. The gadget enable process can create inotify watches in each
driver's directory, and a create event for "ep1" will indicate that
the driver has finished writing descriptors. Once events for all
drivers have been received, the gadget is ready to be enabled.

Signed-off-by: Jerry Zhang <jerry@xxxxxxxxxx>
---
 drivers/usb/gadget/function/f_fs.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
index ddfc537c7526..fc038db46e14 100644
--- a/drivers/usb/gadget/function/f_fs.c
+++ b/drivers/usb/gadget/function/f_fs.c
@@ -13,10 +13,11 @@
 
 /* #define DEBUG */
 /* #define VERBOSE_DEBUG */
 
 #include <linux/blkdev.h>
+#include <linux/fsnotify.h>
 #include <linux/pagemap.h>
 #include <linux/export.h>
 #include <linux/fs_parser.h>
 #include <linux/hid.h>
 #include <linux/mm.h>
@@ -1443,10 +1444,11 @@ static struct dentry *ffs_sb_create_file(struct super_block *sb,
 		dput(dentry);
 		return NULL;
 	}
 
 	d_add(dentry, inode);
+	fsnotify_create(dentry->d_parent->d_inode, dentry);
 	return dentry;
 }
 
 /* Super block */
 static const struct super_operations ffs_sb_operations = {
-- 
2.37.3




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux