drivers: cmsis-dap: pull up common connect code

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>
bscan_tunnel
Karl Palsson 2016-04-13 23:42:48 +00:00 committed by Tomas Vanek
parent 3a5b2b66db
commit 5aceec2412
1 changed files with 8 additions and 21 deletions

View File

@ -841,17 +841,6 @@ static int cmsis_dap_swd_open(void)
{ {
int retval; 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)) { if (!(cmsis_dap_handle->caps & INFO_CAPS_SWD)) {
LOG_ERROR("CMSIS-DAP: SWD not supported"); LOG_ERROR("CMSIS-DAP: SWD not supported");
return ERROR_JTAG_DEVICE_ERROR; return ERROR_JTAG_DEVICE_ERROR;
@ -872,15 +861,6 @@ static int cmsis_dap_init(void)
int retval; int retval;
uint8_t *data; uint8_t *data;
if (swd_mode) {
retval = cmsis_dap_swd_open();
if (retval != ERROR_OK)
return retval;
}
if (cmsis_dap_handle == NULL) {
/* JTAG init */
retval = cmsis_dap_usb_open(); retval = cmsis_dap_usb_open();
if (retval != ERROR_OK) if (retval != ERROR_OK)
return retval; return retval;
@ -889,6 +869,13 @@ static int cmsis_dap_init(void)
if (retval != ERROR_OK) if (retval != ERROR_OK)
return retval; return retval;
if (swd_mode) {
retval = cmsis_dap_swd_open();
if (retval != ERROR_OK)
return retval;
}
if (cmsis_dap_handle == NULL) {
/* Connect in JTAG mode */ /* Connect in JTAG mode */
if (!(cmsis_dap_handle->caps & INFO_CAPS_JTAG)) { if (!(cmsis_dap_handle->caps & INFO_CAPS_JTAG)) {
LOG_ERROR("CMSIS-DAP: JTAG not supported"); LOG_ERROR("CMSIS-DAP: JTAG not supported");