Skip to content

Commit 8b751e0

Browse files
committed
jtag: drivers: prepare for aligning switch and case statements
To prepare for aligning switch and case statements, fix in advance some checkpatch error due to existing code: - remove 'else' after return and break; - use '__func__' in place of hardcoded function name; - remove useless parenthesis; - don't end line with an open parenthesis. Change-Id: I6a9905e5a30c90456de562e727dd2dfe2fda10c4 Signed-off-by: Antonio Borneo <[email protected]> Reviewed-on: https://review.openocd.org/c/openocd/+/9054 Reviewed-by: zapb <[email protected]> Tested-by: jenkins
1 parent 8a50464 commit 8b751e0

File tree

4 files changed

+28
-47
lines changed

4 files changed

+28
-47
lines changed

src/jtag/drivers/ft232r.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -821,11 +821,11 @@ static int syncbb_execute_queue(struct jtag_command *cmd_queue)
821821
case JTAG_RESET:
822822
LOG_DEBUG_IO("reset trst: %i srst %i", cmd->cmd.reset->trst, cmd->cmd.reset->srst);
823823

824-
if ((cmd->cmd.reset->trst == 1) ||
825-
(cmd->cmd.reset->srst &&
826-
(jtag_get_reset_config() & RESET_SRST_PULLS_TRST))) {
824+
if (cmd->cmd.reset->trst == 1 ||
825+
(cmd->cmd.reset->srst &&
826+
(jtag_get_reset_config() & RESET_SRST_PULLS_TRST)))
827827
tap_set_state(TAP_RESET);
828-
}
828+
829829
ft232r_reset(cmd->cmd.reset->trst, cmd->cmd.reset->srst);
830830
break;
831831

src/jtag/drivers/kitprog.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -652,10 +652,9 @@ static int kitprog_swd_switch_seq(enum swd_special_seq seq)
652652
if (kitprog_swd_seq(SEQUENCE_JTAG_TO_SWD) != ERROR_OK)
653653
return ERROR_FAIL;
654654
break;
655-
} else {
656-
LOG_DEBUG("JTAG to SWD not supported");
657-
/* Fall through to fix target reset issue */
658655
}
656+
LOG_DEBUG("JTAG to SWD not supported");
657+
/* Fall through to fix target reset issue */
659658
/* fallthrough */
660659
case LINE_RESET:
661660
LOG_DEBUG("SWD line reset");

