Skip to contentSkip to conversation

Several improvements to USB gadgets

PATCH Superseded Michal Nazarewicz 4 participants 17 messages May 19, 2010 – May 21, 2010

Subsystems (2)

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

cover Several improvements to USB gadgets

This patchset introduces several improvements to USB gadget, functions, etc.:

Michal Nazarewicz (8):
USB: gadget: g_mass_storage: static data instead of dynamic
allocation

A micro optimisation preventing a kmalloc call() which would otherwise be always called at the very beginning for the same area size.

This was submitted previously by me but Greg did not included it in his quilt tree (unless I overlooked something) so I'll posting it again for completeness. Sorry if that creates confusion.

USB: gadget: f_mass_storage: fsg_add() renamed to fsg_bind_config()
USB: gadget: f_fs: functionfs_add() renamed to
functionfs_bind_config()

All other functions use foo_bind_config() to add function to USB configuration so changed the names for mass storage and FunctionFS as well.

In case of mass storage the old (fsg_add()) function is still available but marked deprecated. In case of FFS the old (functionfs_add()) function has been removed.

USB: gadget: composite: usb_string_ids_*() functions added
USB: gadget: f_fs: use usb_string_ids_n()

usb_string_ids_n() and usb_string_ids_tab() functions added for batch sting IDs requests.

USB: gadget: g_multi: code clean up and refactoring
USB: gadget: g_multi: more configurable
USB: gadget: g_multi: added documentation and INF files

g_multi clean up, fixes, etc.

 Documentation/usb/gadget_multi.txt        |  129 +++++++++++++++
 Documentation/usb/gadget_multi_rndis.inf  |  200 +++++++++++++++++++++++
 Documentation/usb/gadget_multi_serial.inf |   44 +++++
 drivers/usb/gadget/Kconfig                |   66 +++++---
 drivers/usb/gadget/composite.c            |   67 +++++++-
 drivers/usb/gadget/f_fs.c                 |   35 ++---
 drivers/usb/gadget/f_mass_storage.c       |   13 +-
 drivers/usb/gadget/g_ffs.c                |    2 +-
 drivers/usb/gadget/mass_storage.c         |   13 +-
 drivers/usb/gadget/multi.c                |  254 +++++++++++++++--------------
 include/linux/usb/composite.h             |    4 +
 include/linux/usb/functionfs.h            |    6 +-
 12 files changed, 653 insertions(+), 180 deletions(-)
 create mode 100644 Documentation/usb/gadget_multi.txt
 create mode 100644 Documentation/usb/gadget_multi_rndis.inf
 create mode 100644 Documentation/usb/gadget_multi_serial.inf
Signature · 4 lines
Best regards,                                        _     _
| Humble Liege of Serenely Enlightened Majesty of  o' \,=./ `o
| Computer Science,  Micha흢 "mina86" Nazarewicz       (o o)
+----[mina86*mina86.com]---[mina86*jabber.org]----ooO--(_)--Ooo--
#1 lore raw

PATCH 1/8 USB: gadget: g_mass_storage: static data instead of dynamic allocation

This patch changes msg_do_config() function so that it uses a static object for a fsg_common structure instead of dynamically allocated. This is a micro-optimisation.

---
 drivers/usb/gadget/mass_storage.c |   13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)
drivers/usb/gadget/mass_storage.c +7 -6
index 705cc1f..a3349f2 100644
@@ -143,7 +143,7 @@ static int msg_thread_exits(struct fsg_common *common)
 
 static int __init msg_do_config(struct usb_configuration *c)
 {
-	struct fsg_common *common;
+	static struct fsg_common common, *retp;
 	struct fsg_config config;
 	int ret;
 
@@ -154,12 +154,13 @@ static int __init msg_do_config(struct usb_configuration *c)
 
 	fsg_config_from_params(&config, &mod_data);
 	config.thread_exits = msg_thread_exits;
-	common = fsg_common_init(0, c->cdev, &config);
-	if (IS_ERR(common))
-		return PTR_ERR(common);
 
-	ret = fsg_add(c->cdev, c, common);
-	fsg_common_put(common);
+	retp = fsg_common_init(&common, c->cdev, &config);
+	if (IS_ERR(retp))
+		return PTR_ERR(retp);
+
+	ret = fsg_add(c->cdev, c, &common);
+	fsg_common_put(&common);
 	return ret;
 }
 
Signature · 1 line
1.7.1
#2 lore raw

