summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKrzysztof Opasiak <k.opasiak@samsung.com>2017-12-06 22:06:16 +0100
committerKrzysztof Opasiak <k.opasiak@samsung.com>2017-12-12 14:06:36 +0100
commite4d9cbf6ccdfc7210b61249146d62a2770573c69 (patch)
treeb59434406132b7adcf109f92ea3ada706b9407fd
parent952f19c7ce13a454f699830c8138d1ad82805a0b (diff)
downloadlibusbg-e4d9cbf6ccdfc7210b61249146d62a2770573c69.tar.gz
libusbg-e4d9cbf6ccdfc7210b61249146d62a2770573c69.tar.bz2
libusbg-e4d9cbf6ccdfc7210b61249146d62a2770573c69.zip
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 <k.opasiak@samsung.com>
-rw-r--r--src/usbg.c12
1 files 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);