[PATCH v5 08/12] libusbg: Separate parsing gadget attributes and strings.

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

 



Gadget attributes and strings are logically independent,
so they should be initialized in separate functions.

Signed-off-by: Krzysztof Opasiak <k.opasiak@xxxxxxxxxxx>
---
 src/usbg.c |   11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/usbg.c b/src/usbg.c
index ab9f253..11a9abf 100644
--- a/src/usbg.c
+++ b/src/usbg.c
@@ -319,9 +319,6 @@ static int usbg_parse_configs(char *path, struct gadget *g)
 
 static void usbg_parse_attrs(char *path, struct gadget *g)
 {
-	/* UDC bound to, if any */
-	usbg_read_string(path, g->name, "UDC", g->udc);
-
 	/* Actual attributes */
 	g->dclass = usbg_read_hex(path, g->name, "bDeviceClass");
 	g->dsubclass = usbg_read_hex(path, g->name, "bDeviceSubClass");
@@ -331,7 +328,10 @@ static void usbg_parse_attrs(char *path, struct gadget *g)
 	g->bcdusb = usbg_read_hex(path, g->name, "bcdUSB");
 	g->vendor = usbg_read_hex(path, g->name, "idVendor");
 	g->product = usbg_read_hex(path, g->name, "idProduct");
+}
 
+static void usbg_parse_strings(char *path, struct gadget *g)
+{
 	/* Strings - hardcoded to U.S. English only for now */
 	usbg_read_string(path, g->name, "strings/0x409/serialnumber", g->str_ser);
 	usbg_read_string(path, g->name, "strings/0x409/manufacturer", g->str_mnf);
@@ -352,7 +352,10 @@ static int usbg_parse_gadgets(char *path, struct state *s)
 		strcpy(g->name, dent[i]->d_name);
 		strcpy(g->path, s->path);
 		g->parent = s;
-		usbg_parse_attrs(path, g);
+		/* UDC bound to, if any */
+		usbg_read_string(path, g->name, "UDC", g->udc);
+		usbg_parse_configs(path, g);
+		usbg_parse_strings(path, g);
 		usbg_parse_functions(path, g);
 		usbg_parse_configs(path, g);
 		TAILQ_INSERT_TAIL(&s->gadgets, g, gnode);
-- 
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