kernel: subsys: lib: drivers: Use k_heap instead of z_mem_pool wrappers
Use the core k_heap API pervasively within our tree instead of the z_mem_pool wrapper that provided compatibility with the older mempool implementation. Almost all of this is straightforward swapping of one alloc/free call for another. In a few cases where code was holding onto an old-style "mem_block" a local compatibility struct with a single field has been swapped in to keep the invasiveness of the changes down. Note that not all the relevant changes in this patch have in-tree test coverage, though I validated that it all builds. Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
This commit is contained in:
parent
78614bf271
commit
fcd392f6ce
25 changed files with 137 additions and 207 deletions
|
@ -7,14 +7,17 @@
|
|||
|
||||
#include <drivers/video.h>
|
||||
|
||||
K_MEM_POOL_DEFINE(video_buffer_pool,
|
||||
CONFIG_VIDEO_BUFFER_POOL_ALIGN,
|
||||
CONFIG_VIDEO_BUFFER_POOL_SZ_MAX,
|
||||
CONFIG_VIDEO_BUFFER_POOL_NUM_MAX,
|
||||
CONFIG_VIDEO_BUFFER_POOL_ALIGN);
|
||||
K_HEAP_DEFINE(video_buffer_pool,
|
||||
CONFIG_VIDEO_BUFFER_POOL_SZ_MAX *
|
||||
CONFIG_VIDEO_BUFFER_POOL_NUM_MAX);
|
||||
|
||||
static struct video_buffer video_buf[CONFIG_VIDEO_BUFFER_POOL_NUM_MAX];
|
||||
static struct k_mem_block video_block[CONFIG_VIDEO_BUFFER_POOL_NUM_MAX];
|
||||
|
||||
struct mem_block {
|
||||
void *data;
|
||||
};
|
||||
|
||||
static mem_block video_block[CONFIG_VIDEO_BUFFER_POOL_NUM_MAX];
|
||||
|
||||
struct video_buffer *video_buffer_alloc(size_t size)
|
||||
{
|
||||
|
@ -36,7 +39,8 @@ struct video_buffer *video_buffer_alloc(size_t size)
|
|||
}
|
||||
|
||||
/* Alloc buffer memory */
|
||||
if (k_mem_pool_alloc(&video_buffer_pool, block, size, K_FOREVER)) {
|
||||
block->data = k_heap_alloc(&video_buffer_pool, size, K_FOREVER);
|
||||
if (block->data == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -49,7 +53,7 @@ struct video_buffer *video_buffer_alloc(size_t size)
|
|||
|
||||
void video_buffer_release(struct video_buffer *vbuf)
|
||||
{
|
||||
struct k_mem_block *block = NULL;
|
||||
struct mem_block *block = NULL;
|
||||
int i;
|
||||
|
||||
/* vbuf to block */
|
||||
|
@ -61,5 +65,5 @@ void video_buffer_release(struct video_buffer *vbuf)
|
|||
}
|
||||
|
||||
vbuf->buffer = NULL;
|
||||
k_mem_pool_free(block);
|
||||
k_heap_free(&video_buffer_pool, block->data);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue