[PATCH v2 1/2] usb: gadget: legacy: Add udc module param to all legacy gadgets

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

 



Add new module parameter called "udc" to all legacy gadgets.
By using this parameter user can choose a controller towhich
this gadget should be bound.

This may be useful esp. when having multiple controllers
or multiple gadget builtin.

When value for this param is not provided then old behaviour
(binding to first free UDC) remains unchanged.

Signed-off-by: Krzysztof Opasiak <k.opasiak@xxxxxxxxxxx>
---
Changes since v1:
- add documentation for udc_name field

---
 drivers/usb/gadget/composite.c             |    1 +
 drivers/usb/gadget/legacy/acm_ms.c         |    2 ++
 drivers/usb/gadget/legacy/audio.c          |    2 ++
 drivers/usb/gadget/legacy/cdc2.c           |    2 ++
 drivers/usb/gadget/legacy/dbgp.c           |    3 +++
 drivers/usb/gadget/legacy/ether.c          |    2 ++
 drivers/usb/gadget/legacy/g_ffs.c          |    2 ++
 drivers/usb/gadget/legacy/gmidi.c          |    2 ++
 drivers/usb/gadget/legacy/hid.c            |    2 ++
 drivers/usb/gadget/legacy/mass_storage.c   |    2 ++
 drivers/usb/gadget/legacy/multi.c          |    2 ++
 drivers/usb/gadget/legacy/ncm.c            |    2 ++
 drivers/usb/gadget/legacy/nokia.c          |    2 ++
 drivers/usb/gadget/legacy/printer.c        |    2 ++
 drivers/usb/gadget/legacy/serial.c         |    2 ++
 drivers/usb/gadget/legacy/tcm_usb_gadget.c |    2 ++
 drivers/usb/gadget/legacy/webcam.c         |    2 ++
 drivers/usb/gadget/legacy/zero.c           |    2 ++
 include/linux/usb/composite.h              |    7 +++++++
 19 files changed, 43 insertions(+)

diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index eb64848..1262c03 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -2313,6 +2313,7 @@ int usb_composite_probe(struct usb_composite_driver *driver)
 		driver->name = "composite";
 
 	driver->gadget_driver = composite_driver_template;
+	driver->gadget_driver.udc_name = driver->udc_name;
 	gadget_driver = &driver->gadget_driver;
 
 	gadget_driver->function =  (char *) driver->name;
diff --git a/drivers/usb/gadget/legacy/acm_ms.c b/drivers/usb/gadget/legacy/acm_ms.c
index c39de65..9ca07e8 100644
--- a/drivers/usb/gadget/legacy/acm_ms.c
+++ b/drivers/usb/gadget/legacy/acm_ms.c
@@ -260,6 +260,8 @@ static struct usb_composite_driver acm_ms_driver = {
 	.unbind		= acm_ms_unbind,
 };
 
+USB_GADGET_COMPOSITE_UDC_NAME(acm_ms_driver);
+
 module_usb_composite_driver(acm_ms_driver);
 
 MODULE_DESCRIPTION(DRIVER_DESC);
diff --git a/drivers/usb/gadget/legacy/audio.c b/drivers/usb/gadget/legacy/audio.c
index 5d7b3c6..a07e36c 100644
--- a/drivers/usb/gadget/legacy/audio.c
+++ b/drivers/usb/gadget/legacy/audio.c
@@ -304,6 +304,8 @@ static struct usb_composite_driver audio_driver = {
 	.unbind		= audio_unbind,
 };
 
+USB_GADGET_COMPOSITE_UDC_NAME(audio_driver);
+
 module_usb_composite_driver(audio_driver);
 
 MODULE_DESCRIPTION(DRIVER_DESC);
diff --git a/drivers/usb/gadget/legacy/cdc2.c b/drivers/usb/gadget/legacy/cdc2.c
index 51c0868..fd5f142 100644
--- a/drivers/usb/gadget/legacy/cdc2.c
+++ b/drivers/usb/gadget/legacy/cdc2.c
@@ -234,6 +234,8 @@ static struct usb_composite_driver cdc_driver = {
 	.unbind		= cdc_unbind,
 };
 
+USB_GADGET_COMPOSITE_UDC_NAME(cdc_driver);
+
 module_usb_composite_driver(cdc_driver);
 
 MODULE_DESCRIPTION(DRIVER_DESC);
diff --git a/drivers/usb/gadget/legacy/dbgp.c b/drivers/usb/gadget/legacy/dbgp.c
index 99ca3da..5d434bd 100644
--- a/drivers/usb/gadget/legacy/dbgp.c
+++ b/drivers/usb/gadget/legacy/dbgp.c
@@ -406,6 +406,9 @@ static struct usb_gadget_driver dbgp_driver = {
 	},
 };
 
