thor: add support for dfu_alt_info reintialization from the downloaded script 43/248843/2
authorMarek Szyprowski <m.szyprowski@samsung.com>
Fri, 27 Nov 2020 15:10:34 +0000 (16:10 +0100)
committerMarek Szyprowski <m.szyprowski@samsung.com>
Thu, 3 Dec 2020 16:53:18 +0000 (17:53 +0100)
Reinitialize dfu_env_entities after flashing the 'SCRIPT' entity to
ensure that the potential changes to the 'dfu_alt_info' environment
variable are applied.

Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Change-Id: Iad98f348d25ee37fbb7493d4e567d1a4de55dc2c

cmd/thordown.c
drivers/usb/gadget/f_thor.c
include/thor.h

index a817e89..9c96cf4 100644 (file)
@@ -75,13 +75,18 @@ int do_thor_down(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
                goto exit;
        }
 
-       ret = thor_handle();
-       if (ret) {
-               pr_err("THOR failed: %d\n", ret);
-               ret = CMD_RET_FAILURE;
-               goto exit;
-       }
-
+       do {
+               ret = thor_handle();
+               if (ret == THOR_DFU_REINIT_NEEDED) {
+                       dfu_free_entities();
+                       ret = dfu_init_env_entities(interface, devstring);
+               }
+               if (ret) {
+                       pr_err("THOR failed: %d\n", ret);
+                       ret = CMD_RET_FAILURE;
+                       goto exit;
+               }
+       } while (ret == 0);
 exit:
        g_dnl_unregister();
        usb_gadget_release(controller_index);
index 1368684..54c3261 100644 (file)
@@ -35,6 +35,7 @@
 #include <samsung/misc.h>
 #include <linux/input.h>
 #include <usb.h>
+#include <thor.h>
 
 #include "f_thor.h"
 
@@ -805,6 +806,8 @@ int thor_handle(void)
                        printf("%s: No data received!\n", __func__);
                        return ret;
                }
+               if (dfu_reinit_needed)
+                       return THOR_DFU_REINIT_NEEDED;
        }
 
        return 0;
index 62501bd..ee67ab0 100644 (file)
@@ -12,6 +12,8 @@
 
 #include <linux/usb/composite.h>
 
+#define THOR_DFU_REINIT_NEEDED 0xFFFFFFFE
+
 int thor_handle(void);
 int thor_init(void);
 int thor_add(struct usb_configuration *c);