[S390] Cleanup & optimize bitops.

The bitops header is now a bit shorter and easier to understand since
it uses less inline assembly. It requires some tricks to persuade the
compiler to generate decent code. The ffz/ffs functions now use the
_zb_findmap/_sb_findmap table as well.
With this cleanup the new bitops for ext4 can be implemented with a
few lines, instead of another large inline assembly.

Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>

+227 -304
+227 -304
include/asm-s390/bitops.h
··· 440 __test_bit((nr),(addr)) ) 441 442 /* 443 - * ffz = Find First Zero in word. Undefined if no zero exists, 444 - * so code should check against ~0UL first.. 445 */ 446 - static inline unsigned long ffz(unsigned long word) 447 - { 448 - unsigned long bit = 0; 449 450 #ifdef __s390x__ 451 if (likely((word & 0xffffffff) == 0xffffffff)) { 452 word >>= 32; 453 - bit += 32; 454 } 455 #endif 456 if (likely((word & 0xffff) == 0xffff)) { 457 word >>= 16; 458 - bit += 16; 459 } 460 if (likely((word & 0xff) == 0xff)) { 461 word >>= 8; 462 - bit += 8; 463 } 464 - return bit + _zb_findmap[word & 0xff]; 465 } 466 467 - /* 468 - * __ffs = find first bit in word. Undefined if no bit exists, 469 - * so code should check against 0UL first.. 470 */ 471 - static inline unsigned long __ffs (unsigned long word) 472 { 473 - unsigned long bit = 0; 474 - 475 #ifdef __s390x__ 476 if (likely((word & 0xffffffff) == 0)) { 477 word >>= 32; 478 - bit += 32; 479 } 480 #endif 481 if (likely((word & 0xffff) == 0)) { 482 word >>= 16; 483 - bit += 16; 484 } 485 if (likely((word & 0xff) == 0)) { 486 word >>= 8; 487 - bit += 8; 488 } 489 - return bit + _sb_findmap[word & 0xff]; 490 } 491 492 /* 493 - * Find-bit routines.. 494 */ 495 496 - #ifndef __s390x__ 497 - 498 - static inline int 499 - find_first_zero_bit(const unsigned long * addr, unsigned long size) 500 { 501 - typedef struct { long _[__BITOPS_WORDS(size)]; } addrtype; 502 - unsigned long cmp, count; 503 - unsigned int res; 504 505 if (!size) 506 return 0; 507 - asm volatile( 508 - " lhi %1,-1\n" 509 - " lr %2,%3\n" 510 - " slr %0,%0\n" 511 - " ahi %2,31\n" 512 - " srl %2,5\n" 513 - "0: c %1,0(%0,%4)\n" 514 - " jne 1f\n" 515 - " la %0,4(%0)\n" 516 - " brct %2,0b\n" 517 - " lr %0,%3\n" 518 - " j 4f\n" 519 - "1: l %2,0(%0,%4)\n" 520 - " sll %0,3\n" 521 - " lhi %1,0xff\n" 522 - " tml %2,0xffff\n" 523 - " jno 2f\n" 524 - " ahi %0,16\n" 525 - " srl %2,16\n" 526 - "2: tml %2,0x00ff\n" 527 - " jno 3f\n" 528 - " ahi %0,8\n" 529 - " srl %2,8\n" 530 - "3: nr %2,%1\n" 531 - " ic %2,0(%2,%5)\n" 532 - " alr %0,%2\n" 533 - "4:" 534 - : "=&a" (res), "=&d" (cmp), "=&a" (count) 535 - : "a" (size), "a" (addr), "a" (&_zb_findmap), 536 - "m" (*(addrtype *) addr) : "cc"); 537 - return (res < size) ? res : size; 538 } 539 540 - static inline int 541 - find_first_bit(const unsigned long * addr, unsigned long size) 542 { 543 - typedef struct { long _[__BITOPS_WORDS(size)]; } addrtype; 544 - unsigned long cmp, count; 545 - unsigned int res; 546 547 if (!size) 548 return 0; 549 - asm volatile( 550 - " slr %1,%1\n" 551 - " lr %2,%3\n" 552 - " slr %0,%0\n" 553 - " ahi %2,31\n" 554 - " srl %2,5\n" 555 - "0: c %1,0(%0,%4)\n" 556 - " jne 1f\n" 557 - " la %0,4(%0)\n" 558 - " brct %2,0b\n" 559 - " lr %0,%3\n" 560 - " j 4f\n" 561 - "1: l %2,0(%0,%4)\n" 562 - " sll %0,3\n" 563 - " lhi %1,0xff\n" 564 - " tml %2,0xffff\n" 565 - " jnz 2f\n" 566 - " ahi %0,16\n" 567 - " srl %2,16\n" 568 - "2: tml %2,0x00ff\n" 569 - " jnz 3f\n" 570 - " ahi %0,8\n" 571 - " srl %2,8\n" 572 - "3: nr %2,%1\n" 573 - " ic %2,0(%2,%5)\n" 574 - " alr %0,%2\n" 575 - "4:" 576 - : "=&a" (res), "=&d" (cmp), "=&a" (count) 577 - : "a" (size), "a" (addr), "a" (&_sb_findmap), 578 - "m" (*(addrtype *) addr) : "cc"); 579 - return (res < size) ? res : size; 580 } 581 582 - #else /* __s390x__ */ 583 - 584 - static inline unsigned long 585 - find_first_zero_bit(const unsigned long * addr, unsigned long size) 586 - { 587 - typedef struct { long _[__BITOPS_WORDS(size)]; } addrtype; 588 - unsigned long res, cmp, count; 589 - 590 - if (!size) 591 - return 0; 592 - asm volatile( 593 - " lghi %1,-1\n" 594 - " lgr %2,%3\n" 595 - " slgr %0,%0\n" 596 - " aghi %2,63\n" 597 - " srlg %2,%2,6\n" 598 - "0: cg %1,0(%0,%4)\n" 599 - " jne 1f\n" 600 - " la %0,8(%0)\n" 601 - " brct %2,0b\n" 602 - " lgr %0,%3\n" 603 - " j 5f\n" 604 - "1: lg %2,0(%0,%4)\n" 605 - " sllg %0,%0,3\n" 606 - " clr %2,%1\n" 607 - " jne 2f\n" 608 - " aghi %0,32\n" 609 - " srlg %2,%2,32\n" 610 - "2: lghi %1,0xff\n" 611 - " tmll %2,0xffff\n" 612 - " jno 3f\n" 613 - " aghi %0,16\n" 614 - " srl %2,16\n" 615 - "3: tmll %2,0x00ff\n" 616 - " jno 4f\n" 617 - " aghi %0,8\n" 618 - " srl %2,8\n" 619 - "4: ngr %2,%1\n" 620 - " ic %2,0(%2,%5)\n" 621 - " algr %0,%2\n" 622 - "5:" 623 - : "=&a" (res), "=&d" (cmp), "=&a" (count) 624 - : "a" (size), "a" (addr), "a" (&_zb_findmap), 625 - "m" (*(addrtype *) addr) : "cc"); 626 - return (res < size) ? res : size; 627 - } 628 - 629 - static inline unsigned long 630 - find_first_bit(const unsigned long * addr, unsigned long size) 631 - { 632 - typedef struct { long _[__BITOPS_WORDS(size)]; } addrtype; 633 - unsigned long res, cmp, count; 634 - 635 - if (!size) 636 - return 0; 637 - asm volatile( 638 - " slgr %1,%1\n" 639 - " lgr %2,%3\n" 640 - " slgr %0,%0\n" 641 - " aghi %2,63\n" 642 - " srlg %2,%2,6\n" 643 - "0: cg %1,0(%0,%4)\n" 644 - " jne 1f\n" 645 - " aghi %0,8\n" 646 - " brct %2,0b\n" 647 - " lgr %0,%3\n" 648 - " j 5f\n" 649 - "1: lg %2,0(%0,%4)\n" 650 - " sllg %0,%0,3\n" 651 - " clr %2,%1\n" 652 - " jne 2f\n" 653 - " aghi %0,32\n" 654 - " srlg %2,%2,32\n" 655 - "2: lghi %1,0xff\n" 656 - " tmll %2,0xffff\n" 657 - " jnz 3f\n" 658 - " aghi %0,16\n" 659 - " srl %2,16\n" 660 - "3: tmll %2,0x00ff\n" 661 - " jnz 4f\n" 662 - " aghi %0,8\n" 663 - " srl %2,8\n" 664 - "4: ngr %2,%1\n" 665 - " ic %2,0(%2,%5)\n" 666 - " algr %0,%2\n" 667 - "5:" 668 - : "=&a" (res), "=&d" (cmp), "=&a" (count) 669 - : "a" (size), "a" (addr), "a" (&_sb_findmap), 670 - "m" (*(addrtype *) addr) : "cc"); 671 - return (res < size) ? res : size; 672 - } 673 - 674 - #endif /* __s390x__ */ 675 - 676 - static inline int 677 - find_next_zero_bit (const unsigned long * addr, unsigned long size, 678 - unsigned long offset) 679 { 680 const unsigned long *p; 681 unsigned long bit, set; ··· 702 p = addr + offset / __BITOPS_WORDSIZE; 703 if (bit) { 704 /* 705 - * s390 version of ffz returns __BITOPS_WORDSIZE 706 * if no zero bit is present in the word. 707 */ 708 - set = ffz(*p >> bit) + bit; 709 if (set >= size) 710 return size + offset; 711 if (set < __BITOPS_WORDSIZE) ··· 717 return offset + find_first_zero_bit(p, size); 718 } 719 720 - static inline int 721 - find_next_bit (const unsigned long * addr, unsigned long size, 722 - unsigned long offset) 723 { 724 const unsigned long *p; 725 unsigned long bit, set; ··· 738 p = addr + offset / __BITOPS_WORDSIZE; 739 if (bit) { 740 /* 741 - * s390 version of __ffs returns __BITOPS_WORDSIZE 742 * if no one bit is present in the word. 743 */ 744 - set = __ffs(*p & (~0UL << bit)); 745 if (set >= size) 746 return size + offset; 747 if (set < __BITOPS_WORDSIZE) ··· 763 { 764 return find_first_bit(b, 140); 765 } 766 - 767 - #include <asm-generic/bitops/ffs.h> 768 769 #include <asm-generic/bitops/fls.h> 770 #include <asm-generic/bitops/fls64.h> ··· 793 #define ext2_find_next_bit(addr, size, off) \ 794 generic_find_next_le_bit((unsigned long *)(addr), (size), (off)) 795 796 - #ifndef __s390x__ 797 - 798 - static inline int 799 - ext2_find_first_zero_bit(void *vaddr, unsigned int size) 800 { 801 - typedef struct { long _[__BITOPS_WORDS(size)]; } addrtype; 802 - unsigned long cmp, count; 803 - unsigned int res; 804 805 if (!size) 806 return 0; 807 - asm volatile( 808 - " lhi %1,-1\n" 809 - " lr %2,%3\n" 810 - " ahi %2,31\n" 811 - " srl %2,5\n" 812 - " slr %0,%0\n" 813 - "0: cl %1,0(%0,%4)\n" 814 - " jne 1f\n" 815 - " ahi %0,4\n" 816 - " brct %2,0b\n" 817 - " lr %0,%3\n" 818 - " j 4f\n" 819 - "1: l %2,0(%0,%4)\n" 820 - " sll %0,3\n" 821 - " ahi %0,24\n" 822 - " lhi %1,0xff\n" 823 - " tmh %2,0xffff\n" 824 - " jo 2f\n" 825 - " ahi %0,-16\n" 826 - " srl %2,16\n" 827 - "2: tml %2,0xff00\n" 828 - " jo 3f\n" 829 - " ahi %0,-8\n" 830 - " srl %2,8\n" 831 - "3: nr %2,%1\n" 832 - " ic %2,0(%2,%5)\n" 833 - " alr %0,%2\n" 834 - "4:" 835 - : "=&a" (res), "=&d" (cmp), "=&a" (count) 836 - : "a" (size), "a" (vaddr), "a" (&_zb_findmap), 837 - "m" (*(addrtype *) vaddr) : "cc"); 838 - return (res < size) ? res : size; 839 } 840 841 - #else /* __s390x__ */ 842 - 843 - static inline unsigned long 844 - ext2_find_first_zero_bit(void *vaddr, unsigned long size) 845 - { 846 - typedef struct { long _[__BITOPS_WORDS(size)]; } addrtype; 847 - unsigned long res, cmp, count; 848 - 849 - if (!size) 850 - return 0; 851 - asm volatile( 852 - " lghi %1,-1\n" 853 - " lgr %2,%3\n" 854 - " aghi %2,63\n" 855 - " srlg %2,%2,6\n" 856 - " slgr %0,%0\n" 857 - "0: clg %1,0(%0,%4)\n" 858 - " jne 1f\n" 859 - " aghi %0,8\n" 860 - " brct %2,0b\n" 861 - " lgr %0,%3\n" 862 - " j 5f\n" 863 - "1: cl %1,0(%0,%4)\n" 864 - " jne 2f\n" 865 - " aghi %0,4\n" 866 - "2: l %2,0(%0,%4)\n" 867 - " sllg %0,%0,3\n" 868 - " aghi %0,24\n" 869 - " lghi %1,0xff\n" 870 - " tmlh %2,0xffff\n" 871 - " jo 3f\n" 872 - " aghi %0,-16\n" 873 - " srl %2,16\n" 874 - "3: tmll %2,0xff00\n" 875 - " jo 4f\n" 876 - " aghi %0,-8\n" 877 - " srl %2,8\n" 878 - "4: ngr %2,%1\n" 879 - " ic %2,0(%2,%5)\n" 880 - " algr %0,%2\n" 881 - "5:" 882 - : "=&a" (res), "=&d" (cmp), "=&a" (count) 883 - : "a" (size), "a" (vaddr), "a" (&_zb_findmap), 884 - "m" (*(addrtype *) vaddr) : "cc"); 885 - return (res < size) ? res : size; 886 - } 887 - 888 - #endif /* __s390x__ */ 889 - 890 - static inline int 891 - ext2_find_next_zero_bit(void *vaddr, unsigned long size, unsigned long offset) 892 { 893 unsigned long *addr = vaddr, *p; 894 - unsigned long word, bit, set; 895 896 if (offset >= size) 897 return size; ··· 817 size -= offset; 818 p = addr + offset / __BITOPS_WORDSIZE; 819 if (bit) { 820 - #ifndef __s390x__ 821 - asm volatile( 822 - " ic %0,0(%1)\n" 823 - " icm %0,2,1(%1)\n" 824 - " icm %0,4,2(%1)\n" 825 - " icm %0,8,3(%1)" 826 - : "=&a" (word) : "a" (p), "m" (*p) : "cc"); 827 - #else 828 - asm volatile( 829 - " lrvg %0,%1" 830 - : "=a" (word) : "m" (*p) ); 831 - #endif 832 /* 833 * s390 version of ffz returns __BITOPS_WORDSIZE 834 * if no zero bit is present in the word. 835 */ 836 - set = ffz(word >> bit) + bit; 837 if (set >= size) 838 return size + offset; 839 if (set < __BITOPS_WORDSIZE)
··· 440 __test_bit((nr),(addr)) ) 441 442 /* 443 + * Optimized find bit helper functions. 444 */ 445 446 + /** 447 + * __ffz_word_loop - find byte offset of first long != -1UL 448 + * @addr: pointer to array of unsigned long 449 + * @size: size of the array in bits 450 + */ 451 + static inline unsigned long __ffz_word_loop(const unsigned long *addr, 452 + unsigned long size) 453 + { 454 + typedef struct { long _[__BITOPS_WORDS(size)]; } addrtype; 455 + unsigned long bytes = 0; 456 + 457 + asm volatile( 458 + #ifndef __s390x__ 459 + " ahi %1,31\n" 460 + " srl %1,5\n" 461 + "0: c %2,0(%0,%3)\n" 462 + " jne 1f\n" 463 + " la %0,4(%0)\n" 464 + " brct %1,0b\n" 465 + "1:\n" 466 + #else 467 + " aghi %1,63\n" 468 + " srlg %1,%1,6\n" 469 + "0: cg %2,0(%0,%3)\n" 470 + " jne 1f\n" 471 + " la %0,8(%0)\n" 472 + " brct %1,0b\n" 473 + "1:\n" 474 + #endif 475 + : "+a" (bytes), "+d" (size) 476 + : "d" (-1UL), "a" (addr), "m" (*(addrtype *) addr) 477 + : "cc" ); 478 + return bytes; 479 + } 480 + 481 + /** 482 + * __ffs_word_loop - find byte offset of first long != 0UL 483 + * @addr: pointer to array of unsigned long 484 + * @size: size of the array in bits 485 + */ 486 + static inline unsigned long __ffs_word_loop(const unsigned long *addr, 487 + unsigned long size) 488 + { 489 + typedef struct { long _[__BITOPS_WORDS(size)]; } addrtype; 490 + unsigned long bytes = 0; 491 + 492 + asm volatile( 493 + #ifndef __s390x__ 494 + " ahi %1,31\n" 495 + " srl %1,5\n" 496 + "0: c %2,0(%0,%3)\n" 497 + " jne 1f\n" 498 + " la %0,4(%0)\n" 499 + " brct %1,0b\n" 500 + "1:\n" 501 + #else 502 + " aghi %1,63\n" 503 + " srlg %1,%1,6\n" 504 + "0: cg %2,0(%0,%3)\n" 505 + " jne 1f\n" 506 + " la %0,8(%0)\n" 507 + " brct %1,0b\n" 508 + "1:\n" 509 + #endif 510 + : "+a" (bytes), "+a" (size) 511 + : "d" (0UL), "a" (addr), "m" (*(addrtype *) addr) 512 + : "cc" ); 513 + return bytes; 514 + } 515 + 516 + /** 517 + * __ffz_word - add number of the first unset bit 518 + * @nr: base value the bit number is added to 519 + * @word: the word that is searched for unset bits 520 + */ 521 + static inline unsigned long __ffz_word(unsigned long nr, unsigned long word) 522 + { 523 #ifdef __s390x__ 524 if (likely((word & 0xffffffff) == 0xffffffff)) { 525 word >>= 32; 526 + nr += 32; 527 } 528 #endif 529 if (likely((word & 0xffff) == 0xffff)) { 530 word >>= 16; 531 + nr += 16; 532 } 533 if (likely((word & 0xff) == 0xff)) { 534 word >>= 8; 535 + nr += 8; 536 } 537 + return nr + _zb_findmap[(unsigned char) word]; 538 } 539 540 + /** 541 + * __ffs_word - add number of the first set bit 542 + * @nr: base value the bit number is added to 543 + * @word: the word that is searched for set bits 544 */ 545 + static inline unsigned long __ffs_word(unsigned long nr, unsigned long word) 546 { 547 #ifdef __s390x__ 548 if (likely((word & 0xffffffff) == 0)) { 549 word >>= 32; 550 + nr += 32; 551 } 552 #endif 553 if (likely((word & 0xffff) == 0)) { 554 word >>= 16; 555 + nr += 16; 556 } 557 if (likely((word & 0xff) == 0)) { 558 word >>= 8; 559 + nr += 8; 560 } 561 + return nr + _sb_findmap[(unsigned char) word]; 562 + } 563 + 564 + 565 + /** 566 + * __load_ulong_be - load big endian unsigned long 567 + * @p: pointer to array of unsigned long 568 + * @offset: byte offset of source value in the array 569 + */ 570 + static inline unsigned long __load_ulong_be(const unsigned long *p, 571 + unsigned long offset) 572 + { 573 + p = (unsigned long *)((unsigned long) p + offset); 574 + return *p; 575 + } 576 + 577 + /** 578 + * __load_ulong_le - load little endian unsigned long 579 + * @p: pointer to array of unsigned long 580 + * @offset: byte offset of source value in the array 581 + */ 582 + static inline unsigned long __load_ulong_le(const unsigned long *p, 583 + unsigned long offset) 584 + { 585 + unsigned long word; 586 + 587 + p = (unsigned long *)((unsigned long) p + offset); 588 + #ifndef __s390x__ 589 + asm volatile( 590 + " ic %0,0(%1)\n" 591 + " icm %0,2,1(%1)\n" 592 + " icm %0,4,2(%1)\n" 593 + " icm %0,8,3(%1)" 594 + : "=&d" (word) : "a" (p), "m" (*p) : "cc"); 595 + #else 596 + asm volatile( 597 + " lrvg %0,%1" 598 + : "=d" (word) : "m" (*p) ); 599 + #endif 600 + return word; 601 } 602 603 /* 604 + * The various find bit functions. 605 */ 606 607 + /* 608 + * ffz - find first zero in word. 609 + * @word: The word to search 610 + * 611 + * Undefined if no zero exists, so code should check against ~0UL first. 612 + */ 613 + static inline unsigned long ffz(unsigned long word) 614 { 615 + return __ffz_word(0, word); 616 + } 617 + 618 + /** 619 + * __ffs - find first bit in word. 620 + * @word: The word to search 621 + * 622 + * Undefined if no bit exists, so code should check against 0 first. 623 + */ 624 + static inline unsigned long __ffs (unsigned long word) 625 + { 626 + return __ffs_word(0, word); 627 + } 628 + 629 + /** 630 + * ffs - find first bit set 631 + * @x: the word to search 632 + * 633 + * This is defined the same way as 634 + * the libc and compiler builtin ffs routines, therefore 635 + * differs in spirit from the above ffz (man ffs). 636 + */ 637 + static inline int ffs(int x) 638 + { 639 + if (!x) 640 + return 0; 641 + return __ffs_word(1, x); 642 + } 643 + 644 + /** 645 + * find_first_zero_bit - find the first zero bit in a memory region 646 + * @addr: The address to start the search at 647 + * @size: The maximum size to search 648 + * 649 + * Returns the bit-number of the first zero bit, not the number of the byte 650 + * containing a bit. 651 + */ 652 + static inline unsigned long find_first_zero_bit(const unsigned long *addr, 653 + unsigned long size) 654 + { 655 + unsigned long bytes, bits; 656 657 if (!size) 658 return 0; 659 + bytes = __ffz_word_loop(addr, size); 660 + bits = __ffz_word(bytes*8, __load_ulong_be(addr, bytes)); 661 + return (bits < size) ? bits : size; 662 } 663 664 + /** 665 + * find_first_bit - find the first set bit in a memory region 666 + * @addr: The address to start the search at 667 + * @size: The maximum size to search 668 + * 669 + * Returns the bit-number of the first set bit, not the number of the byte 670 + * containing a bit. 671 + */ 672 + static inline unsigned long find_first_bit(const unsigned long * addr, 673 + unsigned long size) 674 { 675 + unsigned long bytes, bits; 676 677 if (!size) 678 return 0; 679 + bytes = __ffs_word_loop(addr, size); 680 + bits = __ffs_word(bytes*8, __load_ulong_be(addr, bytes)); 681 + return (bits < size) ? bits : size; 682 } 683 684 + /** 685 + * find_next_zero_bit - find the first zero bit in a memory region 686 + * @addr: The address to base the search on 687 + * @offset: The bitnumber to start searching at 688 + * @size: The maximum size to search 689 + */ 690 + static inline int find_next_zero_bit (const unsigned long * addr, 691 + unsigned long size, 692 + unsigned long offset) 693 { 694 const unsigned long *p; 695 unsigned long bit, set; ··· 688 p = addr + offset / __BITOPS_WORDSIZE; 689 if (bit) { 690 /* 691 + * __ffz_word returns __BITOPS_WORDSIZE 692 * if no zero bit is present in the word. 693 */ 694 + set = __ffz_word(0, *p >> bit) + bit; 695 if (set >= size) 696 return size + offset; 697 if (set < __BITOPS_WORDSIZE) ··· 703 return offset + find_first_zero_bit(p, size); 704 } 705 706 + /** 707 + * find_next_bit - find the first set bit in a memory region 708 + * @addr: The address to base the search on 709 + * @offset: The bitnumber to start searching at 710 + * @size: The maximum size to search 711 + */ 712 + static inline int find_next_bit (const unsigned long * addr, 713 + unsigned long size, 714 + unsigned long offset) 715 { 716 const unsigned long *p; 717 unsigned long bit, set; ··· 718 p = addr + offset / __BITOPS_WORDSIZE; 719 if (bit) { 720 /* 721 + * __ffs_word returns __BITOPS_WORDSIZE 722 * if no one bit is present in the word. 723 */ 724 + set = __ffs_word(0, *p & (~0UL << bit)); 725 if (set >= size) 726 return size + offset; 727 if (set < __BITOPS_WORDSIZE) ··· 743 { 744 return find_first_bit(b, 140); 745 } 746 747 #include <asm-generic/bitops/fls.h> 748 #include <asm-generic/bitops/fls64.h> ··· 775 #define ext2_find_next_bit(addr, size, off) \ 776 generic_find_next_le_bit((unsigned long *)(addr), (size), (off)) 777 778 + static inline int ext2_find_first_zero_bit(void *vaddr, unsigned int size) 779 { 780 + unsigned long bytes, bits; 781 782 if (!size) 783 return 0; 784 + bytes = __ffz_word_loop(vaddr, size); 785 + bits = __ffz_word(bytes*8, __load_ulong_le(vaddr, bytes)); 786 + return (bits < size) ? bits : size; 787 } 788 789 + static inline int ext2_find_next_zero_bit(void *vaddr, unsigned long size, 790 + unsigned long offset) 791 { 792 unsigned long *addr = vaddr, *p; 793 + unsigned long bit, set; 794 795 if (offset >= size) 796 return size; ··· 882 size -= offset; 883 p = addr + offset / __BITOPS_WORDSIZE; 884 if (bit) { 885 /* 886 * s390 version of ffz returns __BITOPS_WORDSIZE 887 * if no zero bit is present in the word. 888 */ 889 + set = ffz(__load_ulong_le(p, 0) >> bit) + bit; 890 if (set >= size) 891 return size + offset; 892 if (set < __BITOPS_WORDSIZE)