]> git.sur5r.net Git - openocd/commitdiff
drivers: cmsis-dap: pull up common connect code
authorKarl Palsson <karlp@tweak.net.au>
Wed, 13 Apr 2016 23:42:48 +0000 (23:42 +0000)
committerTomas Vanek <vanekt@fbl.cz>
Wed, 18 Jul 2018 20:07:43 +0000 (21:07 +0100)
Just a minor deduplication

Change-Id: Idd256883e5f6d4bd4dcc18462dd5468991f507b3
Signed-off-by: Karl Palsson <karlp@tweak.net.au>
Reviewed-on: http://openocd.zylin.com/3403
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
src/jtag/drivers/cmsis_dap_usb.c

index 6b010c1d68753d433f7f7b52fe4701503e2de102..a0922d4651ea479b8bce1992acea44877a4195ed 100644 (file)
@@ -841,17 +841,6 @@ static int cmsis_dap_swd_open(void)
 {
        int retval;
 
-       if (cmsis_dap_handle == NULL) {
-               /* SWD init */
-               retval = cmsis_dap_usb_open();
-               if (retval != ERROR_OK)
-                       return retval;
-
-               retval = cmsis_dap_get_caps_info();
-               if (retval != ERROR_OK)
-                       return retval;
-       }
-
        if (!(cmsis_dap_handle->caps & INFO_CAPS_SWD)) {
                LOG_ERROR("CMSIS-DAP: SWD not supported");
                return ERROR_JTAG_DEVICE_ERROR;
@@ -872,6 +861,14 @@ static int cmsis_dap_init(void)
        int retval;
        uint8_t *data;
 
+       retval = cmsis_dap_usb_open();
+       if (retval != ERROR_OK)
+               return retval;
+
+       retval = cmsis_dap_get_caps_info();
+       if (retval != ERROR_OK)
+               return retval;
+
        if (swd_mode) {
                retval = cmsis_dap_swd_open();
                if (retval != ERROR_OK)
@@ -879,16 +876,6 @@ static int cmsis_dap_init(void)
        }
 
        if (cmsis_dap_handle == NULL) {
-
-               /* JTAG init */
-               retval = cmsis_dap_usb_open();
-               if (retval != ERROR_OK)
-                       return retval;
-
-               retval = cmsis_dap_get_caps_info();
-               if (retval != ERROR_OK)
-                       return retval;
-
                /* Connect in JTAG mode */
                if (!(cmsis_dap_handle->caps & INFO_CAPS_JTAG)) {
                        LOG_ERROR("CMSIS-DAP: JTAG not supported");