Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

flexible-arrays.txt: standardize document format

Each text file under Documentation follows a different
format. Some doesn't even have titles!

Change its representation to follow the adopted standard,
using ReST markups for it to be parseable by Sphinx:

- use :Author: and :Updated: markups;
- use proper markup for the document title;
- mark the literal-blocks.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>

authored by

Mauro Carvalho Chehab and committed by
Jonathan Corbet
af7175bc 72fd15c0

+14 -11
+14 -11
Documentation/flexible-arrays.txt
··· 1 + =================================== 1 2 Using flexible arrays in the kernel 2 - Last updated for 2.6.32 3 - Jonathan Corbet <corbet@lwn.net> 3 + =================================== 4 + 5 + :Updated: Last updated for 2.6.32 6 + :Author: Jonathan Corbet <corbet@lwn.net> 4 7 5 8 Large contiguous memory allocations can be unreliable in the Linux kernel. 6 9 Kernel programmers will sometimes respond to this problem by allocating ··· 29 26 locking at all; if concurrent access to an array is possible, then the 30 27 caller must arrange for appropriate mutual exclusion. 31 28 32 - The creation of a flexible array is done with: 29 + The creation of a flexible array is done with:: 33 30 34 31 #include <linux/flex_array.h> 35 32 ··· 43 40 the current code, using flags to ask for high memory is likely to lead to 44 41 notably unpleasant side effects. 45 42 46 - It is also possible to define flexible arrays at compile time with: 43 + It is also possible to define flexible arrays at compile time with:: 47 44 48 45 DEFINE_FLEX_ARRAY(name, element_size, total); 49 46 50 47 This macro will result in a definition of an array with the given name; the 51 48 element size and total will be checked for validity at compile time. 52 49 53 - Storing data into a flexible array is accomplished with a call to: 50 + Storing data into a flexible array is accomplished with a call to:: 54 51 55 52 int flex_array_put(struct flex_array *array, unsigned int element_nr, 56 53 void *src, gfp_t flags); ··· 66 63 memory allocator would be a bad thing. That can be avoided by using 67 64 GFP_ATOMIC for the flags value, but, often, there is a better way. The 68 65 trick is to ensure that any needed memory allocations are done before 69 - entering atomic context, using: 66 + entering atomic context, using:: 70 67 71 68 int flex_array_prealloc(struct flex_array *array, unsigned int start, 72 69 unsigned int nr_elements, gfp_t flags); ··· 76 73 flex_array_put() call on an element in that range is guaranteed not to 77 74 block. 78 75 79 - Getting data back out of the array is done with: 76 + Getting data back out of the array is done with:: 80 77 81 78 void *flex_array_get(struct flex_array *fa, unsigned int element_nr); 82 79 ··· 92 89 Note that, if array elements are allocated with __GFP_ZERO, they will be 93 90 initialized to zero and this poisoning will not happen. 94 91 95 - Individual elements in the array can be cleared with: 92 + Individual elements in the array can be cleared with:: 96 93 97 94 int flex_array_clear(struct flex_array *array, unsigned int element_nr); 98 95 ··· 100 97 zero. If storage for the indicated element is not allocated for the array, 101 98 flex_array_clear() will return -EINVAL instead. Note that clearing an 102 99 element does not release the storage associated with it; to reduce the 103 - allocated size of an array, call: 100 + allocated size of an array, call:: 104 101 105 102 int flex_array_shrink(struct flex_array *array); 106 103 ··· 109 106 FLEX_ARRAY_FREE bytes, so (1) it can be expensive, and (2) it will not work 110 107 if the array's pages are allocated with __GFP_ZERO. 111 108 112 - It is possible to remove all elements of an array with a call to: 109 + It is possible to remove all elements of an array with a call to:: 113 110 114 111 void flex_array_free_parts(struct flex_array *array); 115 112 116 113 This call frees all elements, but leaves the array itself in place. 117 - Freeing the entire array is done with: 114 + Freeing the entire array is done with:: 118 115 119 116 void flex_array_free(struct flex_array *array); 120 117