From 301666cb3c31fdf267bda5f1390f37ca06ffe069 Mon Sep 17 00:00:00 2001 From: Krzysztof Opasiak Date: Mon, 16 Dec 2013 11:00:26 +0100 Subject: [PATCH] libusbgx: Initialize gadget attributes and strings while gadget creation. Fix gadget_create_gadget function to initialize gadget attributes and strings with default values provided by kernel. Signed-off-by: Krzysztof Opasiak [Port from libusbg and update description] Signed-off-by: Krzysztof Opasiak --- src/usbg.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/usbg.c b/src/usbg.c index 11a9abf..9ee3d35 100644 --- a/src/usbg.c +++ b/src/usbg.c @@ -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)) -- 2.7.4