diff options
author | Michal Nazarewicz <mina86@mina86.com> | 2014-12-12 19:54:45 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-12-13 15:42:46 -0500 |
commit | 5e19b013f55a884c59a14391b22138899d1cc4cc (patch) | |
tree | 9bf703aa3539ddf0e2b9767787f112d04559ed84 /lib | |
parent | c8475d144abb1e62958cc5ec281d2a9e161c1946 (diff) |
lib: bitmap: add alignment offset for bitmap_find_next_zero_area()
Add a bitmap_find_next_zero_area_off() function which works like
bitmap_find_next_zero_area() function except it allows an offset to be
specified when alignment is checked. This lets caller request a bit such
that its number plus the offset is aligned according to the mask.
[gregory.0xf0@gmail.com: Retrieved from https://patchwork.linuxtv.org/patch/6254/ and updated documentation]
Signed-off-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Gregory Fong <gregory.0xf0@gmail.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Kukjin Kim <kgene.kim@samsung.com>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Laura Abbott <lauraa@codeaurora.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/bitmap.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/lib/bitmap.c b/lib/bitmap.c index b499ab6ada29..969ae8fbc85b 100644 --- a/lib/bitmap.c +++ b/lib/bitmap.c | |||
@@ -326,30 +326,32 @@ void bitmap_clear(unsigned long *map, unsigned int start, int len) | |||
326 | } | 326 | } |
327 | EXPORT_SYMBOL(bitmap_clear); | 327 | EXPORT_SYMBOL(bitmap_clear); |
328 | 328 | ||
329 | /* | 329 | /** |
330 | * bitmap_find_next_zero_area - find a contiguous aligned zero area | 330 | * bitmap_find_next_zero_area_off - find a contiguous aligned zero area |
331 | * @map: The address to base the search on | 331 | * @map: The address to base the search on |
332 | * @size: The bitmap size in bits | 332 | * @size: The bitmap size in bits |
333 | * @start: The bitnumber to start searching at | 333 | * @start: The bitnumber to start searching at |
334 | * @nr: The number of zeroed bits we're looking for | 334 | * @nr: The number of zeroed bits we're looking for |
335 | * @align_mask: Alignment mask for zero area | 335 | * @align_mask: Alignment mask for zero area |
336 | * @align_offset: Alignment offset for zero area. | ||
336 | * | 337 | * |
337 | * The @align_mask should be one less than a power of 2; the effect is that | 338 | * The @align_mask should be one less than a power of 2; the effect is that |
338 | * the bit offset of all zero areas this function finds is multiples of that | 339 | * the bit offset of all zero areas this function finds plus @align_offset |
339 | * power of 2. A @align_mask of 0 means no alignment is required. | 340 | * is multiple of that power of 2. |
340 | */ | 341 | */ |
341 | unsigned long bitmap_find_next_zero_area(unsigned long *map, | 342 | unsigned long bitmap_find_next_zero_area_off(unsigned long *map, |
342 | unsigned long size, | 343 | unsigned long size, |
343 | unsigned long start, | 344 | unsigned long start, |
344 | unsigned int nr, | 345 | unsigned int nr, |
345 | unsigned long align_mask) | 346 | unsigned long align_mask, |
347 | unsigned long align_offset) | ||
346 | { | 348 | { |
347 | unsigned long index, end, i; | 349 | unsigned long index, end, i; |
348 | again: | 350 | again: |
349 | index = find_next_zero_bit(map, size, start); | 351 | index = find_next_zero_bit(map, size, start); |
350 | 352 | ||
351 | /* Align allocation */ | 353 | /* Align allocation */ |
352 | index = __ALIGN_MASK(index, align_mask); | 354 | index = __ALIGN_MASK(index + align_offset, align_mask) - align_offset; |
353 | 355 | ||
354 | end = index + nr; | 356 | end = index + nr; |
355 | if (end > size) | 357 | if (end > size) |
@@ -361,7 +363,7 @@ again: | |||
361 | } | 363 | } |
362 | return index; | 364 | return index; |
363 | } | 365 | } |
364 | EXPORT_SYMBOL(bitmap_find_next_zero_area); | 366 | EXPORT_SYMBOL(bitmap_find_next_zero_area_off); |
365 | 367 | ||
366 | /* | 368 | /* |
367 | * Bitmap printing & parsing functions: first version by Nadia Yvette Chambers, | 369 | * Bitmap printing & parsing functions: first version by Nadia Yvette Chambers, |