Staging: memrar: Moved memrar_allocator struct into memrar_allocator.c
PATCH 1/1 Staging: memrar: Moved memrar_allocator struct into memrar_allocator.c
Forward declared memrar_allocator in memrar_allocator.h and moved it to memrar_allocator.c file. Implemented memrar_allocator_capacity() and memrar_allocator_largest_free_area().
--- drivers/staging/memrar/memrar_allocator.c | 42 +++++++++++++++++++++++++ drivers/staging/memrar/memrar_allocator.h | 48 ++++++++++++----------------- 2 files changed, 62 insertions(+), 28 deletions(-)
drivers/staging/memrar/memrar_allocator.c +42 -0
@@ -41,6 +41,36 @@#include <linux/kernel.h> +/** +* struct memrar_allocator - encapsulation of the memory allocator state +* @lock: Lock used to synchronize access to the memory +* allocator state. +* @base: Base (start) address of the allocator memory +* space. +* @capacity: Size of the allocator memory space in bytes. +* @block_size: The size in bytes of individual blocks within +* the allocator memory space. +* @largest_free_area: Largest free area of memory in the allocator +* in bytes. +* @allocated_list: List of allocated memory block address +* ranges. +* @free_list: List of free address ranges. +* +* This structure contains all memory allocator state, including the +* base address, capacity, free list, lock, etc. +*/ +struct memrar_allocator { +/* private: internal use only */ +struct mutex lock; +unsigned long base; +size_t capacity; +size_t block_size; +size_t largest_free_area; +struct memrar_address_ranges allocated_list; +struct memrar_address_ranges free_list; +}; + +struct memrar_allocator *memrar_create_allocator (unsigned long base,size_t capacity,size_t block_size)
@@ -423,7 +453,19 @@ exit_memrar_free:return 0 ; } +size_t memrar_allocator_largest_free_area (struct memrar_allocator *allocator) +{ +if (allocator ==NULL ) +return 0 ; +return allocator->largest_free_area; +} +size_t memrar_allocator_capacity (struct memrar_allocator *allocator) +{ +if (allocator ==NULL ) +return 0 ; +return allocator->capacity; +}/* Local Variables:
drivers/staging/memrar/memrar_allocator.h +20 -28
60 lines not on this page · raw message
Signature · 1 line
1.7.1
Quoted 3 lines · Henri Häkkinen
Forward declared
memrar_allocatorinmemrar_allocator.hand moved it tomemrar_allocator.cfile. Implementedmemrar_allocator_capacity()andmemrar_allocator_largest_free_area().
Um, did you try building the code after this patch? It fails in bad ways:
CC [M] drivers/staging/memrar/memrar_handler.odrivers/staging/memrar/memrar_handler.c: In function ‘memrar_init_rar_resources’:drivers/staging/memrar/memrar_handler.c:352:2: error: dereferencing pointer to incomplete type drivers/staging/memrar/memrar_handler.c: In function ‘memrar_get_stat’:drivers/staging/memrar/memrar_handler.c:548:25: error: dereferencing pointer to incomplete type drivers/staging/memrar/memrar_handler.c:550:23: error: dereferencing pointer to incomplete type drivers/staging/memrar/memrar_handler.c:551:35: error: dereferencing pointer to incomplete type drivers/staging/memrar/memrar_handler.c:552:25: error: dereferencing pointer to incomplete type
Please always build the patches you send out. I can't take this one obviously :(
Care to fix it up?
thanks,
greg k-h