Module: xenomai-forge Branch: next Commit: b18f657844cf5e36efd8ae2a1e104c000eb1b4e0 URL: http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=b18f657844cf5e36efd8ae2a1e104c000eb1b4e0
Author: Philippe Gerum <r...@xenomai.org> Date: Mon Sep 8 19:18:55 2014 +0200 cobalt/heap: drop flush handler in xnheap_destroy() Zero users, no purpose. --- include/cobalt/kernel/heap.h | 7 +------ kernel/cobalt/heap.c | 19 +++---------------- kernel/cobalt/init.c | 13 ++++++------- kernel/cobalt/posix/memory.c | 2 +- kernel/drivers/ipc/iddp.c | 21 ++++++++++----------- kernel/drivers/ipc/xddp.c | 22 ++++++++++++---------- 6 files changed, 33 insertions(+), 51 deletions(-) diff --git a/include/cobalt/kernel/heap.h b/include/cobalt/kernel/heap.h index 3f308ec..d29778f 100644 --- a/include/cobalt/kernel/heap.h +++ b/include/cobalt/kernel/heap.h @@ -134,12 +134,7 @@ int xnheap_init(struct xnheap *heap, void *membase, u32 size); void xnheap_set_name(struct xnheap *heap, const char *name, ...); -void xnheap_destroy(struct xnheap *heap, - void (*flushfn)(struct xnheap *heap, - void *membase, - u32 size, - void *cookie), - void *cookie); +void xnheap_destroy(struct xnheap *heap); void *xnheap_alloc(struct xnheap *heap, u32 size); diff --git a/kernel/cobalt/heap.c b/kernel/cobalt/heap.c index 7cb167a..efd410b 100644 --- a/kernel/cobalt/heap.c +++ b/kernel/cobalt/heap.c @@ -243,26 +243,16 @@ int xnheap_init(struct xnheap *heap, void *membase, u32 size) EXPORT_SYMBOL_GPL(xnheap_init); /** - * @fn void xnheap_destroy(struct xnheap *heap, void (*flushfn)(struct xnheap *heap, void *membase, u32 size, void *cookie), void *cookie) + * @fn void xnheap_destroy(struct xnheap *heap) * @brief Destroys a memory heap. * * Destroys a memory heap. * - * @param heap The descriptor address of the destroyed heap. - * - * @param flushfn If non-NULL, the address of a user-supplied flush - * routine which will be called to further release the heap memory. - * - * @param cookie If @a flushfn is non-NULL, @a cookie is an opaque - * pointer which will be passed unmodified to @a flushfn. + * @param heap The heap descriptor. * * @coretags{secondary-only} */ -void xnheap_destroy(struct xnheap *heap, - void (*flushfn)(struct xnheap *heap, - void *membase, - u32 size, void *cookie), - void *cookie) +void xnheap_destroy(struct xnheap *heap) { spl_t s; @@ -274,9 +264,6 @@ void xnheap_destroy(struct xnheap *heap, xnvfile_touch_tag(&vfile_tag); xnlock_put_irqrestore(&nklock, s); kfree(heap->pagemap); - - if (flushfn) - flushfn(heap, heap->membase, heap->size, cookie); } EXPORT_SYMBOL_GPL(xnheap_destroy); diff --git a/kernel/cobalt/init.c b/kernel/cobalt/init.c index 0c9e08b..e729b11 100644 --- a/kernel/cobalt/init.c +++ b/kernel/cobalt/init.c @@ -116,16 +116,12 @@ static void disable_timesource(void) #endif /* CONFIG_XENO_OPT_STATS */ } -static void flush_heap(struct xnheap *heap, - void *mem, u32 size, void *cookie) -{ - free_pages_exact(mem, size); -} - static void sys_shutdown(void) { struct xnthread *thread, *tmp; struct xnsched *sched; + void *membase; + u32 memsize; int cpu; spl_t s; @@ -152,7 +148,10 @@ static void sys_shutdown(void) xnlock_put_irqrestore(&nklock, s); xnregistry_cleanup(); - xnheap_destroy(&kheap, flush_heap, NULL); + membase = xnheap_get_membase(&kheap); + memsize = xnheap_get_size(&kheap); + xnheap_destroy(&kheap); + free_pages_exact(membase, memsize); } static int __init mach_setup(void) diff --git a/kernel/cobalt/posix/memory.c b/kernel/cobalt/posix/memory.c index d3cce34..06422ef 100644 --- a/kernel/cobalt/posix/memory.c +++ b/kernel/cobalt/posix/memory.c @@ -352,7 +352,7 @@ void cobalt_umm_destroy(struct cobalt_umm *umm) secondary_mode_only(); if (atomic_dec_and_test(&umm->refcount)) { - xnheap_destroy(&umm->heap, NULL, NULL); + xnheap_destroy(&umm->heap); vfree(xnheap_get_membase(&umm->heap)); if (umm->release) umm->release(umm); diff --git a/kernel/drivers/ipc/iddp.c b/kernel/drivers/ipc/iddp.c index 4487bb3..a2406da 100644 --- a/kernel/drivers/ipc/iddp.c +++ b/kernel/drivers/ipc/iddp.c @@ -159,12 +159,6 @@ static void __iddp_free_mbuf(struct iddp_socket *sk, rtdm_waitqueue_broadcast(sk->poolwaitq); } -static void __iddp_flush_pool(struct xnheap *heap, - void *poolmem, u32 poolsz, void *cookie) -{ - free_pages_exact(poolmem, poolsz); -} - static int iddp_socket(struct rtdm_fd *fd) { struct rtipc_private *priv = rtdm_fd_to_private(fd); @@ -196,6 +190,8 @@ static void iddp_close(struct rtdm_fd *fd) struct iddp_socket *sk = priv->state; struct iddp_message *mbuf; rtdm_lockctx_t s; + void *poolmem; + u32 poolsz; if (sk->name.sipc_port > -1) { cobalt_atomic_enter(s); @@ -210,7 +206,10 @@ static void iddp_close(struct rtdm_fd *fd) xnregistry_remove(sk->handle); if (sk->bufpool != &kheap) { - xnheap_destroy(&sk->privpool, __iddp_flush_pool, NULL); + poolmem = xnheap_get_membase(&sk->privpool); + poolsz = xnheap_get_size(&sk->privpool); + xnheap_destroy(&sk->privpool); + free_pages_exact(poolmem, poolsz); return; } @@ -587,7 +586,6 @@ static int __iddp_bind_socket(struct rtdm_fd *fd, goto fail; } xnheap_set_name(&sk->privpool, "iddp-pool@%d", port); - sk->poolwaitq = &sk->privwaitq; sk->bufpool = &sk->privpool; } @@ -601,9 +599,10 @@ static int __iddp_bind_socket(struct rtdm_fd *fd, ret = xnregistry_enter(sk->label, sk, &sk->handle, &__iddp_pnode.node); if (ret) { - if (poolsz > 0) - xnheap_destroy(&sk->privpool, - __iddp_flush_pool, NULL); + if (poolsz > 0) { + xnheap_destroy(&sk->privpool); + free_pages_exact(poolmem, poolsz); + } goto fail; } } diff --git a/kernel/drivers/ipc/xddp.c b/kernel/drivers/ipc/xddp.c index c1be6a5..aa6704a 100644 --- a/kernel/drivers/ipc/xddp.c +++ b/kernel/drivers/ipc/xddp.c @@ -104,12 +104,6 @@ static struct xnpnode_link __xddp_pnode = { #endif /* !CONFIG_XENO_OPT_VFILE */ -static void __xddp_flush_pool(struct xnheap *heap, - void *poolmem, u32 poolsz, void *cookie) -{ - free_pages_exact(poolmem, poolsz); -} - static void *__xddp_alloc_handler(size_t size, void *skarg) /* nklock free */ { struct xddp_socket *sk = skarg; @@ -205,9 +199,15 @@ static int __xddp_input_handler(struct xnpipe_mh *mh, int retval, void *skarg) / static void __xddp_release_handler(void *skarg) /* nklock free */ { struct xddp_socket *sk = skarg; + void *poolmem; + u32 poolsz; - if (sk->bufpool == &sk->privpool) - xnheap_destroy(&sk->privpool, __xddp_flush_pool, NULL); + if (sk->bufpool == &sk->privpool) { + poolmem = xnheap_get_membase(&sk->privpool); + poolsz = xnheap_get_size(&sk->privpool); + xnheap_destroy(&sk->privpool); + free_pages_exact(poolmem, poolsz); + } kfree(sk); } @@ -735,8 +735,10 @@ static int __xddp_bind_socket(struct rtipc_private *priv, if (ret == -EBUSY) ret = -EADDRINUSE; fail_freeheap: - if (sk->bufpool == &sk->privpool) - xnheap_destroy(&sk->privpool, __xddp_flush_pool, NULL); + if (poolsz > 0) { + xnheap_destroy(&sk->privpool); + free_pages_exact(poolmem, poolsz); + } fail: clear_bit(_XDDP_BINDING, &sk->status); return ret; _______________________________________________ Xenomai-git mailing list Xenomai-git@xenomai.org http://www.xenomai.org/mailman/listinfo/xenomai-git