diff options
| author | Thomas Gleixner <tglx@linutronix.de> | 2015-01-12 04:51:13 -0500 |
|---|---|---|
| committer | Thomas Gleixner <tglx@linutronix.de> | 2015-01-12 04:51:13 -0500 |
| commit | 2f5eaf66e580f64032b365a00157b6b58c266b37 (patch) | |
| tree | 7852017c864f0eb3833782e2a017952bd8531458 /lib/bitmap.c | |
| parent | c291ee622165cb2c8d4e7af63fffd499354a23be (diff) | |
| parent | 91d1179212161f220938198b742c328ad38fd0a3 (diff) | |
Merge tag 'irqchip-urgent-3.19' of git://git.infradead.org/users/jcooper/linux into irq/urgent
irqchip urgent fixes for v3.19 from Jason Cooper
- mtk-sysirq: Fix error handling
- hip04: Fix cpu map for 16bit value
- gic-v3-its: Clear a warning regarding decimal constants
- omap-intc: Fix legacy DMA regression
- atmel-aic-common: Retain priority when changing type
Diffstat (limited to 'lib/bitmap.c')
| -rw-r--r-- | lib/bitmap.c | 53 |
1 files changed, 42 insertions, 11 deletions
diff --git a/lib/bitmap.c b/lib/bitmap.c index b499ab6ada29..324ea9eab8c1 100644 --- a/lib/bitmap.c +++ b/lib/bitmap.c | |||
| @@ -12,6 +12,8 @@ | |||
| 12 | #include <linux/bitmap.h> | 12 | #include <linux/bitmap.h> |
| 13 | #include <linux/bitops.h> | 13 | #include <linux/bitops.h> |
| 14 | #include <linux/bug.h> | 14 | #include <linux/bug.h> |
| 15 | |||
| 16 | #include <asm/page.h> | ||
| 15 | #include <asm/uaccess.h> | 17 | #include <asm/uaccess.h> |
| 16 | 18 | ||
| 17 | /* | 19 | /* |
| @@ -326,30 +328,32 @@ void bitmap_clear(unsigned long *map, unsigned int start, int len) | |||
| 326 | } | 328 | } |
| 327 | EXPORT_SYMBOL(bitmap_clear); | 329 | EXPORT_SYMBOL(bitmap_clear); |
| 328 | 330 | ||
| 329 | /* | 331 | /** |
| 330 | * bitmap_find_next_zero_area - find a contiguous aligned zero area | 332 | * bitmap_find_next_zero_area_off - find a contiguous aligned zero area |
| 331 | * @map: The address to base the search on | 333 | * @map: The address to base the search on |
| 332 | * @size: The bitmap size in bits | 334 | * @size: The bitmap size in bits |
| 333 | * @start: The bitnumber to start searching at | 335 | * @start: The bitnumber to start searching at |
| 334 | * @nr: The number of zeroed bits we're looking for | 336 | * @nr: The number of zeroed bits we're looking for |
| 335 | * @align_mask: Alignment mask for zero area | 337 | * @align_mask: Alignment mask for zero area |
| 338 | * @align_offset: Alignment offset for zero area. | ||
| 336 | * | 339 | * |
| 337 | * The @align_mask should be one less than a power of 2; the effect is that | 340 | * 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 | 341 | * 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. | 342 | * is multiple of that power of 2. |
| 340 | */ | 343 | */ |
| 341 | unsigned long bitmap_find_next_zero_area(unsigned long *map, | 344 | unsigned long bitmap_find_next_zero_area_off(unsigned long *map, |
| 342 | unsigned long size, | 345 | unsigned long size, |
| 343 | unsigned long start, | 346 | unsigned long start, |
| 344 | unsigned int nr, | 347 | unsigned int nr, |
| 345 | unsigned long align_mask) | 348 | unsigned long align_mask, |
| 349 | unsigned long align_offset) | ||
| 346 | { | 350 | { |
| 347 | unsigned long index, end, i; | 351 | unsigned long index, end, i; |
| 348 | again: | 352 | again: |
| 349 | index = find_next_zero_bit(map, size, start); | 353 | index = find_next_zero_bit(map, size, start); |
| 350 | 354 | ||
| 351 | /* Align allocation */ | 355 | /* Align allocation */ |
| 352 | index = __ALIGN_MASK(index, align_mask); | 356 | index = __ALIGN_MASK(index + align_offset, align_mask) - align_offset; |
| 353 | 357 | ||
| 354 | end = index + nr; | 358 | end = index + nr; |
| 355 | if (end > size) | 359 | if (end > size) |
| @@ -361,7 +365,7 @@ again: | |||
| 361 | } | 365 | } |
| 362 | return index; | 366 | return index; |
| 363 | } | 367 | } |
| 364 | EXPORT_SYMBOL(bitmap_find_next_zero_area); | 368 | EXPORT_SYMBOL(bitmap_find_next_zero_area_off); |
| 365 | 369 | ||
| 366 | /* | 370 | /* |
| 367 | * Bitmap printing & parsing functions: first version by Nadia Yvette Chambers, | 371 | * Bitmap printing & parsing functions: first version by Nadia Yvette Chambers, |
| @@ -584,6 +588,33 @@ int bitmap_scnlistprintf(char *buf, unsigned int buflen, | |||
| 584 | EXPORT_SYMBOL(bitmap_scnlistprintf); | 588 | EXPORT_SYMBOL(bitmap_scnlistprintf); |
| 585 | 589 | ||
| 586 | /** | 590 | /** |
| 591 | * bitmap_print_to_pagebuf - convert bitmap to list or hex format ASCII string | ||
| 592 | * @list: indicates whether the bitmap must be list | ||
| 593 | * @buf: page aligned buffer into which string is placed | ||
| 594 | * @maskp: pointer to bitmap to convert | ||
| 595 | * @nmaskbits: size of bitmap, in bits | ||
| 596 | * | ||
| 597 | * Output format is a comma-separated list of decimal numbers and | ||
| 598 | * ranges if list is specified or hex digits grouped into comma-separated | ||
| 599 | * sets of 8 digits/set. Returns the number of characters written to buf. | ||
| 600 | */ | ||
| 601 | int bitmap_print_to_pagebuf(bool list, char *buf, const unsigned long *maskp, | ||
| 602 | int nmaskbits) | ||
| 603 | { | ||
| 604 | ptrdiff_t len = PTR_ALIGN(buf + PAGE_SIZE - 1, PAGE_SIZE) - buf - 2; | ||
| 605 | int n = 0; | ||
| 606 | |||
| 607 | if (len > 1) { | ||
| 608 | n = list ? bitmap_scnlistprintf(buf, len, maskp, nmaskbits) : | ||
| 609 | bitmap_scnprintf(buf, len, maskp, nmaskbits); | ||
| 610 | buf[n++] = '\n'; | ||
| 611 | buf[n] = '\0'; | ||
| 612 | } | ||
| 613 | return n; | ||
| 614 | } | ||
| 615 | EXPORT_SYMBOL(bitmap_print_to_pagebuf); | ||
| 616 | |||
| 617 | /** | ||
| 587 | * __bitmap_parselist - convert list format ASCII string to bitmap | 618 | * __bitmap_parselist - convert list format ASCII string to bitmap |
| 588 | * @buf: read nul-terminated user string from this buffer | 619 | * @buf: read nul-terminated user string from this buffer |
| 589 | * @buflen: buffer size in bytes. If string is smaller than this | 620 | * @buflen: buffer size in bytes. If string is smaller than this |