PATCH 2/8 USB: gadget: f_mass_storage: fsg_add() renamed to fsg_bind_config()

Mass Storage Function had a bit unique name for function used to add it to USB configuration. Renamed as to match naming convention of other functions.

---
 drivers/usb/gadget/f_mass_storage.c |   13 ++++++++++---
 drivers/usb/gadget/mass_storage.c   |    2 +-
 drivers/usb/gadget/multi.c          |    4 ++--
 3 files changed, 13 insertions(+), 6 deletions(-)
drivers/usb/gadget/f_mass_storage.c +10 -3
index 7d05a0b..072cbf9 100644
@@ -3023,9 +3023,9 @@ static struct usb_gadget_strings *fsg_strings_array[] = {
 	NULL,
 };
 
-static int fsg_add(struct usb_composite_dev *cdev,
-		   struct usb_configuration *c,
-		   struct fsg_common *common)
+static int fsg_bind_config(struct usb_composite_dev *cdev,
+			   struct usb_configuration *c,
+			   struct fsg_common *common)
 {
 	struct fsg_dev *fsg;
 	int rc;
@@ -3072,6 +3072,13 @@ error_free_fsg:
 	return rc;
 }
 
+static inline int __deprecated __maybe_unused
+fsg_add(struct usb_composite_dev *cdev,
+	struct usb_configuration *c,
+	struct fsg_common *common)
+{
+	return fsg_bind_config(cdev, c, common);
+}
 
 
 /************************* Module parameters *************************/
drivers/usb/gadget/mass_storage.c +1 -1
index a3349f2..d6975f4 100644
@@ -159,7 +159,7 @@ static int __init msg_do_config(struct usb_configuration *c)
 	if (IS_ERR(retp))
 		return PTR_ERR(retp);
 
-	ret = fsg_add(c->cdev, c, &common);
+	ret = fsg_bind_config(c->cdev, c, &common);
 	fsg_common_put(&common);
 	return ret;
 }
drivers/usb/gadget/multi.c +2 -2
index a930d7f..d3d3140 100644
@@ -172,7 +172,7 @@ static int __init rndis_do_config(struct usb_configuration *c)
 	if (ret < 0)
 		return ret;
 
-	ret = fsg_add(c->cdev, c, fsg_common);
+	ret = fsg_bind_config(c->cdev, c, fsg_common);
 	if (ret < 0)
 		return ret;
 
@@ -208,7 +208,7 @@ static int __init cdc_do_config(struct usb_configuration *c)
 	if (ret < 0)
 		return ret;
 
-	ret = fsg_add(c->cdev, c, fsg_common);
+	ret = fsg_bind_config(c->cdev, c, fsg_common);
 	if (ret < 0)
 		return ret;
 
Signature · 1 line
1.7.1
#3 lore raw

PATCH 3/8 USB: gadget: f_fs: functionfs_add() renamed to functionfs_bind_config()

FunctionFS had a bit unique name for function used to add it to USB configuration. Renamed as to match naming convention of other functions.

---
 drivers/usb/gadget/f_fs.c      |    6 +++---
 drivers/usb/gadget/g_ffs.c     |    2 +-
 include/linux/usb/functionfs.h |    6 +++---
 3 files changed, 7 insertions(+), 7 deletions(-)
drivers/usb/gadget/f_fs.c +3 -3
index d69eccf..3fe120f 100644
@@ -1480,9 +1480,9 @@ static void ffs_epfiles_destroy(struct ffs_epfile *epfiles, unsigned count)
 }
 
 
