diff options
| author | Russell King <rmk@dyn-67.arm.linux.org.uk> | 2009-09-12 07:02:26 -0400 |
|---|---|---|
| committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2009-09-12 07:02:26 -0400 |
| commit | ddd559b13f6d2fe3ad68c4b3f5235fd3c2eae4e3 (patch) | |
| tree | d827bca3fc825a0ac33efbcd493713be40fcc812 /include/linux/flex_array.h | |
| parent | cf7a2b4fb6a9b86779930a0a123b0df41aa9208f (diff) | |
| parent | f17a1f06d2fa93f4825be572622eb02c4894db4e (diff) | |
Merge branch 'devel-stable' into devel
Conflicts:
MAINTAINERS
arch/arm/mm/fault.c
Diffstat (limited to 'include/linux/flex_array.h')
| -rw-r--r-- | include/linux/flex_array.h | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/include/linux/flex_array.h b/include/linux/flex_array.h new file mode 100644 index 000000000000..23c1ec79a31b --- /dev/null +++ b/include/linux/flex_array.h | |||
| @@ -0,0 +1,47 @@ | |||
| 1 | #ifndef _FLEX_ARRAY_H | ||
| 2 | #define _FLEX_ARRAY_H | ||
| 3 | |||
| 4 | #include <linux/types.h> | ||
| 5 | #include <asm/page.h> | ||
| 6 | |||
| 7 | #define FLEX_ARRAY_PART_SIZE PAGE_SIZE | ||
| 8 | #define FLEX_ARRAY_BASE_SIZE PAGE_SIZE | ||
| 9 | |||
| 10 | struct flex_array_part; | ||
| 11 | |||
| 12 | /* | ||
| 13 | * This is meant to replace cases where an array-like | ||
| 14 | * structure has gotten too big to fit into kmalloc() | ||
| 15 | * and the developer is getting tempted to use | ||
| 16 | * vmalloc(). | ||
| 17 | */ | ||
| 18 | |||
| 19 | struct flex_array { | ||
| 20 | union { | ||
| 21 | struct { | ||
| 22 | int element_size; | ||
| 23 | int total_nr_elements; | ||
| 24 | struct flex_array_part *parts[0]; | ||
| 25 | }; | ||
| 26 | /* | ||
| 27 | * This little trick makes sure that | ||
| 28 | * sizeof(flex_array) == PAGE_SIZE | ||
| 29 | */ | ||
| 30 | char padding[FLEX_ARRAY_BASE_SIZE]; | ||
| 31 | }; | ||
| 32 | }; | ||
| 33 | |||
| 34 | #define FLEX_ARRAY_INIT(size, total) { { {\ | ||
| 35 | .element_size = (size), \ | ||
| 36 | .total_nr_elements = (total), \ | ||
| 37 | } } } | ||
| 38 | |||
| 39 | struct flex_array *flex_array_alloc(int element_size, int total, gfp_t flags); | ||
| 40 | int flex_array_prealloc(struct flex_array *fa, int start, int end, gfp_t flags); | ||
| 41 | void flex_array_free(struct flex_array *fa); | ||
| 42 | void flex_array_free_parts(struct flex_array *fa); | ||
| 43 | int flex_array_put(struct flex_array *fa, int element_nr, void *src, | ||
| 44 | gfp_t flags); | ||
| 45 | void *flex_array_get(struct flex_array *fa, int element_nr); | ||
| 46 | |||
| 47 | #endif /* _FLEX_ARRAY_H */ | ||
