libusbgx: Initialize gadget attributes and strings while gadget creation.
authorKrzysztof Opasiak <k.opasiak@samsung.com>
Mon, 16 Dec 2013 10:00:26 +0000 (11:00 +0100)
committerKrzysztof Opasiak <k.opasiak@samsung.com>
Tue, 22 Dec 2015 19:33:56 +0000 (20:33 +0100)
Fix gadget_create_gadget function to initialize gadget attributes
and strings with default values provided by kernel.

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 11a9abf..9ee3d35 100644 (file)
@@ -526,8 +526,6 @@ struct gadget *usbg_create_gadget(struct state *s, char *name,
        strcpy(g->name, name);
        sprintf(g->path, "%s", s->path);
        g->parent = s;
-       g->vendor = vendor;
-       g->product = product;
 
        ret = mkdir(gpath, S_IRWXU|S_IRWXG|S_IRWXO);
        if (ret < 0) {
@@ -539,6 +537,9 @@ struct gadget *usbg_create_gadget(struct state *s, char *name,
        usbg_write_hex16(s->path, name, "idVendor", vendor);
        usbg_write_hex16(s->path, name, "idProduct", product);
 
+       usbg_parse_attrs(s->path, g);
+       usbg_parse_strings(s->path, g);
+
        /* Insert in string order */
        if (TAILQ_EMPTY(&s->gadgets) ||
            (strcmp(name, TAILQ_FIRST(&s->gadgets)->name) < 0))