-static int functionfs_add(struct usb_composite_dev *cdev,
-			  struct usb_configuration *c,
-			  struct ffs_data *ffs)
+static int functionfs_bind_config(struct usb_composite_dev *cdev,
+				  struct usb_configuration *c,
+				  struct ffs_data *ffs)
 {
 	struct ffs_function *func;
 	int ret;
drivers/usb/gadget/g_ffs.c +1 -1
index 4b0e4a0..2f26470 100644
@@ -388,7 +388,7 @@ static int __gfs_do_config(struct usb_configuration *c,
 			return ret;
 	}
 
-	ret = functionfs_add(c->cdev, c, gfs_ffs_data);
+	ret = functionfs_bind_config(c->cdev, c, gfs_ffs_data);
 	if (unlikely(ret < 0))
 		return ret;
 
include/linux/usb/functionfs.h +3 -3
index a34a2a0..6f649c1 100644
@@ -180,9 +180,9 @@ static int functionfs_bind(struct ffs_data *ffs, struct usb_composite_dev *cdev)
 static void functionfs_unbind(struct ffs_data *ffs)
 	__attribute__((nonnull));
 
-static int functionfs_add(struct usb_composite_dev *cdev,
-			  struct usb_configuration *c,
-			  struct ffs_data *ffs)
+static int functionfs_bind_config(struct usb_composite_dev *cdev,
+				  struct usb_configuration *c,
+				  struct ffs_data *ffs)
 	__attribute__((warn_unused_result, nonnull));
 
 
Signature · 1 line
1.7.1
#4 lore raw

PATCH 4/8 USB: gadget: composite: usb_string_ids_*() functions added

usb_string_ids_tab() and usb_string_ids_n() functions added to the composite framework. The first accepts an array of usb_string object and for each registeres a string id and the second registeres a given number of ids and returns the first.

This may simplify string ids registration since gadgets and composite functions won't have to call usb_string_id() several times and each time check for errer status -- all this will be done with a single call.

---
 drivers/usb/gadget/composite.c |   67 ++++++++++++++++++++++++++++++++++++++--
 include/linux/usb/composite.h  |    4 ++
 2 files changed, 68 insertions(+), 3 deletions(-)
drivers/usb/gadget/composite.c +64 -3
index 391d169..cd1a952 100644
@@ -673,9 +673,10 @@ static int get_string(struct usb_composite_dev *cdev,
  * string IDs.  Drivers for functions, configurations, or gadgets will
  * then store that ID in the appropriate descriptors and string table.
  *
- * All string identifier should be allocated using this routine, to
- * ensure that for example different functions don't wrongly assign
- * different meanings to the same identifier.
+ * All string identifier should be allocated using this,
+ * @usb_string_ids_tab() or @usb_string_ids_n() routine, to ensure
+ * that for example different functions don't wrongly assign different
+ * meanings to the same identifier.
  */
 int usb_string_id(struct usb_composite_dev *cdev)
 {
@@ -687,6 +688,66 @@ int usb_string_id(struct usb_composite_dev *cdev)
 	return -ENODEV;
 }
 
+/**
+ * usb_string_ids() - allocate unused string IDs in batch
+ * @cdev: the device whose string descriptor IDs are being allocated
+ * @str: an array of usb_string objects to assign numbers to
+ * Context: single threaded during gadget setup
+ *
+ * @usb_string_ids() is called from bind() callbacks to allocate
+ * string IDs.  Drivers for functions, configurations, or gadgets will
+ * then copy IDs from the string table to the appropriate descriptors
+ * and string table for other languages.
+ *
+ * All string identifier should be allocated using this,
+ * @usb_string_id() or @usb_string_ids_n() routine, to ensure that for
+ * example different functions don't wrongly assign different meanings
+ * to the same identifier.
+ */
+int usb_string_ids_tab(struct usb_composite_dev *cdev, struct usb_string *str)
+{
+	int next = cdev->next_string_id;
+
+	for (; str->s; ++str) {
+		if (unlikely(next == 255))
+			return -ENODEV;
+		str->id = ++next;
+	}
+
+	cdev->next_string_id = next;
+
+	return 0;
+}
+
+/**
+ * usb_string_ids_n() - allocate unused string IDs in batch
+ * @cdev: the device whose string descriptor IDs are being allocated
+ * @n: number of string IDs to allocate
+ * Context: single threaded during gadget setup
+ *
+ * Returns the first requested ID.  This ID and next @n-1 IDs are now
+ * valid IDs.  At least providind that @n is non zore because if it
+ * is, returns last requested ID which is now very useful information.
+ *
+ * @usb_string_ids_n() is called from bind() callbacks to allocate
+ * string IDs.  Drivers for functions, configurations, or gadgets will
+ * then store that ID in the appropriate descriptors and string table.
+ *
+ * All string identifier should be allocated using this,
+ * @usb_string_id() or @usb_string_ids_n() routine, to ensure that for
+ * example different functions don't wrongly assign different meanings
+ * to the same identifier.
+ */
+int usb_string_ids_n(struct usb_composite_dev *c, unsigned n)
+{
+	unsigned next = c->next_string_id;
+	if (unlikely(n > 254 || (unsigned)next + n > 255))
+		return -ENODEV;
+	c->next_string_id += n;
+	return next + 1;
+}
+
+
 /*-------------------------------------------------------------------------*/
 
 static void composite_setup_complete(struct usb_ep *ep, struct usb_request *req)
include/linux/usb/composite.h +4 -0
index 139353e..f378075 100644
@@ -342,6 +342,10 @@ struct usb_composite_dev {
 };
 
 extern int usb_string_id(struct usb_composite_dev *c);
+extern int usb_string_ids_tab(struct usb_composite_dev *c,
+			      struct usb_string *str);
+extern int usb_string_ids_n(struct usb_composite_dev *c, unsigned n);
+
 
 /* messaging utils */
 #define DBG(d, fmt, args...) \
Signature · 1 line
1.7.1
#5 lore raw

PATCH 5/8 USB: gadget: f_fs: use usb_string_ids_n()

Use usb_string_ids_n() function to simplify string ids registeration.

---
 drivers/usb/gadget/f_fs.c |   29 ++++++++++++-----------------
 1 files changed, 12 insertions(+), 17 deletions(-)
drivers/usb/gadget/f_fs.c +12 -17
index 3fe120f..ffc0001 100644
@@ -1377,7 +1377,8 @@ static void ffs_data_reset(struct ffs_data *ffs)
 
 static int functionfs_bind(struct ffs_data *ffs, struct usb_composite_dev *cdev)
 {
-	unsigned i, count;
+	struct usb_gadget_strings **lang;
+	unsigned first_id;
 
 	ENTER();
 
@@ -1385,7 +1386,9 @@ static int functionfs_bind(struct ffs_data *ffs, struct usb_composite_dev *cdev)
 		 || test_and_set_bit(FFS_FL_BOUND, &ffs->flags)))
 		return -EBADFD;
 
-	ffs_data_get(ffs);
+	first_id = usb_string_ids_n(cdev, ffs->strings_count);
+	if (unlikely(first_id < 0))
+		return first_id;
 
 	ffs->ep0req = usb_ep_alloc_request(cdev->gadget->ep0, GFP_KERNEL);
 	if (unlikely(!ffs->ep0req))
@@ -1393,25 +1396,17 @@ static int functionfs_bind(struct ffs_data *ffs, struct usb_composite_dev *cdev)
 	ffs->ep0req->complete = ffs_ep0_complete;
 	ffs->ep0req->context = ffs;
 
-	/* Get strings identifiers */
-	for (count = ffs->strings_count, i = 0; i < count; ++i) {
-		struct usb_gadget_strings **lang;
-
-		int id = usb_string_id(cdev);
-		if (unlikely(id < 0)) {
-			usb_ep_free_request(cdev->gadget->ep0, ffs->ep0req);
-			ffs->ep0req = NULL;
-			return id;
+	lang = ffs->stringtabs;
+	while (*lang) {
+		struct usb_string *str = (*lang)->strings;
+		int id = first_id;
+		for (; str->s; ++id, ++str) {
+			str->id = id;
 		}
-
-		lang = ffs->stringtabs;
-		do {
-			(*lang)->strings[i].id = id;
-			++lang;
-		} while (*lang);
 	}
 
 	ffs->gadget = cdev->gadget;
+	ffs_data_get(ffs);
 	return 0;
 }
 
Signature · 1 line
1.7.1
#6 lore raw

PATCH 6/8 USB: gadget: g_multi: code clean up and refactoring

The Multifunction Compasite Gadget have been cleaned up and refactored so hopefully it looks prettier and works at least as good as before changes.

---
 drivers/usb/gadget/Kconfig |    1 +
 drivers/usb/gadget/multi.c |  262 +++++++++++++++++++++++++-------------------
 2 files changed, 148 insertions(+), 115 deletions(-)
drivers/usb/gadget/Kconfig +1 -0
index 649c0c5..1a3270d 100644
@@ -862,6 +862,7 @@ config USB_G_NOKIA
 config USB_G_MULTI
 	tristate "Multifunction Composite Gadget (EXPERIMENTAL)"
 	depends on BLOCK && NET
+	select USB_G_MULTI_CDC if ! USB_G_MULTI_RNDIS
 	help
 	  The Multifunction Composite Gadget provides Ethernet (RNDIS
 	  and/or CDC Ethernet), mass storage and ACM serial link
drivers/usb/gadget/multi.c +147 -115

404 lines not on this page · raw message

Signature · 1 line
1.7.1
#7 lore raw

PATCH 7/8 USB: gadget: g_multi: more configurable

Added Kconfig options for each function used by g_multi so that one can customize the gadget to a greater extend.

Note that it will be wise to change vendor and product ID when customising the gadget.

---
 drivers/usb/gadget/Kconfig |   67 +++++++++++------
 drivers/usb/gadget/multi.c |  166 +++++++++++++++++++------------------------
 2 files changed, 116 insertions(+), 117 deletions(-)
drivers/usb/gadget/Kconfig +43 -24
index 1a3270d..1309e46 100644
@@ -861,43 +861,62 @@ config USB_G_NOKIA
 
 config USB_G_MULTI
 	tristate "Multifunction Composite Gadget (EXPERIMENTAL)"
-	depends on BLOCK && NET
-	select USB_G_MULTI_CDC if ! USB_G_MULTI_RNDIS
+	select USB_G_MULTI_ACM if !USB_G_MULTI_ANYTHING
 	help
-	  The Multifunction Composite Gadget provides Ethernet (RNDIS
-	  and/or CDC Ethernet), mass storage and ACM serial link
-	  interfaces.
-
-	  You will be asked to choose which of the two configurations is
-	  to be available in the gadget.  At least one configuration must
-	  be chosen to make the gadget usable.  Selecting more than one
-	  configuration will prevent Windows from automatically detecting
-	  the gadget as a composite gadget, so an INF file will be needed to
-	  use the gadget.
+	  The Multifunction Composite Gadget provides several different
+	  configurations and functions.  Which interfaces are provided can
+	  be configured at build time.  If you choose this gadget additional
+	  options will appear.
 
 	  Say "y" to link the driver statically, or "m" to build a
 	  dynamically linked module called "g_multi".
 
-config USB_G_MULTI_RNDIS
-	bool "RNDIS + CDC Serial + Storage configuration"
+config USB_G_MULTI_ANYTHING
+	bool
 	depends on USB_G_MULTI
+
+config USB_G_MULTI_RNDIS
+	bool "Include RNDIS function"
+	depends on USB_G_MULTI && NET
+	select USB_G_MULTI_ANYTHING
 	default y
 	help
-	  This option enables a configuration with RNDIS, CDC Serial and
-	  Mass Storage functions available in the Multifunction Composite
-	  Gadget.  This is the configuration dedicated for Windows since RNDIS
-	  is Microsoft's protocol.
+	  This option enables the RNDIS (Ethernet) function.  It is
+	  protocol dedicated for Windows since it's Microsoft's invention.
+
+	  If you select also CDC ECM function gadget will have two
+	  configurations one with RNDIS and another with CDC ECM.
+
+	  If unsure, say "y".
+
+config USB_G_MULTI_ECM
+	bool "Include CDC ECM function"
+	depends on USB_G_MULTI && NET
+	select USB_G_MULTI_ANYTHING
+	help
+	  This option enables the CDC ECM (Ethernet) function.  
+
+	  If you select also RNDIS function gadget will have two
+	  configurations one with RNDIS and another with CDC ECM.
 
 	  If unsure, say "y".
 
-config USB_G_MULTI_CDC
-	bool "CDC Ethernet + CDC Serial + Storage configuration"
+config USB_G_MULTI_ACM
+	bool "Include CDC ACM function"
 	depends on USB_G_MULTI
-	default n
+	default y
+	help
+	  This option enables the CDC ACM (serial) function.  
+
+	  If unsure, say "y".
+
+config USB_G_MULTI_MSF
+	bool "Include mass storage function"
+	depends on USB_G_MULTI && BLOCK
+	select USB_G_MULTI_ANYTHING
+	default y
 	help
-	  This option enables a configuration with CDC Ethernet (ECM), CDC
-	  Serial and Mass Storage functions available in the Multifunction
-	  Composite Gadget.
+	  This option enables the mass storage (or UMS) function.  
 
 	  If unsure, say "y".
 
drivers/usb/gadget/multi.c +73 -93

242 lines not on this page · raw message

Signature · 1 line
1.7.1
#8 lore raw

PATCH 8/8 USB: gadget: g_multi: added documentation and INF files

A short documentation of the g_multi driver along with INF files for Windows XP SP3 are provided.

---
 Documentation/usb/gadget_multi.txt        |  129 +++++++++++++++++++
 Documentation/usb/gadget_multi_rndis.inf  |  200 +++++++++++++++++++++++++++++
 Documentation/usb/gadget_multi_serial.inf |   44 +++++++
 3 files changed, 373 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/usb/gadget_multi.txt
 create mode 100644 Documentation/usb/gadget_multi_rndis.inf
 create mode 100644 Documentation/usb/gadget_multi_serial.inf
Documentation/usb/gadget_multi.txt new file +129 -0
new file mode 100644
index 0000000..7365521
@@ -0,0 +1,129 @@
+                                                             -*- org -*-
+
+* Overview
+
+The Multifunction Composite Gadget (or g_multi) is a customisable
+composite gadget that makes extensive use of the composite framework
+to provide a... multifunction gadget.
+
+In it's standard configuration it provides a single USB configuration
+with RNDIS[1] (that is Ethernet), USB CDC[2] ACM (that is serial) and
+USB Mass Storage functions.
+
+Each function can be disabled via a Kconfig option.  There's also
+a CDC ECM (Ethernet) function which can be turned on.  If, however,
+CDC ECM and RNDIS are enabled the gadget will have two configurations
+-- one with RNDIS and another with CDC ECM[3].
+
+Please not, however, that if you use non-standard configuration you
+may need to change vendor and/or product ID.
+
+* Linux host drivers
+
+Since the gadget uses standard composite framework and appears as such
+to Linux host it does not need any additional drivers on Linux host
+side.  All the functions are handled by respective drivers designed
+for them.
+
+This is also true for two configuration set-up with RNDIS
+configuration being the first one.  Linux host will use the second
+configuration with CDC ECM which should work better under Linux.
+
+* Windows host drivers
+
+For the gadget two work under Windown two conditions have to be met:
+
+** Detecting as composite gadget
+
+First of all, Windows need to detect the gadget as an USB composite
+gadget (Microsoft calls it USB Generic Parent Driver[4]).  This on its
+own have some conditions[5].  The good news is that you don't have to
+worry about most of them.
+
+The only thing to worry is that Windows won't use its USB Generic
+Parent Driver unless the gadget has a single configuration so a dual
+RNDIS and CDC ECM gadget won't work unless you create an INF.  And of
+course, if you do submit it!
+
+** Attaching drivers for each function
+
+The other, trickier thing is making Windows attach drivers to each
+individual function.
+
+For mass storage it is trivial since Windows detect it's an USB Mass
+Storage class and selects appropriate driver.
+
+Things are harder with RDNIS and CDC ACM.
+
+*** RNDIS
+
+To make Windows select RNDIS drivers for the first function in the
+gadget, one needs to use the [[file:gadget_multi_rndis.inf]] file
+provided with this document.  It "attaches" Window's RNDIS driver to
+the first interface of the gadget.
+
+*** CDC ACM
+
+Similarly, [[file:gadget_multi_serial.inf]] is provided for CDC ACM.
+Note, however that it also requires an usbser.sys file which can be
+extracted form Windows XP SP3 cab files.
+
+It is important to note that this works only with this particular
+version of the usbser.sys file and not the other versions that can be
+found on the Internet.
+
+*** Customising the gadget
+
+It is important to note, that after customising g_multi interface
+numbers change and so provided INF files will most likely stop working
+due to interface number mismatch.
+
+This also means, that after changing the set of functions available in
+g_multi one should change gadget's vendor and/or product ID so there
+will be no collision with other customised gadgets or the original
+gadget.
+
+*** Improvements in INF files
+
+It needs to be noted that we are not Windows driver experts and as
+such we do not claim that provided INF files are the flawless or that
+they will work on each and every Windows versions (they were tested on
+Windows XP SP3 only).
+
+The bottom line is, if you can improve the INF files, please do and
+share the results. :)
+
+* Other systems
+
+At this moment, drivers for any other systems have not been tested.
+Knowing how MacOS is based on BSD and BSD is an Open Source it is
+believed that (read: "I have no idea whether"), unlike under Windows,
+it should work out-of-the-box.
+
+For more exotic systems I have even less to say...
+
+Any testing and drivers *are* *welcome*!
+
+* Authors
+
+This document has been written by Michal Nazarewicz
+([[mailto:[email protected]]]) and the INF files have been
+hacked by Marek Szyprowski ([[mailto:[email protected]]])
+basing on the [[file:linux.inf]] file provided for Ethernet gadget
+and description from [[file:gadget_serial.txt]].
+
+* Footnotes
+
+[1] Remote Network Driver Interface Specification,
+[[http://msdn.microsoft.com/en-us/library/ee484414.aspx]].
+
+[2] Communications Device Class Abstract Control Model, spec for this
+and other USB classes can be found at
+[[http://www.usb.org/developers/devclass_docs/]].
+
+[3] CDC Ethernet Control Model.
+
+[4] [[http://msdn.microsoft.com/en-us/library/ff539234(v=VS.85).aspx]].
+
+[5] [[http://msdn.microsoft.com/en-us/library/ff537109(v=VS.85).aspx]].
+
Documentation/usb/gadget_multi_rndis.inf new file +200 -0

200 lines not on this page · raw message

Documentation/usb/gadget_multi_serial.inf new file +44 -0

44 lines not on this page · raw message

Signature · 1 line
1.7.1
#9 lore raw

Re: [PATCH 7/8] USB: gadget: g_multi: more configurable

In reply to Michal Nazarewicz
Quoted 6 lines

Added Kconfig options for each
function used by g_multi so that
one can customize the gadget to a greater extend.

Note that it will be wise to change vendor and product ID

For the record .... I would *MUCH* rather see new gadgets than pursue this path of tweaking/customizing existing ones and thus removing/changing behaviors folk may rely on.

Tweaking is OK during certain development stages, but when it comes to production, there should be a single version of the gadget driver which isn't especially dependant on Kconfig options. It should act the same at all times.

#10 lore raw

Re: [PATCH 7/8] USB: gadget: g_multi: more configurable

Quoted 5 lines
Quoted 5 lines

Added Kconfig options for each
function used by g_multi so that
one can customize the gadget to a greater extend.

Note that it will be wise to change vendor and product ID

Quoted 3 lines · David Brownell

For the record .... I would *MUCH* rather see new gadgets than pursue this path of tweaking/customizing existing ones and thus removing/changing behaviors folk may rely on.

The problem with this approach is that if you have 4 USB functions you can came up with 16 different gadgets (and that does not take into consideration order of functions but lets ignore that).

A fully customizable gadget may let one tweak it and when he finally settles for a set of functions develop a custom gadget (for instance by hacking off parts of the g_multi).

I don't really expect g_multi will be widely used in its base form. Most likely, it will be hacked and slashed for one's needs so why not make it simple to do?

Quoted 4 lines

Tweaking is OK during certain development stages, but when it comes to production, there should be a single version of the gadget driver which isn't especially dependant on Kconfig options. It should act the same at all times.

Quoted 3 lines · David Brownell

Note that g_multi was intended to be a a fairly simple example, so another reason I don't like seeing all those config options is that it would no longer be a simple example ....

To be honest it was never my intend. :) As a matter of fact, I'm working on other features to add to g_multi, most notably at the moment an "Install Mode" or "NoCD" mode.

In the end, I'd like to turn g_multi into a full flagged run-time customizable composite gadget similar to Android's composite (except better ;) ) so that one would be able to build her own composite gadget in a matter of seconds without the need of calling all the setup, cleanup, bind, etc. functions herself.

Quoted 4 lines

I see you did a bunch of good work on MS-Windows interop (yay!), but that can be done without complexifying this driver. Let some other (new) driver take that role of "complex example"), but keep the simple one so there's an easy approach to the easy concepts.

All in all, if I understand your point correctly, you have only issue with the 7th patch which introduces Kconfig options. All the other patches seem OK, or do you have some comments on those as well?

Signature · 4 lines
Best regards,                                        _     _
| Humble Liege of Serenely Enlightened Majesty of  o' \,=./ `o
| Computer Science,  Michał "mina86" Nazarewicz       (o o)
+----[mina86*mina86.com]---[mina86*jabber.org]----ooO--(_)--Ooo--
#11 lore raw

Re: [PATCH 7/8] USB: gadget: g_multi: more configurable

In reply to Michal Nazarewicz
Quoted 4 lines

Added Kconfig options for each
function used by g_multi so that
one can customize the gadget to a greater extend.

Note that g_multi was intended to be a a fairly simple example, so another reason I don't like seeing all those config options is that it would no longer be a simple example ....

I see you did a bunch of good work on MS-Windows interop (yay!), but that can be done without complexifying this driver. Let some other (new) driver take that role of "complex example"), but keep the simple one so there's an easy approach to the easy concepts.

#12 lore raw

Re: [PATCH 5/8] USB: gadget: f_fs: use usb_string_ids_n()

In reply to Michal Nazarewicz

Hello.

Quoted 5 lines · Michal Nazarewicz

Use usb_string_ids_n() function to simplify string ids registeration.

[...]

Quoted 4 lines
drivers/usb/gadget/f_fs.c +0 -0
index 3fe120f..ffc0001 100644

[...]

Quoted 10 lines
drivers/usb/gadget/f_fs.c +0 -6
@@ -1393,25 +1396,17 @@ static int functionfs_bind(struct ffs_data *ffs, struct usb_composite_dev *cdev)
 	ffs->ep0req->complete = ffs_ep0_complete;
 	ffs->ep0req->context = ffs;
 
-	/* Get strings identifiers */
-	for (count = ffs->strings_count, i = 0; i < count; ++i) {
-		struct usb_gadget_strings **lang;
-
-		int id = usb_string_id(cdev);
-		if (unlikely(id < 0)) {

drivers/usb/gadget/f_fs.c static int functionfs_bind(struct ffs_data *ffs, struct usb_composite_dev *cdev) · line 1405

Quoted 10 lines
drivers/usb/gadget/f_fs.c +6 -3
-			usb_ep_free_request(cdev->gadget->ep0, ffs->ep0req);
-			ffs->ep0req = NULL;
-			return id;
+	lang = ffs->stringtabs;
+	while (*lang) {
+		struct usb_string *str = (*lang)->strings;
+		int id = first_id;
+		for (; str->s; ++id, ++str) {
+			str->id = id;
 		}

{} not needed here.

WBR, Sergei

#13 lore raw

Re: [PATCH 5/8] USB: gadget: f_fs: use usb_string_ids_n()

Quoted 21 lines
Quoted 20 lines · Michal Nazarewicz
drivers/usb/gadget/f_fs.c +6 -9
@@ -1393,25 +1396,17 @@ static int functionfs_bind(struct ffs_data *ffs, struct usb_composite_dev *cdev)
 	ffs->ep0req->complete = ffs_ep0_complete;
 	ffs->ep0req->context = ffs;
 
-	/* Get strings identifiers */
-	for (count = ffs->strings_count, i = 0; i < count; ++i) {
-		struct usb_gadget_strings **lang;
-
-		int id = usb_string_id(cdev);
-		if (unlikely(id < 0)) {
-			usb_ep_free_request(cdev->gadget->ep0, ffs->ep0req);
-			ffs->ep0req = NULL;
-			return id;
+	lang = ffs->stringtabs;
+	while (*lang) {
+		struct usb_string *str = (*lang)->strings;
+		int id = first_id;
+		for (; str->s; ++id, ++str) {
+			str->id = id;
 		}
Quoted 1 line · Sergei Shtylyov

{} not needed here.

Thanks.

I'll wait for some other comments and resend the patchset or this single patch or whatever will be appropriate.

Signature · 4 lines
Best regards,                                        _     _
| Humble Liege of Serenely Enlightened Majesty of  o' \,=./ `o
| Computer Science,  Michał "mina86" Nazarewicz       (o o)
+----[mina86*mina86.com]---[mina86*jabber.org]----ooO--(_)--Ooo--
#14 lore raw
In reply to Michal Nazarewicz
Quoted 2 lines · Michal Nazarewicz

This patchset introduces several improvements to USB gadget, functions, etc.:

Uh, damn, sorry for posting those twice. I did a:

  git send-email * --to [email protected] 000*

ie. given all files as arguments twice.

Signature · 4 lines
Best regards,                                        _     _
| Humble Liege of Serenely Enlightened Majesty of  o' \,=./ `o
| Computer Science,  Michał "mina86" Nazarewicz       (o o)
+----[mina86*mina86.com]---[mina86*jabber.org]----ooO--(_)--Ooo--
#15 lore raw
Quoted 9 lines · Michał Nazarewicz
Quoted 2 lines · Michal Nazarewicz

This patchset introduces several improvements to USB gadget, functions, etc.:

Uh, damn, sorry for posting those twice. I did a:

   git send-email * --to [email protected] 000*

ie. given all files as arguments twice.

Please always cc: the usb subsystem maintainer if you wish to have the patches applied. Otherwise they can easily be missed...

thanks,

greg k-h

#16 lore raw
In reply to Michal Nazarewicz

Uh... Wow...

I am *terribly* *sorry* for posting those three times...

This time I forgot about --dry-run. So embarrassed.

Apparently posting patches first thing in the morning is not such a good idea.

Apologies once again.

Signature · 4 lines
Best regards,                                        _     _
| Humble Liege of Serenely Enlightened Majesty of  o' \,=./ `o
| Computer Science,  Michał "mina86" Nazarewicz       (o o)
+----[mina86*mina86.com]---[mina86*jabber.org]----ooO--(_)--Ooo--