diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/flex_array.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/flex_array.c b/lib/flex_array.c index c0ea40ba2082..0c33b24498ba 100644 --- a/lib/flex_array.c +++ b/lib/flex_array.c | |||
@@ -232,10 +232,10 @@ EXPORT_SYMBOL(flex_array_clear); | |||
232 | 232 | ||
233 | /** | 233 | /** |
234 | * flex_array_prealloc - guarantee that array space exists | 234 | * flex_array_prealloc - guarantee that array space exists |
235 | * @fa: the flex array for which to preallocate parts | 235 | * @fa: the flex array for which to preallocate parts |
236 | * @start: index of first array element for which space is allocated | 236 | * @start: index of first array element for which space is allocated |
237 | * @end: index of last (inclusive) element for which space is allocated | 237 | * @nr_elements: number of elements for which space is allocated |
238 | * @flags: page allocation flags | 238 | * @flags: page allocation flags |
239 | * | 239 | * |
240 | * This will guarantee that no future calls to flex_array_put() | 240 | * This will guarantee that no future calls to flex_array_put() |
241 | * will allocate memory. It can be used if you are expecting to | 241 | * will allocate memory. It can be used if you are expecting to |
@@ -245,13 +245,16 @@ EXPORT_SYMBOL(flex_array_clear); | |||
245 | * Locking must be provided by the caller. | 245 | * Locking must be provided by the caller. |
246 | */ | 246 | */ |
247 | int flex_array_prealloc(struct flex_array *fa, unsigned int start, | 247 | int flex_array_prealloc(struct flex_array *fa, unsigned int start, |
248 | unsigned int end, gfp_t flags) | 248 | unsigned int nr_elements, gfp_t flags) |
249 | { | 249 | { |
250 | int start_part; | 250 | int start_part; |
251 | int end_part; | 251 | int end_part; |
252 | int part_nr; | 252 | int part_nr; |
253 | unsigned int end; | ||
253 | struct flex_array_part *part; | 254 | struct flex_array_part *part; |
254 | 255 | ||
256 | end = start + nr_elements - 1; | ||
257 | |||
255 | if (start >= fa->total_nr_elements || end >= fa->total_nr_elements) | 258 | if (start >= fa->total_nr_elements || end >= fa->total_nr_elements) |
256 | return -ENOSPC; | 259 | return -ENOSPC; |
257 | if (elements_fit_in_base(fa)) | 260 | if (elements_fit_in_base(fa)) |