src/jtag/drivers/rlink.c

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -332,33 +332,22 @@ static int dtc_load_from_buffer(struct libusb_device_handle *hdev_param, const u
332332

333333
case DTCLOAD_LOAD:
334334
/* Send the DTC program to ST7 RAM. */
335-
usb_err = ep1_memory_write(
336-
hdev_param,
337-
DTC_LOAD_BUFFER,
338-
header->length + 1, buffer
339-
);
335+
usb_err = ep1_memory_write(hdev_param, DTC_LOAD_BUFFER,
336+
header->length + 1, buffer);
340337
if (usb_err < 0)
341338
return usb_err;
342339

343340
/* Load it into the DTC. */
344-
usb_err = ep1_generic_commandl(
345-
hdev_param, 3,
346-
EP1_CMD_DTC_LOAD,
347-
(DTC_LOAD_BUFFER >> 8),
348-
DTC_LOAD_BUFFER
349-
);
341+
usb_err = ep1_generic_commandl(hdev_param, 3, EP1_CMD_DTC_LOAD,
342+
(DTC_LOAD_BUFFER >> 8), DTC_LOAD_BUFFER);
350343
if (usb_err < 0)
351344
return usb_err;
352345

353346
break;
354347

355348
case DTCLOAD_RUN:
356-
usb_err = ep1_generic_commandl(
357-
hdev_param, 3,
358-
EP1_CMD_DTC_CALL,
359-
buffer[0],
360-
EP1_CMD_DTC_WAIT
361-
);
349+
usb_err = ep1_generic_commandl(hdev_param, 3, EP1_CMD_DTC_CALL,
350+
buffer[0], EP1_CMD_DTC_WAIT);
362351
if (usb_err < 0)
363352
return usb_err;
364353

@@ -369,11 +358,8 @@ static int dtc_load_from_buffer(struct libusb_device_handle *hdev_param, const u
369358
break;
370359

371360
case DTCLOAD_LUT:
372-
usb_err = ep1_memory_write(
373-
hdev_param,
374-
ST7_USB_BUF_EP0OUT + lut_start,
375-
header->length + 1, buffer
376-
);
361+
usb_err = ep1_memory_write(hdev_param,
362+
ST7_USB_BUF_EP0OUT + lut_start, header->length + 1, buffer);
377363
if (usb_err < 0)
378364
return usb_err;
379365
break;
@@ -1300,7 +1286,7 @@ static int rlink_execute_queue(struct jtag_command *cmd_queue)
13001286
LOG_DEBUG_IO("reset trst: %i srst %i",
13011287
cmd->cmd.reset->trst,
13021288
cmd->cmd.reset->srst);
1303-
if ((cmd->cmd.reset->trst == 1) ||
1289+
if (cmd->cmd.reset->trst == 1 ||
13041290
(cmd->cmd.reset->srst &&
13051291
(jtag_get_reset_config() & RESET_SRST_PULLS_TRST)))
13061292
tap_set_state(TAP_RESET);

src/jtag/drivers/ulink.c

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -528,26 +528,24 @@ static int ulink_allocate_payload(struct ulink_cmd *ulink_cmd, int size,
528528
LOG_ERROR("BUG: Duplicate payload allocation for OpenULINK command");
529529
free(payload);
530530
return ERROR_FAIL;
531-
} else {
532-
ulink_cmd->payload_out = payload;
533-
ulink_cmd->payload_out_size = size;
534531
}
532+
ulink_cmd->payload_out = payload;
533+
ulink_cmd->payload_out_size = size;
535534
break;
536535
case PAYLOAD_DIRECTION_IN:
537536
if (ulink_cmd->payload_in_start) {
538537
LOG_ERROR("BUG: Duplicate payload allocation for OpenULINK command");
539538
free(payload);
540539
return ERROR_FAIL;
541-
} else {
542-
ulink_cmd->payload_in_start = payload;
543-
ulink_cmd->payload_in = payload;
544-
ulink_cmd->payload_in_size = size;
545-
546-
/* By default, free payload_in_start in ulink_clear_queue(). Commands
547-
* that do not want this behavior (e. g. split scans) must turn it off
548-
* separately! */
549-
ulink_cmd->free_payload_in_start = true;
550540
}
541+
ulink_cmd->payload_in_start = payload;
542+
ulink_cmd->payload_in = payload;
543+
ulink_cmd->payload_in_size = size;
544+
545+
/* By default, free payload_in_start in ulink_clear_queue(). Commands
546+
* that do not want this behavior (e. g. split scans) must turn it off
547+
* separately! */
548+
ulink_cmd->free_payload_in_start = true;
551549
break;
552550
}
553551

@@ -903,7 +901,7 @@ static int ulink_append_scan_cmd(struct ulink *device, enum scan_type scan_type,
903901
ret = ulink_allocate_payload(cmd, scan_size_bytes + 5, PAYLOAD_DIRECTION_OUT);
904902
break;
905903
default:
906-
LOG_ERROR("BUG: ulink_append_scan_cmd() encountered an unknown scan type");
904+
LOG_ERROR("BUG: %s() encountered an unknown scan type", __func__);
907905
ret = ERROR_FAIL;
908906
break;
909907
}
@@ -1832,8 +1830,7 @@ static int ulink_post_process_scan(struct ulink_cmd *ulink_cmd)
18321830
ret = ERROR_OK;
18331831
break;
18341832
default:
1835-
LOG_ERROR("BUG: ulink_post_process_scan() encountered an unknown"
1836-
" JTAG scan type");
1833+
LOG_ERROR("BUG: %s() encountered an unknown JTAG scan type", __func__);
18371834
ret = ERROR_FAIL;
18381835
break;
18391836
}
@@ -1877,8 +1874,7 @@ static int ulink_post_process_queue(struct ulink *device)
18771874
break;
18781875
default:
18791876
ret = ERROR_FAIL;
1880-
LOG_ERROR("BUG: ulink_post_process_queue() encountered unknown JTAG "
1881-
"command type");
1877+
LOG_ERROR("BUG: %s() encountered unknown JTAG command type", __func__);
18821878
break;
18831879
}
18841880

0 commit comments

Comments
 (0)