Skip to content
This repository was archived by the owner on Mar 7, 2026. It is now read-only.

Commit 4540bd5

Browse files
committed
hosted/ftdi: jtagtap_cycle: Express divmod by 8 as shift and mask
1 parent 21fa42d commit 4540bd5

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/platforms/hosted/ftdi_jtag.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ static void ftdi_jtag_cycle(const bool tms, const bool tdi, const size_t clock_c
164164
* 0x8f CLK_BYTES: Length of 0..n will generate 1..1+n byte cycles,
165165
* i.e. emit 8..8*(n+1) clocks, so adjust clock_bytes down by 1.
166166
*/
167-
uint16_t clock_bytes = clock_cycles / 8U;
167+
uint16_t clock_bytes = clock_cycles >> 3U;
168168
if (clock_bytes > 0) {
169169
clock_bytes -= 1;
170170
const uint8_t cmd8[3U] = {
@@ -175,7 +175,7 @@ static void ftdi_jtag_cycle(const bool tms, const bool tdi, const size_t clock_c
175175
ftdi_buffer_write_arr(cmd8);
176176
}
177177
/* 0x8e CLK_BITS: Length of 0..7 will emit 1..8 clocks */
178-
const uint8_t clock_bits = clock_cycles % 8U - 1U;
178+
const uint8_t clock_bits = (clock_cycles & 7U) - 1U;
179179
if (clock_bits >= 8U)
180180
return;
181181
const uint8_t cmd1[2U] = {

0 commit comments

Comments
 (0)