libusbgx: Separate parsing gadget attributes and strings.
authorKrzysztof Opasiak <k.opasiak@samsung.com>
Mon, 16 Dec 2013 09:58:45 +0000 (10:58 +0100)
committerKrzysztof Opasiak <k.opasiak@samsung.com>
Tue, 22 Dec 2015 19:33:56 +0000 (20:33 +0100)
Gadget attributes and strings are logically independent,
so they should be initialized in separate functions.

Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
[Port from libusbg and update description]
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
src/usbg.c

index ab9f253..11a9abf 100644 (file)
@@ -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);