[PATCH 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/gadget.c |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/gadget.c b/src/gadget.c
index 40da70f..04fe46b 100644
--- a/src/gadget.c
+++ b/src/gadget.c
@@ -314,9 +314,6 @@ static int gadget_parse_configs(char *path, struct gadget *g)
 
 static void gadget_parse_attrs(char *path, struct gadget *g)
 {
-	/* UDC bound to, if any */
-	gadget_read_string(path, g->name, "UDC", g->udc);
-
 	/* Actual attributes */
 	g->dclass = gadget_read_hex(path, g->name, "bDeviceClass");
 	g->dsubclass = gadget_read_hex(path, g->name, "bDeviceSubClass");
@@ -326,7 +323,10 @@ static void gadget_parse_attrs(char *path, struct gadget *g)
 	g->bcdusb = gadget_read_hex(path, g->name, "bcdUSB");
 	g->vendor = gadget_read_hex(path, g->name, "idVendor");
 	g->product = gadget_read_hex(path, g->name, "idProduct");
+}
 
+static void gadget_parse_strings(char *path, struct gadget *g)
+{
 	/* Strings - hardcoded to U.S. English only for now */
 	gadget_read_string(path, g->name, "strings/0x409/serialnumber", g->str_ser);
 	gadget_read_string(path, g->name, "strings/0x409/manufacturer", g->str_mnf);
@@ -347,7 +347,10 @@ static int gadget_parse_gadgets(char *path, struct state *s)
 		strcpy(g->name, dent[i]->d_name);
 		strcpy(g->path, s->path);
 		g->parent = s;
+		/* UDC bound to, if any */
+		gadget_read_string(path, g->name, "UDC", g->udc);
 		gadget_parse_attrs(path, g);
+		gadget_parse_strings(path, g);
 		gadget_parse_functions(path, g);
 		gadget_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