From e4d9cbf6ccdfc7210b61249146d62a2770573c69 Mon Sep 17 00:00:00 2001 From: Krzysztof Opasiak Date: Wed, 6 Dec 2017 22:06:16 +0100 Subject: [PATCH] libusbgx: Make usbg_rm_config() aware of OS descriptors Since we added support for OS descriptors we allowed user to create a link in gadget's os_desc directory to choose one of available configurations. This link prevents config from being removed. This makes our rm funcitons stop working with the recursive option. To fix this, let's make them OS desc aware and remove this link before trying to remove configuration if recurse option is set. Signed-off-by: Krzysztof Opasiak --- src/usbg.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/usbg.c b/src/usbg.c index 00fc55e..061f383 100644 --- a/src/usbg.c +++ b/src/usbg.c @@ -1248,12 +1248,20 @@ int usbg_rm_config(usbg_config *c, int opts) g = c->parent; if (opts & USBG_RM_RECURSE) { - /* Recursive flag was given - * so remove all bindings and strings */ + /* + * Recursive flag was given + * so remove all bindings and strings + */ char spath[USBG_MAX_PATH_LENGTH]; int nmb; usbg_binding *b; + if (c->parent->os_desc_binding == c) { + ret = usbg_set_os_desc_config(g, NULL); + if (ret != USBG_SUCCESS) + goto out; + } + while (!TAILQ_EMPTY(&c->bindings)) { b = TAILQ_FIRST(&c->bindings); ret = usbg_rm_binding(b); -- 2.7.4