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

Signed-off-by: Krzysztof Opasiak <k.opas...@samsung.com>
---
 src/gadget.c |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/gadget.c b/src/gadget.c
index 31adb67..2686d62 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 majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to