|
59 | 59 | /** Buffer granularity required by the UDC driver */
|
60 | 60 | #define UDC_BUF_GRANULARITY Z_UDC_BUF_GRANULARITY
|
61 | 61 |
|
| 62 | +/** Round up to the granularity required by the UDC driver */ |
| 63 | +#define UDC_ROUND_UP(size) ROUND_UP(size, Z_UDC_BUF_GRANULARITY) |
| 64 | + |
62 | 65 | /**
|
63 | 66 | * @brief Define a UDC driver-compliant static buffer
|
64 | 67 | *
|
|
70 | 73 | */
|
71 | 74 | #define UDC_STATIC_BUF_DEFINE(name, size) \
|
72 | 75 | static uint8_t Z_UDC_BUF_SECTION __aligned(UDC_BUF_ALIGN) \
|
73 |
| - name[ROUND_UP(size, UDC_BUF_GRANULARITY)]; |
| 76 | + name[UDC_ROUND_UP(size)]; |
74 | 77 |
|
75 | 78 | /**
|
76 | 79 | * @brief Verify that the buffer is aligned as required by the UDC driver
|
@@ -148,14 +151,14 @@ extern const struct net_buf_data_cb net_buf_dma_cb;
|
148 | 151 | BUILD_ASSERT((UDC_BUF_GRANULARITY) % (UDC_BUF_ALIGN) == 0, \
|
149 | 152 | "Code assumes granurality is multiple of alignment"); \
|
150 | 153 | static uint8_t Z_UDC_BUF_SECTION __aligned(UDC_BUF_ALIGN) \
|
151 |
| - net_buf_data_##pname[count][ROUND_UP(size, UDC_BUF_GRANULARITY)];\ |
| 154 | + net_buf_data_##pname[count][UDC_ROUND_UP(size)]; \ |
152 | 155 | static const struct net_buf_pool_fixed net_buf_fixed_##pname = { \
|
153 | 156 | .data_pool = (uint8_t *)net_buf_data_##pname, \
|
154 | 157 | }; \
|
155 | 158 | static const struct net_buf_data_alloc net_buf_fixed_alloc_##pname = { \
|
156 | 159 | .cb = &net_buf_fixed_cb, \
|
157 | 160 | .alloc_data = (void *)&net_buf_fixed_##pname, \
|
158 |
| - .max_alloc_size = ROUND_UP(size, UDC_BUF_GRANULARITY), \ |
| 161 | + .max_alloc_size = UDC_ROUND_UP(size), \ |
159 | 162 | }; \
|
160 | 163 | static STRUCT_SECTION_ITERABLE(net_buf_pool, pname) = \
|
161 | 164 | NET_BUF_POOL_INITIALIZER(pname, &net_buf_fixed_alloc_##pname, \
|
|
0 commit comments