Skip to content

Commit

Permalink
kernel: Deprecate k_mem_pool APIs
Browse files Browse the repository at this point in the history
Mark all k_mem_pool APIs deprecated for future code.  Remaining
internal usage now uses equivalent "z_mem_pool" symbols instead.

Fixes zephyrproject-rtos#24358

Signed-off-by: Andy Ross <[email protected]>
  • Loading branch information
Andy Ross authored and nashif committed Dec 8, 2020
1 parent 27b1394 commit 6965cf5
Show file tree
Hide file tree
Showing 31 changed files with 116 additions and 410 deletions.
1 change: 0 additions & 1 deletion doc/reference/kernel/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ These pages cover memory allocation and management services.

memory/heap.rst
memory/slabs.rst
memory/pools.rst

Timing
******
Expand Down
217 changes: 0 additions & 217 deletions doc/reference/kernel/memory/pools.rst

This file was deleted.

6 changes: 3 additions & 3 deletions drivers/usb/device/usb_dc_kinetis.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ static struct buf_descriptor __aligned(512) bdt[(NUM_OF_EP_MAX) * 2 * 2];

#define EP_BUF_NUMOF_BLOCKS (NUM_OF_EP_MAX / 2)

K_MEM_POOL_DEFINE(ep_buf_pool, 16, 512, EP_BUF_NUMOF_BLOCKS, 4);
Z_MEM_POOL_DEFINE(ep_buf_pool, 16, 512, EP_BUF_NUMOF_BLOCKS, 4);

