summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorReinhard Panhuber <[email protected]>2020-09-26 11:00:31 +0200
committerReinhard Panhuber <[email protected]>2020-09-26 11:00:31 +0200
commit8dcb10493330513b5b017306634a936413f1ecd5 (patch)
treedfe2e2587bc3f63447bcee51cf081d4d00bc6b32
parent9ddcfc09d7c0f076248307f76222d5b1db9e0882 (diff)
Change modulo substitute to while ( idx >= depth) idx -= depth;
-rw-r--r--src/common/tusb_fifo.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/common/tusb_fifo.c b/src/common/tusb_fifo.c
index 1e0c6b5e7..f41cf9f6c 100644
--- a/src/common/tusb_fifo.c
+++ b/src/common/tusb_fifo.c
@@ -81,9 +81,8 @@ bool tu_fifo_config(tu_fifo_t *f, void* buffer, uint16_t depth, uint16_t item_si
static inline uint16_t _ff_mod(uint16_t idx, uint16_t depth)
{
-// return idx % depth;
- idx -= depth & -(idx >= depth);
- return idx -= depth & -(idx >= depth);
+ while ( idx >= depth) idx -= depth;
+ return idx;
}
// send one item to FIFO WITHOUT updating write pointer