summaryrefslogtreecommitdiffstats
path: root/patches/libusbgx-0.2.0/0003-examples-gadget-vid-pid-remove-add-dynamic-vid-pid-s.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patches/libusbgx-0.2.0/0003-examples-gadget-vid-pid-remove-add-dynamic-vid-pid-s.patch')
-rw-r--r--patches/libusbgx-0.2.0/0003-examples-gadget-vid-pid-remove-add-dynamic-vid-pid-s.patch67
1 files changed, 67 insertions, 0 deletions
diff --git a/patches/libusbgx-0.2.0/0003-examples-gadget-vid-pid-remove-add-dynamic-vid-pid-s.patch b/patches/libusbgx-0.2.0/0003-examples-gadget-vid-pid-remove-add-dynamic-vid-pid-s.patch
new file mode 100644
index 000000000..63ddf347f
--- /dev/null
+++ b/patches/libusbgx-0.2.0/0003-examples-gadget-vid-pid-remove-add-dynamic-vid-pid-s.patch
@@ -0,0 +1,67 @@
+From: Michael Grzeschik <m.grzeschik@pengutronix.de>
+Date: Wed, 28 Apr 2021 21:43:07 +0200
+Subject: [PATCH] examples: gadget-vid-pid-remove: add dynamic vid pid support
+
+Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
+---
+ examples/gadget-vid-pid-remove.c | 25 ++++++++++++++++++++-----
+ 1 file changed, 20 insertions(+), 5 deletions(-)
+
+diff --git a/examples/gadget-vid-pid-remove.c b/examples/gadget-vid-pid-remove.c
+index f6b950b38da3..f5eb9664b721 100644
+--- a/examples/gadget-vid-pid-remove.c
++++ b/examples/gadget-vid-pid-remove.c
+@@ -23,11 +23,10 @@
+
+ #include <errno.h>
+ #include <stdio.h>
++#include <string.h>
++#include <stdlib.h>
+ #include <usbg/usbg.h>
+
+-#define VENDOR 0x1d6b
+-#define PRODUCT 0x0104
+-
+ int remove_gadget(usbg_gadget *g)
+ {
+ int usbg_ret;
+@@ -60,13 +59,29 @@ out:
+ return usbg_ret;
+ }
+
+-int main(void)
++int main(int argc, char **argv)
+ {
+ int usbg_ret;
+ int ret = -EINVAL;
+ usbg_state *s;
+ usbg_gadget *g;
+ struct usbg_gadget_attrs g_attrs;
++ char *cp;
++ int vendor = 0x1d6b, product = 0x0104;
++
++ if (argc >= 2) {
++ cp = strchr(argv[1], ':');
++ if (!cp) {
++ ret = -EINVAL;
++ fprintf(stderr, "Usage: gadget-vid-pid-remove vid:pid\n");
++ goto out1;
++ }
++ *cp++ = 0;
++ if (&argv[1])
++ vendor = strtoul(argv[1], NULL, 16);
++ if (*cp)
++ product = strtoul(cp, NULL, 16);
++ }
+
+ usbg_ret = usbg_init("/sys/kernel/config", &s);
+ if (usbg_ret != USBG_SUCCESS) {
+@@ -88,7 +103,7 @@ int main(void)
+ }
+
+ /* Compare attrs with given values and remove if suitable */
+- if (g_attrs.idVendor == VENDOR && g_attrs.idProduct == PRODUCT) {
++ if (g_attrs.idVendor == vendor && g_attrs.idProduct == product) {
+ usbg_gadget *g_next = usbg_get_next_gadget(g);
+
+ usbg_ret = remove_gadget(g);