jtag_vpi: use DIV_ROUND_UP
[openocd.git] / src / jtag / drivers / jtag_vpi.c
index d0e90e2afdaaa42145e15754d877419b95b8b452..d962ecfc7bf770aa1c1d2fc65722ec14f450b854 100644 (file)
@@ -100,7 +100,7 @@ static int jtag_vpi_tms_seq(const uint8_t *bits, int nb_bits)
        struct vpi_cmd vpi;
        int nb_bytes;
 
-       nb_bytes = (nb_bits / 8) + !!(nb_bits % 8);
+       nb_bytes = DIV_ROUND_UP(nb_bits, 8);
 
        vpi.cmd = CMD_TMS_SEQ;
        memcpy(vpi.buffer_out, bits, nb_bytes);
@@ -165,7 +165,7 @@ static int jtag_vpi_state_move(tap_state_t state)
 static int jtag_vpi_queue_tdi_xfer(uint8_t *bits, int nb_bits, int tap_shift)
 {
        struct vpi_cmd vpi;
-       int nb_bytes = (nb_bits / 8) + !!(nb_bits % 8);
+       int nb_bytes = DIV_ROUND_UP(nb_bits, 8);
 
        vpi.cmd = tap_shift ? CMD_SCAN_CHAIN_FLIP_TMS : CMD_SCAN_CHAIN;
 
@@ -198,7 +198,7 @@ static int jtag_vpi_queue_tdi_xfer(uint8_t *bits, int nb_bits, int tap_shift)
  */
 static int jtag_vpi_queue_tdi(uint8_t *bits, int nb_bits, int tap_shift)
 {
-       int nb_xfer = (nb_bits / (XFERT_MAX_SIZE * 8)) + !!(nb_bits % (XFERT_MAX_SIZE * 8));
+       int nb_xfer = DIV_ROUND_UP(nb_bits, XFERT_MAX_SIZE * 8);
        uint8_t *xmit_buffer = bits;
        int xmit_nb_bits = nb_bits;
        int i = 0;

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)