This series aims at integrating configfs into FunctionFS, the way it has been done for acm, ncm, ecm, eem, ecm subset, rndis, obex, phonet and mass_storage. It contains everything that is required to provide the equivalent of g_ffs.ko with configfs. Configfs support in FunctionFS has been awaited by the Android folks as discussed during the LPC 2013. Apart from that a VLAIS (variable length array in a struct) patch is added. It is not strictly necessary, but it won't hurt and it will make the Clang people happy. FunctionFS is more complicated than most other USB functions, so the resulting patch series is a bit long. Howerver, it is supposed to do things in steps. 1) preliminary work: extend generic configfs support in USB gadget, convert g_ffs to new function interfaces of f_ecm, f_subset, f_rndis; g_ffs is the last user of the old interfaces so remove compatibility layers 2) factoring out a u_fs.h header and finally making f_fs a separate module with both old and new function interface 3) converting all users of f_fs (in fact only g_ffs) to the new interface and remove compatiblilty layer 4) add configfs support v1..v2: - fixes after Michal's review, thank you, Michal! - removal of unnecessary hunks, simplified VLAIS replacement code, used proper pointer dereferencing, simplified ffs_do_functionfs_bind(), ffs_alloc_inst() and ffs_free(), style corrections, allocated usb_function structures in one chunk for all configs in g_ffs Rebased onto Felipe's master. At the moment I don't have any public git repo at hand, so a branch 'usb-gadget-configfs' will be available later at git://git.linaro.org/people/mszyprowski/linux-srpol.git BACKWARD COMPATIBILITY ====================== Please note that the old g_ffs.ko is still available and works. USING THE NEW "GADGET" ====================== Please refer to this post: http://www.spinics.net/lists/linux-usb/msg76388.html for general information from Sebastian on how to use configfs-based gadgets (*). With configfs the procedure is as follows, compared to the information mentioned above (*): instead of mkdir functions/acm.ttyS1 do mkdir functions/ffs.<instance name> e.g. mkdir functions/ffs.ptp In functions/<function>.<instance name> there will be no attribute files at all, because all parameters are passed with FunctionFS. An example gadget with adb and ptp functions: (I assume there are ptpd and adbd daemons using FunctionFS available, a proof-of-concept adbd can be found here: https://android-review.googlesource.com/#/c/31640/, an early version of ptp which I used is here: http://www.spinics.net/lists/linux-usb/msg41963.html) $ modprobe libcomposite $ mount none cfg -t configfs $ mkdir cfg/usb_gadget/g1 $ cd cfg/usb_gadget/g1 $ mkdir configs/c.1 $ mkdir functions/ffs.adb $ mkdir functions/ffs.ptp $ mkdir strings/0x409 $ mkdir configs/c.1/strings/0x409 $ echo 0x2d01 > idProduct $ echo 0x04e8 > idVendor $ echo my-serial-num > strings/0x409/serialnumber $ echo my-manufacturer > strings/0x409/manufacturer $ echo "FunctionFS gadget (ptp, adb)" > strings/0x409/product $ echo "Conf 1" > configs/c.1/strings/0x409/configuration $ echo 120 > configs/c.1/MaxPower $ ln -s functions/ffs.ptp configs/c.1 $ ln -s functions/ffs.adb configs/c.1 $ mkdir /dev/usbffs $ mount ptp /dev/usbffs -t functionfs $ ptpd $ mkdir -p /dev/usbgadget/adb $ mount -t functionfs adb /dev/usbgadget/adb -o uid=2000,gid=2000 $ adbd $ echo s3c-hsotg > cfg/usb_gadget/g1/UDC After unbinding the gadget with echo "" > UDC the symbolic links in the configuration directory can be removed, the strings/* subdirectories in the configuration directory can be removed, the strings/* subdirectories at the gadget level can be removed and the configs/* subdirectories can be removed. The functions/* subdirectories can be removed. After that the gadget directory can be removed. FunctionFS instances should be unmounted, daemons need to be closed and then the respective modules can be unloaded. TESTING THE FUNCTIONS (actually there is only one) ===================== FunctionFS) device: connect the gadget, enable it host: mount the ptp device, adb shell Andrzej Pietrasiewicz (16): usb/gadget: configfs: allow setting function instance's name usb/gadget: g_ffs: remove a reduntant gfs_ether_setup variable usb/gadget: g_ffs: convert to new interface of f_ecm usb/gadget: f_ecm: remove compatibility layer usb/gadget: g_ffs: convert to new interface of f_subset usb/gadget: f_subset: remove compatibility layer usb/gadget: g_ffs: convert to new interface of f_rndis usb/gadget: f_rndis: remove compatibility layer usb/gadget: rndis: merge u_rndis.ko with usb_f_rndis.ko usb/gadget: FunctionFS: Remove VLAIS usage from gadget code usb/gadget: FunctionFS: create utility file usb/gadget: FunctionFS: add devices management code usb/gadget: FunctionFS: convert to new function interface with backward compatibility usb/gadget: g_ffs: convert to new interface of f_fs usb/gadget: FunctionFS: Remove compatibility layer usb/gadget: FunctionFS: add configfs support Documentation/ABI/testing/configfs-usb-gadget-ffs | 9 + drivers/usb/gadget/Kconfig | 26 +- drivers/usb/gadget/Makefile | 6 +- drivers/usb/gadget/configfs.c | 7 + drivers/usb/gadget/f_ecm.c | 73 +-- drivers/usb/gadget/f_fs.c | 896 +++++++++++++-------- drivers/usb/gadget/f_rndis.c | 94 +-- drivers/usb/gadget/f_subset.c | 60 +-- drivers/usb/gadget/g_ffs.c | 363 ++++++--- drivers/usb/gadget/rndis.c | 7 +- drivers/usb/gadget/u_ether.h | 41 - drivers/usb/gadget/u_fs.h | 254 ++++++ drivers/usb/gadget/u_rndis.h | 2 + include/linux/usb/composite.h | 2 + include/linux/usb/functionfs.h | 30 - 15 files changed, 1139 insertions(+), 731 deletions(-) create mode 100644 Documentation/ABI/testing/configfs-usb-gadget-ffs create mode 100644 drivers/usb/gadget/u_fs.h -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html