Message ID | 20240828122258.928947-7-mark.cave-ayland@ilande.co.uk |
---|---|
State | New |
Headers | show |
Series | fifo8: add fifo8_peek(), fifo8_peek_buf() and tests | expand |
On Wed, Aug 28, 2024 at 10:25 PM Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> wrote: > > Pass the do_pop value from fifo8_peekpop_buf() to fifo8_peekpop_bufptr() to > allow peeks to the FIFO buffer, including adjusting the skip parameter to > handle the case where the internal FIFO buffer wraps around. > > Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Alistair > --- > util/fifo8.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/util/fifo8.c b/util/fifo8.c > index 5453cbc1b0..1031ffbe7e 100644 > --- a/util/fifo8.c > +++ b/util/fifo8.c > @@ -117,7 +117,7 @@ static uint32_t fifo8_peekpop_buf(Fifo8 *fifo, uint8_t *dest, uint32_t destlen, > } > > len = destlen; > - buf = fifo8_peekpop_bufptr(fifo, len, 0, &n1, true); > + buf = fifo8_peekpop_bufptr(fifo, len, 0, &n1, do_pop); > if (dest) { > memcpy(dest, buf, n1); > } > @@ -126,7 +126,7 @@ static uint32_t fifo8_peekpop_buf(Fifo8 *fifo, uint8_t *dest, uint32_t destlen, > len -= n1; > len = MIN(len, fifo8_num_used(fifo)); > if (len) { > - buf = fifo8_peekpop_bufptr(fifo, len, 0, &n2, true); > + buf = fifo8_peekpop_bufptr(fifo, len, do_pop ? 0 : n1, &n2, do_pop); > if (dest) { > memcpy(&dest[n1], buf, n2); > } > -- > 2.39.2 > >
On Wed, Aug 28, 2024 at 5:23 AM Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> wrote: > > Pass the do_pop value from fifo8_peekpop_buf() to fifo8_peekpop_bufptr() to > allow peeks to the FIFO buffer, including adjusting the skip parameter to > handle the case where the internal FIFO buffer wraps around. > > Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> Reviewed-by: Octavian Purdila <tavip@google.com> > --- > util/fifo8.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/util/fifo8.c b/util/fifo8.c > index 5453cbc1b0..1031ffbe7e 100644 > --- a/util/fifo8.c > +++ b/util/fifo8.c > @@ -117,7 +117,7 @@ static uint32_t fifo8_peekpop_buf(Fifo8 *fifo, uint8_t *dest, uint32_t destlen, > } > > len = destlen; > - buf = fifo8_peekpop_bufptr(fifo, len, 0, &n1, true); > + buf = fifo8_peekpop_bufptr(fifo, len, 0, &n1, do_pop); > if (dest) { > memcpy(dest, buf, n1); > } > @@ -126,7 +126,7 @@ static uint32_t fifo8_peekpop_buf(Fifo8 *fifo, uint8_t *dest, uint32_t destlen, > len -= n1; > len = MIN(len, fifo8_num_used(fifo)); > if (len) { > - buf = fifo8_peekpop_bufptr(fifo, len, 0, &n2, true); > + buf = fifo8_peekpop_bufptr(fifo, len, do_pop ? 0 : n1, &n2, do_pop); > if (dest) { > memcpy(&dest[n1], buf, n2); > } > -- > 2.39.2 >
diff --git a/util/fifo8.c b/util/fifo8.c index 5453cbc1b0..1031ffbe7e 100644 --- a/util/fifo8.c +++ b/util/fifo8.c @@ -117,7 +117,7 @@ static uint32_t fifo8_peekpop_buf(Fifo8 *fifo, uint8_t *dest, uint32_t destlen, } len = destlen; - buf = fifo8_peekpop_bufptr(fifo, len, 0, &n1, true); + buf = fifo8_peekpop_bufptr(fifo, len, 0, &n1, do_pop); if (dest) { memcpy(dest, buf, n1); } @@ -126,7 +126,7 @@ static uint32_t fifo8_peekpop_buf(Fifo8 *fifo, uint8_t *dest, uint32_t destlen, len -= n1; len = MIN(len, fifo8_num_used(fifo)); if (len) { - buf = fifo8_peekpop_bufptr(fifo, len, 0, &n2, true); + buf = fifo8_peekpop_bufptr(fifo, len, do_pop ? 0 : n1, &n2, do_pop); if (dest) { memcpy(&dest[n1], buf, n2); }
Pass the do_pop value from fifo8_peekpop_buf() to fifo8_peekpop_bufptr() to allow peeks to the FIFO buffer, including adjusting the skip parameter to handle the case where the internal FIFO buffer wraps around. Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> --- util/fifo8.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)