diff --git a/include/nuttx/mm/iob.h b/include/nuttx/mm/iob.h index 704d9d7bc20..a530bd996f7 100644 --- a/include/nuttx/mm/iob.h +++ b/include/nuttx/mm/iob.h @@ -88,6 +88,8 @@ # define IOB_QEMPTY(q) ((q)->qh_head == NULL) #endif +#define IOB_BUFSIZE(p) CONFIG_IOB_BUFSIZE + /**************************************************************************** * Public Types ****************************************************************************/ diff --git a/mm/iob/iob_clone.c b/mm/iob/iob_clone.c index 109e3d6bd80..82e319e5439 100644 --- a/mm/iob/iob_clone.c +++ b/mm/iob/iob_clone.c @@ -139,7 +139,7 @@ int iob_clone_partial(FAR struct iob_s *iob1, unsigned int len, while (iob2 != NULL) { - avail2 = CONFIG_IOB_BUFSIZE - iob2->io_offset; + avail2 = IOB_BUFSIZE(iob2) - iob2->io_offset; if ((int)(offset2 - avail2) < 0) { break; @@ -173,7 +173,7 @@ int iob_clone_partial(FAR struct iob_s *iob1, unsigned int len, */ dest = &iob2->io_data[iob2->io_offset + offset2]; - avail2 = CONFIG_IOB_BUFSIZE - iob2->io_offset - offset2; + avail2 = IOB_BUFSIZE(iob2) - iob2->io_offset - offset2; /* Copy the smaller of the two and update the srce and destination * offsets. @@ -218,7 +218,7 @@ int iob_clone_partial(FAR struct iob_s *iob1, unsigned int len, * transferred? */ - if ((int)(offset2 + iob2->io_offset - CONFIG_IOB_BUFSIZE) >= 0 && + if ((int)(offset2 + iob2->io_offset - IOB_BUFSIZE(iob2)) >= 0 && iob1 != NULL) { ret = iob_next(iob2, throttled, block); diff --git a/mm/iob/iob_contig.c b/mm/iob/iob_contig.c index 3d678189f42..7a529ea0d82 100644 --- a/mm/iob/iob_contig.c +++ b/mm/iob/iob_contig.c @@ -57,7 +57,7 @@ int iob_contig(FAR struct iob_s *iob, unsigned int len) * then you will need to increase CONFIG_IOB_BUFSIZE. */ - DEBUGASSERT(len <= CONFIG_IOB_BUFSIZE); + DEBUGASSERT(len <= IOB_BUFSIZE(iob)); /* Check if there is already sufficient, contiguous space at the beginning * of the packet diff --git a/mm/iob/iob_copyin.c b/mm/iob/iob_copyin.c index 0d221ee3b93..fb69aa00c65 100644 --- a/mm/iob/iob_copyin.c +++ b/mm/iob/iob_copyin.c @@ -128,7 +128,7 @@ static int iob_copyin_internal(FAR struct iob_s *iob, FAR const uint8_t *src, /* Yes.. We can extend this buffer to the up to the very end. */ - maxlen = CONFIG_IOB_BUFSIZE - iob->io_offset; + maxlen = IOB_BUFSIZE(iob) - iob->io_offset; /* This is the new buffer length that we need. Of course, * clipped to the maximum possible size in this buffer. diff --git a/mm/iob/iob_pack.c b/mm/iob/iob_pack.c index 55b590311f3..6fdce16cbe8 100644 --- a/mm/iob/iob_pack.c +++ b/mm/iob/iob_pack.c @@ -86,7 +86,7 @@ FAR struct iob_s *iob_pack(FAR struct iob_s *iob) */ ncopy = next->io_len; - navail = CONFIG_IOB_BUFSIZE - iob->io_len; + navail = IOB_BUFSIZE(iob) - iob->io_len; if (ncopy > navail) { ncopy = navail; diff --git a/mm/iob/iob_reserve.c b/mm/iob/iob_reserve.c index e1964d5d14f..d707f1fa398 100644 --- a/mm/iob/iob_reserve.c +++ b/mm/iob/iob_reserve.c @@ -49,9 +49,9 @@ void iob_reserve(FAR struct iob_s *iob, unsigned int reserved) while (iob != NULL && reserved > 0) { - if (reserved > CONFIG_IOB_BUFSIZE) + if (reserved > IOB_BUFSIZE(iob)) { - offset = CONFIG_IOB_BUFSIZE; + offset = IOB_BUFSIZE(iob); } else { diff --git a/mm/iob/iob_tailroom.c b/mm/iob/iob_tailroom.c index d0c999156c8..883f220693f 100644 --- a/mm/iob/iob_tailroom.c +++ b/mm/iob/iob_tailroom.c @@ -48,5 +48,5 @@ unsigned int iob_tailroom(FAR struct iob_s *iob) iob = iob->io_flink; } - return CONFIG_IOB_BUFSIZE - (iob->io_offset + iob->io_len); + return IOB_BUFSIZE(iob) - (iob->io_offset + iob->io_len); } diff --git a/mm/iob/iob_update_pktlen.c b/mm/iob/iob_update_pktlen.c index e6e1fd46e32..a5ad1501356 100644 --- a/mm/iob/iob_update_pktlen.c +++ b/mm/iob/iob_update_pktlen.c @@ -74,8 +74,7 @@ int iob_update_pktlen(FAR struct iob_s *iob, unsigned int pktlen, /* Trim inqueue entries if needed */ - nrequire = (pktlen + offset + CONFIG_IOB_BUFSIZE - 1) / - CONFIG_IOB_BUFSIZE; + nrequire = (pktlen + offset + IOB_BUFSIZE(iob) - 1) / IOB_BUFSIZE(iob); if (nrequire == 0) { nrequire = 1; @@ -130,9 +129,9 @@ int iob_update_pktlen(FAR struct iob_s *iob, unsigned int pktlen, next = iob; while (next != NULL && pktlen > 0) { - if (pktlen + next->io_offset > CONFIG_IOB_BUFSIZE) + if (pktlen + next->io_offset > IOB_BUFSIZE(next)) { - len = CONFIG_IOB_BUFSIZE - next->io_offset; + len = IOB_BUFSIZE(next) - next->io_offset; } else {