struct usb_ep_ctrl_data {
struct ep_status {
Expand Down Expand Up @@ -353,14 +353,14 @@ int usb_dc_ep_configure(const struct usb_dc_ep_cfg_data * const cfg)
}

if (bdt[idx_even].buf_addr) {
k_mem_pool_free(block);
z_mem_pool_free(block);
}

USB0->ENDPOINT[ep_idx].ENDPT = 0;
(void)memset(&bdt[idx_even], 0, sizeof(struct buf_descriptor));
(void)memset(&bdt[idx_odd], 0, sizeof(struct buf_descriptor));

if (k_mem_pool_alloc(&ep_buf_pool, block, cfg->ep_mps * 2U, K_MSEC(10)) == 0) {
if (z_mem_pool_alloc(&ep_buf_pool, block, cfg->ep_mps * 2U, K_MSEC(10)) == 0) {
(void)memset(block->data, 0, cfg->ep_mps * 2U);
} else {
LOG_ERR("Memory allocation time-out");
Expand Down
20 changes: 9 additions & 11 deletions drivers/usb/device/usb_dc_nrfx.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ struct usbd_event {
#error Invalid USBD event queue size (CONFIG_USB_NRFX_EVT_QUEUE_SIZE).
#endif

K_MEM_POOL_DEFINE(fifo_elem_pool, FIFO_ELEM_MIN_SZ, FIFO_ELEM_MAX_SZ,
Z_MEM_POOL_DEFINE(fifo_elem_pool, FIFO_ELEM_MIN_SZ, FIFO_ELEM_MAX_SZ,
CONFIG_USB_NRFX_EVT_QUEUE_SIZE, FIFO_ELEM_ALIGN);

/**
Expand Down Expand Up @@ -233,7 +233,7 @@ K_MEM_POOL_DEFINE(fifo_elem_pool, FIFO_ELEM_MIN_SZ, FIFO_ELEM_MAX_SZ,
/** 4 Byte Buffer alignment required by hardware */
#define EP_BUF_POOL_ALIGNMENT sizeof(unsigned int)

K_MEM_POOL_DEFINE(ep_buf_pool, EP_BUF_POOL_BLOCK_MIN_SZ,
Z_MEM_POOL_DEFINE(ep_buf_pool, EP_BUF_POOL_BLOCK_MIN_SZ,
EP_BUF_POOL_BLOCK_MAX_SZ, EP_BUF_POOL_BLOCK_COUNT,
EP_BUF_POOL_ALIGNMENT);

Expand Down Expand Up @@ -406,7 +406,7 @@ static inline void usbd_work_schedule(void)
*/
static inline void usbd_evt_free(struct usbd_event *ev)
{
k_mem_pool_free(&ev->block);
z_mem_pool_free(&ev->block);
}

/**
Expand Down Expand Up @@ -455,7 +455,7 @@ static inline struct usbd_event *usbd_evt_alloc(void)
struct usbd_event *ev;
struct k_mem_block block;

ret = k_mem_pool_alloc(&fifo_elem_pool, &block,
ret = z_mem_pool_alloc(&fifo_elem_pool, &block,
sizeof(struct usbd_event),
K_NO_WAIT);

Expand All @@ -470,7 +470,7 @@ static inline struct usbd_event *usbd_evt_alloc(void)
*/
usbd_evt_flush();

ret = k_mem_pool_alloc(&fifo_elem_pool, &block,
ret = z_mem_pool_alloc(&fifo_elem_pool, &block,
sizeof(struct usbd_event),
K_NO_WAIT);
if (ret < 0) {
Expand Down Expand Up @@ -635,7 +635,6 @@ static int eps_ctx_init(void)
for (i = 0U; i < CFG_EPIN_CNT; i++) {
ep_ctx = in_endpoint_ctx(i);
__ASSERT_NO_MSG(ep_ctx);

ep_ctx_reset(ep_ctx);
}

Expand All @@ -644,7 +643,7 @@ static int eps_ctx_init(void)
__ASSERT_NO_MSG(ep_ctx);

if (!ep_ctx->buf.block.data) {
err = k_mem_pool_alloc(&ep_buf_pool, &ep_ctx->buf.block,
err = z_mem_pool_alloc(&ep_buf_pool, &ep_ctx->buf.block,
EP_BUF_MAX_SZ, K_NO_WAIT);
if (err < 0) {
LOG_ERR("Buffer alloc failed for EP 0x%02x", i);
Expand All @@ -658,7 +657,6 @@ static int eps_ctx_init(void)
if (CFG_EP_ISOIN_CNT) {
ep_ctx = in_endpoint_ctx(NRF_USBD_EPIN(8));
__ASSERT_NO_MSG(ep_ctx);

ep_ctx_reset(ep_ctx);
}

Expand All @@ -667,7 +665,7 @@ static int eps_ctx_init(void)
__ASSERT_NO_MSG(ep_ctx);

if (!ep_ctx->buf.block.data) {
err = k_mem_pool_alloc(&ep_buf_pool, &ep_ctx->buf.block,
err = z_mem_pool_alloc(&ep_buf_pool, &ep_ctx->buf.block,
ISO_EP_BUF_MAX_SZ,
K_NO_WAIT);
if (err < 0) {
Expand Down Expand Up @@ -696,7 +694,7 @@ static void eps_ctx_uninit(void)
for (i = 0U; i < CFG_EPOUT_CNT; i++) {
ep_ctx = out_endpoint_ctx(i);
__ASSERT_NO_MSG(ep_ctx);
k_mem_pool_free(&ep_ctx->buf.block);
z_mem_pool_free(&ep_ctx->buf.block);
memset(ep_ctx, 0, sizeof(*ep_ctx));
}

Expand All @@ -709,7 +707,7 @@ static void eps_ctx_uninit(void)
if (CFG_EP_ISOOUT_CNT) {
ep_ctx = out_endpoint_ctx(NRF_USBD_EPOUT(8));
__ASSERT_NO_MSG(ep_ctx);
k_mem_pool_free(&ep_ctx->buf.block);
z_mem_pool_free(&ep_ctx->buf.block);
memset(ep_ctx, 0, sizeof(*ep_ctx));
}
}
Expand Down
Loading

0 comments on commit 6965cf5

Please sign in to comment.