+module_param_named(udc, dbgp_driver.udc_name, charp, S_IRUGO);
+MODULE_PARM_DESC(udc, "USB Device Controller Name");
+
 static int __init dbgp_init(void)
 {
 	return usb_gadget_probe_driver(&dbgp_driver);
diff --git a/drivers/usb/gadget/legacy/ether.c b/drivers/usb/gadget/legacy/ether.c
index 25a2c2e..172c4b5 100644
--- a/drivers/usb/gadget/legacy/ether.c
+++ b/drivers/usb/gadget/legacy/ether.c
@@ -479,6 +479,8 @@ static struct usb_composite_driver eth_driver = {
 	.unbind		= eth_unbind,
 };
 
+USB_GADGET_COMPOSITE_UDC_NAME(eth_driver);
+
 module_usb_composite_driver(eth_driver);
 
 MODULE_DESCRIPTION(PREFIX DRIVER_DESC);
diff --git a/drivers/usb/gadget/legacy/g_ffs.c b/drivers/usb/gadget/legacy/g_ffs.c
index f85639e..ffa9cc3 100644
--- a/drivers/usb/gadget/legacy/g_ffs.c
+++ b/drivers/usb/gadget/legacy/g_ffs.c
@@ -158,6 +158,8 @@ static struct usb_composite_driver gfs_driver = {
 	.unbind		= gfs_unbind,
 };
 
+USB_GADGET_COMPOSITE_UDC_NAME(gfs_driver);
+
 static unsigned int missing_funcs;
 static bool gfs_registered;
 static bool gfs_single_func;
diff --git a/drivers/usb/gadget/legacy/gmidi.c b/drivers/usb/gadget/legacy/gmidi.c
index fc2ac15..13fe22b 100644
--- a/drivers/usb/gadget/legacy/gmidi.c
+++ b/drivers/usb/gadget/legacy/gmidi.c
@@ -184,4 +184,6 @@ static struct usb_composite_driver midi_driver = {
 	.unbind		= midi_unbind,
 };
 
+USB_GADGET_COMPOSITE_UDC_NAME(midi_driver);
+
 module_usb_composite_driver(midi_driver);
diff --git a/drivers/usb/gadget/legacy/hid.c b/drivers/usb/gadget/legacy/hid.c
index a71a884..c9e38b5 100644
--- a/drivers/usb/gadget/legacy/hid.c
+++ b/drivers/usb/gadget/legacy/hid.c
@@ -264,6 +264,8 @@ static struct usb_composite_driver hidg_driver = {
 	.unbind		= hid_unbind,
 };
 
+USB_GADGET_COMPOSITE_UDC_NAME(hidg_driver);
+
 static struct platform_driver hidg_plat_driver = {
 	.remove		= hidg_plat_driver_remove,
 	.driver		= {
diff --git a/drivers/usb/gadget/legacy/mass_storage.c b/drivers/usb/gadget/legacy/mass_storage.c
index 125974f..1ddb12c 100644
--- a/drivers/usb/gadget/legacy/mass_storage.c
+++ b/drivers/usb/gadget/legacy/mass_storage.c
@@ -251,6 +251,8 @@ static struct usb_composite_driver msg_driver = {
 	.unbind		= msg_unbind,
 };
 
+USB_GADGET_COMPOSITE_UDC_NAME(msg_driver);
+
 MODULE_DESCRIPTION(DRIVER_DESC);
 MODULE_AUTHOR("Michal Nazarewicz");
 MODULE_LICENSE("GPL");
diff --git a/drivers/usb/gadget/legacy/multi.c b/drivers/usb/gadget/legacy/multi.c
index a70a406..d82fdcb 100644
--- a/drivers/usb/gadget/legacy/multi.c
+++ b/drivers/usb/gadget/legacy/multi.c
@@ -492,4 +492,6 @@ static struct usb_composite_driver multi_driver = {
 	.needs_serial	= 1,
 };
 
+USB_GADGET_COMPOSITE_UDC_NAME(multi_driver);
+
 module_usb_composite_driver(multi_driver);
diff --git a/drivers/usb/gadget/legacy/ncm.c b/drivers/usb/gadget/legacy/ncm.c
index 0aba682..6af2c42 100644
--- a/drivers/usb/gadget/legacy/ncm.c
+++ b/drivers/usb/gadget/legacy/ncm.c
@@ -208,6 +208,8 @@ static struct usb_composite_driver ncm_driver = {
 	.unbind		= gncm_unbind,
 };
 
+USB_GADGET_COMPOSITE_UDC_NAME(ncm_driver);
+
 module_usb_composite_driver(ncm_driver);
 
 MODULE_DESCRIPTION(DRIVER_DESC);
diff --git a/drivers/usb/gadget/legacy/nokia.c b/drivers/usb/gadget/legacy/nokia.c
index b1e535f..a41bd8f 100644
--- a/drivers/usb/gadget/legacy/nokia.c
+++ b/drivers/usb/gadget/legacy/nokia.c
@@ -433,4 +433,6 @@ static struct usb_composite_driver nokia_driver = {
 	.unbind		= nokia_unbind,
 };
 
+USB_GADGET_COMPOSITE_UDC_NAME(nokia_driver);
+
 module_usb_composite_driver(nokia_driver);
diff --git a/drivers/usb/gadget/legacy/printer.c b/drivers/usb/gadget/legacy/printer.c
index 6f969a8..6bc1b0f 100644
--- a/drivers/usb/gadget/legacy/printer.c
+++ b/drivers/usb/gadget/legacy/printer.c
@@ -217,6 +217,8 @@ static struct usb_composite_driver printer_driver = {
 	.unbind		= printer_unbind,
 };
 
+USB_GADGET_COMPOSITE_UDC_NAME(printer_driver);
+
 module_usb_composite_driver(printer_driver);
 
 MODULE_DESCRIPTION(DRIVER_DESC);
diff --git a/drivers/usb/gadget/legacy/serial.c b/drivers/usb/gadget/legacy/serial.c
index 9d89adc..fd3a82e 100644
--- a/drivers/usb/gadget/legacy/serial.c
+++ b/drivers/usb/gadget/legacy/serial.c
@@ -243,6 +243,8 @@ static struct usb_composite_driver gserial_driver = {
 	.unbind		= gs_unbind,
 };
 
+USB_GADGET_COMPOSITE_UDC_NAME(gserial_driver);
+
 static int __init init(void)
 {
 	/* We *could* export two configs; that'd be much cleaner...
diff --git a/drivers/usb/gadget/legacy/tcm_usb_gadget.c b/drivers/usb/gadget/legacy/tcm_usb_gadget.c
index 0b0bb98..0728967 100644
--- a/drivers/usb/gadget/legacy/tcm_usb_gadget.c
+++ b/drivers/usb/gadget/legacy/tcm_usb_gadget.c
@@ -127,6 +127,8 @@ static struct usb_composite_driver usbg_driver = {
 	.unbind         = guas_unbind,
 };
 
+USB_GADGET_COMPOSITE_UDC_NAME(usbg_driver);
+
 static int usbg_attach(struct usb_function_instance *f)
 {
 	return usb_composite_probe(&usbg_driver);
diff --git a/drivers/usb/gadget/legacy/webcam.c b/drivers/usb/gadget/legacy/webcam.c
index f9661cd..bc81cdf 100644
--- a/drivers/usb/gadget/legacy/webcam.c
+++ b/drivers/usb/gadget/legacy/webcam.c
@@ -431,6 +431,8 @@ static struct usb_composite_driver webcam_driver = {
 	.unbind		= webcam_unbind,
 };
 
+USB_GADGET_COMPOSITE_UDC_NAME(webcam_driver);
+
 module_usb_composite_driver(webcam_driver);
 
 MODULE_AUTHOR("Laurent Pinchart");
diff --git a/drivers/usb/gadget/legacy/zero.c b/drivers/usb/gadget/legacy/zero.c
index d02e2ce..edd5d8d 100644
--- a/drivers/usb/gadget/legacy/zero.c
+++ b/drivers/usb/gadget/legacy/zero.c
@@ -424,6 +424,8 @@ static struct usb_composite_driver zero_driver = {
 	.resume		= zero_resume,
 };
 
+USB_GADGET_COMPOSITE_UDC_NAME(zero_driver);
+
 module_usb_composite_driver(zero_driver);
 
 MODULE_AUTHOR("David Brownell");
diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h
index 2b81b24..eb718f0 100644
--- a/include/linux/usb/composite.h
+++ b/include/linux/usb/composite.h
@@ -344,6 +344,7 @@ enum {
 /**
  * struct usb_composite_driver - groups configurations into a gadget
  * @name: For diagnostics, identifies the driver.
+ * @udc_name: Name of UDC to which this gadget should be bound
  * @dev: Template descriptor for the device, including default device
  *	identifiers.
  * @strings: tables of strings, keyed by identifiers assigned during @bind
@@ -379,6 +380,7 @@ enum {
  */
 struct usb_composite_driver {
 	const char				*name;
+	char				        *udc_name;
 	const struct usb_device_descriptor	*dev;
 	struct usb_gadget_strings		**strings;
 	enum usb_device_speed			max_speed;
@@ -556,6 +558,11 @@ struct usb_composite_overwrite {
 	module_param_named(iProduct, coverwrite.product, charp, S_IRUGO); \
 	MODULE_PARM_DESC(iProduct, "USB Product string")
 
+#define USB_GADGET_COMPOSITE_UDC_NAME(__composite_driver)              \
+	module_param_named(udc, __composite_driver.udc_name, charp,    \
+			   S_IRUGO);				       \
+	MODULE_PARM_DESC(udc, "USB Device Controller Name")
+
 void usb_composite_overwrite_options(struct usb_composite_dev *cdev,
 		struct usb_composite_overwrite *covr);
 
-- 
1.7.9.5

--
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



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

  Powered by Linux