[PATCH v4 04/12] libusbg: Move directory creation before writing attributes.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Change order of gadget creation and attribute writting
to fix  No such file or directory error while creating
new gadget.

Change-Id: Ibf36f7350b4e9fe38c31edb1fffbaebaf4697530
Signed-off-by: Krzysztof Opasiak <k.opasiak@xxxxxxxxxxx>
---
 src/usbg.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/usbg.c b/src/usbg.c
index 51722a1..e222392 100644
--- a/src/usbg.c
+++ b/src/usbg.c
@@ -510,15 +510,15 @@ struct gadget *usbg_create_gadget(struct state *s, char *name,
 	g->vendor = vendor;
 	g->product = product;
 
-	usbg_write_hex16(s->path, name, "idVendor", vendor);
-	usbg_write_hex16(s->path, name, "idProduct", product);
-
 	ret = mkdir(gpath, S_IRWXU|S_IRWXG|S_IRWXO);
 	if (ret < 0) {
 		ERRORNO("%s\n", gpath);
 		return NULL;
 	}
 
+	usbg_write_hex16(s->path, name, "idVendor", vendor);
+	usbg_write_hex16(s->path, name, "idProduct", product);
+
 	/* Insert in string order */
 	if (TAILQ_EMPTY(&s->gadgets) ||
 	    (strcmp(name, TAILQ_FIRST(&s->gadgets)->name) < 0))
@@ -642,14 +642,14 @@ struct function *usbg_create_function(struct gadget *g, enum function_type type,
 	sprintf(f->path, "%s/%s/%s", g->path, g->name, "functions");
 	f->type = type;
 
-	usbg_parse_function_attrs(f);
-
 	ret = mkdir(fpath, S_IRWXU|S_IRWXG|S_IRWXO);
 	if (ret < 0) {
 		ERRORNO("%s\n", fpath);
 		return NULL;
 	}
 
+	usbg_parse_function_attrs(f);
+
 	/* Insert in string order */
 	if (TAILQ_EMPTY(&g->functions) ||
 	    (strcmp(name, TAILQ_FIRST(&g->functions)->name) < 0))
-- 
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