This patch aims to be simple. It removes #include usbstribgs.c line from each gadget and creats libcomposite.ko which has only one member, that is usbstribgs.c. To avoid mass select statements in Kconfig I simply group the composite based gadgets together. The three gadgets which are not part of the group are: - EHCI Debug Device Gadget. Could be converted to composite if anyone cares - File-backed Storage Gadget. Replaced by "mass storage", will be removed soon. - Gadget Filesystem. Functionality is provided by "Function Filesystem". Unfortunatelly can't be replaced because the user space visible API is different. Signed-off-by: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx> --- drivers/staging/ccg/Kconfig | 1 + drivers/staging/ccg/ccg.c | 1 - drivers/usb/gadget/Kconfig | 116 ++++++++++++++++++++--------------- drivers/usb/gadget/Makefile | 2 + drivers/usb/gadget/acm_ms.c | 1 - drivers/usb/gadget/audio.c | 1 - drivers/usb/gadget/cdc2.c | 1 - drivers/usb/gadget/ether.c | 1 - drivers/usb/gadget/file_storage.c | 1 - drivers/usb/gadget/g_ffs.c | 1 - drivers/usb/gadget/gmidi.c | 1 - drivers/usb/gadget/hid.c | 1 - drivers/usb/gadget/mass_storage.c | 1 - drivers/usb/gadget/multi.c | 1 - drivers/usb/gadget/ncm.c | 1 - drivers/usb/gadget/nokia.c | 1 - drivers/usb/gadget/printer.c | 1 - drivers/usb/gadget/serial.c | 1 - drivers/usb/gadget/tcm_usb_gadget.c | 1 - drivers/usb/gadget/usbstring.c | 4 +- drivers/usb/gadget/webcam.c | 1 - drivers/usb/gadget/zero.c | 1 - 22 files changed, 72 insertions(+), 69 deletions(-) diff --git a/drivers/staging/ccg/Kconfig b/drivers/staging/ccg/Kconfig index 187bcdb..ef4f25b 100644 --- a/drivers/staging/ccg/Kconfig +++ b/drivers/staging/ccg/Kconfig @@ -3,6 +3,7 @@ if USB_GADGET config USB_G_CCG tristate "Configurable Composite Gadget (STAGING)" depends on STAGING && BLOCK + depends on USB_LIBCOMPOSITE help The Configurable Composite Gadget supports multiple USB functions: acm, mass storage, rndis and FunctionFS. diff --git a/drivers/staging/ccg/ccg.c b/drivers/staging/ccg/ccg.c index d726a8d..c379b9f 100644 --- a/drivers/staging/ccg/ccg.c +++ b/drivers/staging/ccg/ccg.c @@ -44,7 +44,6 @@ * the runtime footprint, and giving us at least some parts of what * a "gcc --combine ... part1.c part2.c part3.c ... " build would. */ -#include "../../usb/gadget/usbstring.c" #include "../../usb/gadget/config.c" #include "../../usb/gadget/epautoconf.c" #include "composite.c" diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig index 1494112..c26c26c 100644 --- a/drivers/usb/gadget/Kconfig +++ b/drivers/usb/gadget/Kconfig @@ -507,6 +507,16 @@ config USB_GADGET_SUPERSPEED # # USB Gadget Drivers # + +# composite based drivers +config USB_LIBCOMPOSITE + tristate "Lib composite based gadgets" + depends on USB_GADGET + help + Most gadgets are using the composite framework. There are only three + gadgets left which do not use the composite framework and two of them + have been replaced by alternatives. + choice tristate "USB Gadget Drivers" default USB_ETH @@ -526,6 +536,8 @@ choice not be able work with that controller, or might need to implement a less common variant of a device class protocol. +if USB_LIBCOMPOSITE +# # this first set of drivers all depend on bulk-capable hardware. config USB_ZERO @@ -672,22 +684,6 @@ config USB_G_NCM Say "y" to link the driver statically, or "m" to build a dynamically linked module called "g_ncm". -config USB_GADGETFS - tristate "Gadget Filesystem (EXPERIMENTAL)" - depends on EXPERIMENTAL - help - This driver provides a filesystem based API that lets user mode - programs implement a single-configuration USB device, including - endpoint I/O and control requests that don't relate to enumeration. - All endpoints, transfer speeds, and transfer types supported by - the hardware are available, through read() and write() calls. - - Currently, this option is still labelled as EXPERIMENTAL because - of existing race conditions in the underlying in-kernel AIO core. - - Say "y" to link the driver statically, or "m" to build a - dynamically linked module called "gadgetfs". - config USB_FUNCTIONFS tristate "Function Filesystem (EXPERIMENTAL)" depends on EXPERIMENTAL @@ -726,31 +722,6 @@ config USB_FUNCTIONFS_GENERIC Include a configuration with the Function Filesystem alone with no Ethernet interface. -config USB_FILE_STORAGE - tristate "File-backed Storage Gadget (DEPRECATED)" - depends on BLOCK - help - The File-backed Storage Gadget acts as a USB Mass Storage - disk drive. As its storage repository it can use a regular - file or a block device (in much the same way as the "loop" - device driver), specified as a module parameter. - - Say "y" to link the driver statically, or "m" to build a - dynamically linked module called "g_file_storage". - - NOTE: This driver is deprecated. Its replacement is the - Mass Storage Gadget. - -config USB_FILE_STORAGE_TEST - bool "File-backed Storage Gadget testing version" - depends on USB_FILE_STORAGE - default n - help - Say "y" to generate the larger testing version of the - File-backed Storage Gadget, useful for probing the - behavior of USB Mass Storage hosts. Not needed for - normal operation. - config USB_MASS_STORAGE tristate "Mass Storage Gadget" depends on BLOCK @@ -912,6 +883,22 @@ config USB_G_HID Say "y" to link the driver statically, or "m" to build a dynamically linked module called "g_hid". +# put drivers that need isochronous transfer support (for audio +# or video class gadget drivers), or specific hardware, here. +config USB_G_WEBCAM + tristate "USB Webcam Gadget" + depends on VIDEO_DEV + help + The Webcam Gadget acts as a composite USB Audio and Video Class + device. It provides a userspace API to process UVC control requests + and stream video data to the host. + + Say "y" to link the driver statically, or "m" to build a + dynamically linked module called "g_webcam". + +endif + +# Standalone / single function gadgets config USB_G_DBGP tristate "EHCI Debug Device Gadget" help @@ -940,18 +927,47 @@ config USB_G_DBGP_SERIAL endchoice endif -# put drivers that need isochronous transfer support (for audio -# or video class gadget drivers), or specific hardware, here. -config USB_G_WEBCAM - tristate "USB Webcam Gadget" - depends on VIDEO_DEV +config USB_FILE_STORAGE + tristate "File-backed Storage Gadget (DEPRECATED)" + depends on BLOCK help - The Webcam Gadget acts as a composite USB Audio and Video Class - device. It provides a userspace API to process UVC control requests - and stream video data to the host. + The File-backed Storage Gadget acts as a USB Mass Storage + disk drive. As its storage repository it can use a regular + file or a block device (in much the same way as the "loop" + device driver), specified as a module parameter. Say "y" to link the driver statically, or "m" to build a - dynamically linked module called "g_webcam". + dynamically linked module called "g_file_storage". + + NOTE: This driver is deprecated. Its replacement is the + Mass Storage Gadget. + +config USB_FILE_STORAGE_TEST + bool "File-backed Storage Gadget testing version" + depends on USB_FILE_STORAGE + default n + help + Say "y" to generate the larger testing version of the + File-backed Storage Gadget, useful for probing the + behavior of USB Mass Storage hosts. Not needed for + normal operation. + + +config USB_GADGETFS + tristate "Gadget Filesystem (EXPERIMENTAL)" + depends on EXPERIMENTAL + help + This driver provides a filesystem based API that lets user mode + programs implement a single-configuration USB device, including + endpoint I/O and control requests that don't relate to enumeration. + All endpoints, transfer speeds, and transfer types supported by + the hardware are available, through read() and write() calls. + + Currently, this option is still labelled as EXPERIMENTAL because + of existing race conditions in the underlying in-kernel AIO core. + + Say "y" to link the driver statically, or "m" to build a + dynamically linked module called "gadgetfs". endchoice diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile index 3fd8cd0..4ff3f0c 100644 --- a/drivers/usb/gadget/Makefile +++ b/drivers/usb/gadget/Makefile @@ -4,6 +4,8 @@ ccflags-$(CONFIG_USB_GADGET_DEBUG) := -DDEBUG obj-$(CONFIG_USB_GADGET) += udc-core.o +obj-$(CONFIG_USB_LIBCOMPOSITE) += libcomposite.o +libcomposite-y := usbstring.o obj-$(CONFIG_USB_DUMMY_HCD) += dummy_hcd.o obj-$(CONFIG_USB_NET2272) += net2272.o obj-$(CONFIG_USB_NET2280) += net2280.o diff --git a/drivers/usb/gadget/acm_ms.c b/drivers/usb/gadget/acm_ms.c index 65a2f3c..9820960 100644 --- a/drivers/usb/gadget/acm_ms.c +++ b/drivers/usb/gadget/acm_ms.c @@ -42,7 +42,6 @@ */ #include "composite.c" -#include "usbstring.c" #include "config.c" #include "epautoconf.c" #include "u_serial.c" diff --git a/drivers/usb/gadget/audio.c b/drivers/usb/gadget/audio.c index dd339bc..76e54b4 100644 --- a/drivers/usb/gadget/audio.c +++ b/drivers/usb/gadget/audio.c @@ -27,7 +27,6 @@ * a "gcc --combine ... part1.c part2.c part3.c ... " build would. */ #include "composite.c" -#include "usbstring.c" #include "config.c" #include "epautoconf.c" diff --git a/drivers/usb/gadget/cdc2.c b/drivers/usb/gadget/cdc2.c index b7d984b..74a9c7f 100644 --- a/drivers/usb/gadget/cdc2.c +++ b/drivers/usb/gadget/cdc2.c @@ -44,7 +44,6 @@ */ #include "composite.c" -#include "usbstring.c" #include "config.c" #include "epautoconf.c" #include "u_serial.c" diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c index 4580ec0..e16094e 100644 --- a/drivers/usb/gadget/ether.c +++ b/drivers/usb/gadget/ether.c @@ -103,7 +103,6 @@ static inline bool has_rndis(void) * a "gcc --combine ... part1.c part2.c part3.c ... " build would. */ #include "composite.c" -#include "usbstring.c" #include "config.c" #include "epautoconf.c" diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c index cdacae7..8d0166b 100644 --- a/drivers/usb/gadget/file_storage.c +++ b/drivers/usb/gadget/file_storage.c @@ -265,7 +265,6 @@ * the runtime footprint, and giving us at least some parts of what * a "gcc --combine ... part1.c part2.c part3.c ... " build would. */ -#include "usbstring.c" #include "config.c" #include "epautoconf.c" diff --git a/drivers/usb/gadget/g_ffs.c b/drivers/usb/gadget/g_ffs.c index da9809f..407b5cc 100644 --- a/drivers/usb/gadget/g_ffs.c +++ b/drivers/usb/gadget/g_ffs.c @@ -24,7 +24,6 @@ */ #include "composite.c" -#include "usbstring.c" #include "config.c" #include "epautoconf.c" diff --git a/drivers/usb/gadget/gmidi.c b/drivers/usb/gadget/gmidi.c index 1e3cd37..135b390 100644 --- a/drivers/usb/gadget/gmidi.c +++ b/drivers/usb/gadget/gmidi.c @@ -38,7 +38,6 @@ #include "gadget_chips.h" #include "composite.c" -#include "usbstring.c" #include "config.c" #include "epautoconf.c" #include "f_midi.c" diff --git a/drivers/usb/gadget/hid.c b/drivers/usb/gadget/hid.c index 8502e56..effda2e 100644 --- a/drivers/usb/gadget/hid.c +++ b/drivers/usb/gadget/hid.c @@ -35,7 +35,6 @@ */ #include "composite.c" -#include "usbstring.c" #include "config.c" #include "epautoconf.c" diff --git a/drivers/usb/gadget/mass_storage.c b/drivers/usb/gadget/mass_storage.c index 480edbc..a7f32c3 100644 --- a/drivers/usb/gadget/mass_storage.c +++ b/drivers/usb/gadget/mass_storage.c @@ -49,7 +49,6 @@ */ #include "composite.c" -#include "usbstring.c" #include "config.c" #include "epautoconf.c" #include "f_mass_storage.c" diff --git a/drivers/usb/gadget/multi.c b/drivers/usb/gadget/multi.c index 13db7cc..71c1fab 100644 --- a/drivers/usb/gadget/multi.c +++ b/drivers/usb/gadget/multi.c @@ -44,7 +44,6 @@ MODULE_LICENSE("GPL"); */ #include "composite.c" -#include "usbstring.c" #include "config.c" #include "epautoconf.c" diff --git a/drivers/usb/gadget/ncm.c b/drivers/usb/gadget/ncm.c index 9a20057..d7e6b1e 100644 --- a/drivers/usb/gadget/ncm.c +++ b/drivers/usb/gadget/ncm.c @@ -37,7 +37,6 @@ * a "gcc --combine ... part1.c part2.c part3.c ... " build would. */ #include "composite.c" -#include "usbstring.c" #include "config.c" #include "epautoconf.c" diff --git a/drivers/usb/gadget/nokia.c b/drivers/usb/gadget/nokia.c index a5b5e71..474c77c 100644 --- a/drivers/usb/gadget/nokia.c +++ b/drivers/usb/gadget/nokia.c @@ -39,7 +39,6 @@ * a "gcc --combine ... part1.c part2.c part3.c ... " build would. */ #include "composite.c" -#include "usbstring.c" #include "config.c" #include "epautoconf.c" diff --git a/drivers/usb/gadget/printer.c b/drivers/usb/gadget/printer.c index 33c0c07..c55e7d9 100644 --- a/drivers/usb/gadget/printer.c +++ b/drivers/usb/gadget/printer.c @@ -52,7 +52,6 @@ * a "gcc --combine ... part1.c part2.c part3.c ... " build would. */ #include "composite.c" -#include "usbstring.c" #include "config.c" #include "epautoconf.c" diff --git a/drivers/usb/gadget/serial.c b/drivers/usb/gadget/serial.c index ea3f8e9..88baa9e 100644 --- a/drivers/usb/gadget/serial.c +++ b/drivers/usb/gadget/serial.c @@ -38,7 +38,6 @@ * a "gcc --combine ... part1.c part2.c part3.c ... " build would. */ #include "composite.c" -#include "usbstring.c" #include "config.c" #include "epautoconf.c" diff --git a/drivers/usb/gadget/tcm_usb_gadget.c b/drivers/usb/gadget/tcm_usb_gadget.c index 35ca09a..327af68 100644 --- a/drivers/usb/gadget/tcm_usb_gadget.c +++ b/drivers/usb/gadget/tcm_usb_gadget.c @@ -25,7 +25,6 @@ #include <target/configfs_macros.h> #include <asm/unaligned.h> -#include "usbstring.c" #include "epautoconf.c" #include "config.c" #include "composite.c" diff --git a/drivers/usb/gadget/usbstring.c b/drivers/usb/gadget/usbstring.c index 4d25b90..24e9bbd 100644 --- a/drivers/usb/gadget/usbstring.c +++ b/drivers/usb/gadget/usbstring.c @@ -9,6 +9,7 @@ #include <linux/errno.h> #include <linux/kernel.h> +#include <linux/module.h> #include <linux/list.h> #include <linux/string.h> #include <linux/device.h> @@ -68,4 +69,5 @@ usb_gadget_get_string (struct usb_gadget_strings *table, int id, u8 *buf) buf [1] = USB_DT_STRING; return buf [0]; } - +EXPORT_SYMBOL_GPL(usb_gadget_get_string); +MODULE_LICENSE("GPL"); diff --git a/drivers/usb/gadget/webcam.c b/drivers/usb/gadget/webcam.c index 2a617c3..dc8fd5c 100644 --- a/drivers/usb/gadget/webcam.c +++ b/drivers/usb/gadget/webcam.c @@ -24,7 +24,6 @@ * a "gcc --combine ... part1.c part2.c part3.c ... " build would. */ #include "composite.c" -#include "usbstring.c" #include "config.c" #include "epautoconf.c" diff --git a/drivers/usb/gadget/zero.c b/drivers/usb/gadget/zero.c index 90df613..4469be8 100644 --- a/drivers/usb/gadget/zero.c +++ b/drivers/usb/gadget/zero.c @@ -59,7 +59,6 @@ * a "gcc --combine ... part1.c part2.c part3.c ... " build would. */ #include "composite.c" -#include "usbstring.c" #include "config.c" #include "epautoconf.c" -- 1.7.10.4 -- 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