diff --git a/drivers/usrsock/usrsock_rpmsg.c b/drivers/usrsock/usrsock_rpmsg.c index a9d6c237586..2c9c5ae3178 100644 --- a/drivers/usrsock/usrsock_rpmsg.c +++ b/drivers/usrsock/usrsock_rpmsg.c @@ -25,6 +25,7 @@ ****************************************************************************/ #include +#include #include #include #include diff --git a/include/nuttx/mm/iob.h b/include/nuttx/mm/iob.h index f2914762371..e6bf0ecc23e 100644 --- a/include/nuttx/mm/iob.h +++ b/include/nuttx/mm/iob.h @@ -31,6 +31,7 @@ #include #include +#include #ifdef CONFIG_IOB_NOTIFIER # include @@ -74,9 +75,7 @@ /* Default config of alignment and head padding size */ -#if !defined(CONFIG_IOB_ALIGNMENT) -# define CONFIG_IOB_ALIGNMENT 1 -#endif +#define IOB_ALIGNMENT MAX(CONFIG_IOB_ALIGNMENT, sizeof(uintptr_t)) /* IOB helpers */ diff --git a/include/nuttx/sched.h b/include/nuttx/sched.h index 8ee25f366f3..facbff4d5c4 100644 --- a/include/nuttx/sched.h +++ b/include/nuttx/sched.h @@ -46,7 +46,6 @@ #include #include #include -#include #include #include #include diff --git a/mm/iob/iob_alloc.c b/mm/iob/iob_alloc.c index 921b9d3b48a..130526bc49f 100644 --- a/mm/iob/iob_alloc.c +++ b/mm/iob/iob_alloc.c @@ -335,9 +335,9 @@ FAR struct iob_s *iob_alloc_dynamic(uint16_t size) FAR struct iob_s *iob; size_t alignsize; - alignsize = ALIGN_UP(sizeof(struct iob_s), CONFIG_IOB_ALIGNMENT) + size; + alignsize = ALIGN_UP(sizeof(struct iob_s), IOB_ALIGNMENT) + size; - iob = kmm_memalign(CONFIG_IOB_ALIGNMENT, alignsize); + iob = kmm_memalign(IOB_ALIGNMENT, alignsize); if (iob) { iob->io_flink = NULL; /* Not in a chain */ @@ -347,7 +347,7 @@ FAR struct iob_s *iob_alloc_dynamic(uint16_t size) iob->io_pktlen = 0; /* Total length of the packet */ iob->io_free = iob_free_dynamic; /* Customer free callback */ iob->io_data = (FAR uint8_t *)ALIGN_UP((uintptr_t)(iob + 1), - CONFIG_IOB_ALIGNMENT); + IOB_ALIGNMENT); } return iob; @@ -432,7 +432,7 @@ FAR struct iob_s *iob_init_with_data(FAR void *data, uint16_t size, iob->io_pktlen = 0; /* Total length of the packet */ iob->io_free = free_cb; /* Customer free callback */ iob->io_data = (FAR uint8_t *)ALIGN_UP((uintptr_t)(iob + 1), - CONFIG_IOB_ALIGNMENT); + IOB_ALIGNMENT); iob->io_bufsize = ((FAR uint8_t *)data + size) - iob->io_data; return iob; diff --git a/mm/iob/iob_free.c b/mm/iob/iob_free.c index 7d734adc880..4c5d8e6e0a8 100644 --- a/mm/iob/iob_free.c +++ b/mm/iob/iob_free.c @@ -122,7 +122,7 @@ FAR struct iob_s *iob_free(FAR struct iob_s *iob) if (iob->io_free != NULL) { FAR uint8_t *io_data = (FAR uint8_t *)ALIGN_UP((uintptr_t)(iob + 1), - CONFIG_IOB_ALIGNMENT); + IOB_ALIGNMENT); if (iob->io_data == io_data) { iob->io_free(iob); diff --git a/mm/iob/iob_initialize.c b/mm/iob/iob_initialize.c index 930473c2bd0..02aad9bbfe0 100644 --- a/mm/iob/iob_initialize.c +++ b/mm/iob/iob_initialize.c @@ -41,13 +41,13 @@ #ifdef CONFIG_IOB_ALLOC # define IOB_ALIGN_SIZE ALIGN_UP(sizeof(struct iob_s) + CONFIG_IOB_BUFSIZE, \ - CONFIG_IOB_ALIGNMENT) + IOB_ALIGNMENT) #else -# define IOB_ALIGN_SIZE ALIGN_UP(sizeof(struct iob_s), CONFIG_IOB_ALIGNMENT) +# define IOB_ALIGN_SIZE ALIGN_UP(sizeof(struct iob_s), IOB_ALIGNMENT) #endif #define IOB_BUFFER_SIZE (IOB_ALIGN_SIZE * CONFIG_IOB_NBUFFERS + \ - CONFIG_IOB_ALIGNMENT - 1) + IOB_ALIGNMENT - 1) /**************************************************************************** * Private Data @@ -55,7 +55,7 @@ /* Following raw buffer will be divided into iob_s instances, the initial * procedure will ensure that the member io_data of each iob_s is aligned - * to the CONFIG_IOB_ALIGNMENT memory boundary. + * to the IOB_ALIGNMENT memory boundary. */ #ifdef IOB_SECTION @@ -135,11 +135,11 @@ void iob_initialize(void) uintptr_t buf; /* Get a start address which plus offsetof(struct iob_s, io_data) is - * aligned to the CONFIG_IOB_ALIGNMENT memory boundary + * aligned to the IOB_ALIGNMENT memory boundary */ buf = ALIGN_UP((uintptr_t)g_iob_buffer + offsetof(struct iob_s, io_data), - CONFIG_IOB_ALIGNMENT) - offsetof(struct iob_s, io_data); + IOB_ALIGNMENT) - offsetof(struct iob_s, io_data); /* Get I/O buffer instance from the start address and add each I/O buffer * to the free list