diff options
author | J.R. Mauro <jrm8005@gmail.com> | 2008-10-20 19:01:31 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2008-10-22 09:56:37 -0700 |
commit | 4460a860f728983f685cb23140c241c10dca0d32 (patch) | |
tree | acf9f5d1fd8f002b6a9d5e06e731b14d2fcaee80 /drivers/staging/echo/bit_operations.h | |
parent | 786ed801ac9607a98fdeb8230ea05202a41fc1c7 (diff) |
Staging: Lindent the echo driver
Lindent drivers/staging/echo*
Signed-off by: J.R. Mauro <jrm8005@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging/echo/bit_operations.h')
-rw-r--r-- | drivers/staging/echo/bit_operations.h | 187 |
1 files changed, 90 insertions, 97 deletions
diff --git a/drivers/staging/echo/bit_operations.h b/drivers/staging/echo/bit_operations.h index abcd7a2168a..cecdcf3fd75 100644 --- a/drivers/staging/echo/bit_operations.h +++ b/drivers/staging/echo/bit_operations.h @@ -36,14 +36,15 @@ \return The bit number of the highest set bit, or -1 if the word is zero. */ static __inline__ int top_bit(unsigned int bits) { - int res; - - __asm__ (" xorl %[res],%[res];\n" - " decl %[res];\n" - " bsrl %[bits],%[res]\n" - : [res] "=&r" (res) - : [bits] "rm" (bits)); - return res; + int res; + + __asm__(" xorl %[res],%[res];\n" + " decl %[res];\n" + " bsrl %[bits],%[res]\n" + :[res] "=&r" (res) + :[bits] "rm"(bits) + ); + return res; } /*! \brief Find the bit position of the lowest set bit in a word @@ -51,84 +52,75 @@ static __inline__ int top_bit(unsigned int bits) \return The bit number of the lowest set bit, or -1 if the word is zero. */ static __inline__ int bottom_bit(unsigned int bits) { - int res; - - __asm__ (" xorl %[res],%[res];\n" - " decl %[res];\n" - " bsfl %[bits],%[res]\n" - : [res] "=&r" (res) - : [bits] "rm" (bits)); - return res; + int res; + + __asm__(" xorl %[res],%[res];\n" + " decl %[res];\n" + " bsfl %[bits],%[res]\n" + :[res] "=&r" (res) + :[bits] "rm"(bits) + ); + return res; } #else static __inline__ int top_bit(unsigned int bits) { - int i; - - if (bits == 0) - return -1; - i = 0; - if (bits & 0xFFFF0000) - { - bits &= 0xFFFF0000; - i += 16; - } - if (bits & 0xFF00FF00) - { - bits &= 0xFF00FF00; - i += 8; - } - if (bits & 0xF0F0F0F0) - { - bits &= 0xF0F0F0F0; - i += 4; - } - if (bits & 0xCCCCCCCC) - { - bits &= 0xCCCCCCCC; - i += 2; - } - if (bits & 0xAAAAAAAA) - { - bits &= 0xAAAAAAAA; - i += 1; - } - return i; + int i; + + if (bits == 0) + return -1; + i = 0; + if (bits & 0xFFFF0000) { + bits &= 0xFFFF0000; + i += 16; + } + if (bits & 0xFF00FF00) { + bits &= 0xFF00FF00; + i += 8; + } + if (bits & 0xF0F0F0F0) { + bits &= 0xF0F0F0F0; + i += 4; + } + if (bits & 0xCCCCCCCC) { + bits &= 0xCCCCCCCC; + i += 2; + } + if (bits & 0xAAAAAAAA) { + bits &= 0xAAAAAAAA; + i += 1; + } + return i; } static __inline__ int bottom_bit(unsigned int bits) { - int i; - - if (bits == 0) - return -1; - i = 32; - if (bits & 0x0000FFFF) - { - bits &= 0x0000FFFF; - i -= 16; - } - if (bits & 0x00FF00FF) - { - bits &= 0x00FF00FF; - i -= 8; - } - if (bits & 0x0F0F0F0F) - { - bits &= 0x0F0F0F0F; - i -= 4; - } - if (bits & 0x33333333) - { - bits &= 0x33333333; - i -= 2; - } - if (bits & 0x55555555) - { - bits &= 0x55555555; - i -= 1; - } - return i; + int i; + + if (bits == 0) + return -1; + i = 32; + if (bits & 0x0000FFFF) { + bits &= 0x0000FFFF; + i -= 16; + } + if (bits & 0x00FF00FF) { + bits &= 0x00FF00FF; + i -= 8; + } + if (bits & 0x0F0F0F0F) { + bits &= 0x0F0F0F0F; + i -= 4; + } + if (bits & 0x33333333) { + bits &= 0x33333333; + i -= 2; + } + if (bits & 0x55555555) { + bits &= 0x55555555; + i -= 1; + } + return i; } #endif @@ -138,13 +130,14 @@ static __inline__ int bottom_bit(unsigned int bits) static __inline__ uint8_t bit_reverse8(uint8_t x) { #if defined(__i386__) || defined(__x86_64__) - /* If multiply is fast */ - return ((x*0x0802U & 0x22110U) | (x*0x8020U & 0x88440U))*0x10101U >> 16; + /* If multiply is fast */ + return ((x * 0x0802U & 0x22110U) | (x * 0x8020U & 0x88440U)) * + 0x10101U >> 16; #else - /* If multiply is slow, but we have a barrel shifter */ - x = (x >> 4) | (x << 4); - x = ((x & 0xCC) >> 2) | ((x & 0x33) << 2); - return ((x & 0xAA) >> 1) | ((x & 0x55) << 1); + /* If multiply is slow, but we have a barrel shifter */ + x = (x >> 4) | (x << 4); + x = ((x & 0xCC) >> 2) | ((x & 0x33) << 2); + return ((x & 0xAA) >> 1) | ((x & 0x55) << 1); #endif } @@ -184,7 +177,7 @@ uint16_t make_mask16(uint16_t x); \return The word with the single set bit. */ static __inline__ uint32_t least_significant_one32(uint32_t x) { - return (x & (-(int32_t) x)); + return (x & (-(int32_t) x)); } /*! \brief Find the most significant one in a word, and return a word @@ -194,10 +187,10 @@ static __inline__ uint32_t least_significant_one32(uint32_t x) static __inline__ uint32_t most_significant_one32(uint32_t x) { #if defined(__i386__) || defined(__x86_64__) - return 1 << top_bit(x); + return 1 << top_bit(x); #else - x = make_mask32(x); - return (x ^ (x >> 1)); + x = make_mask32(x); + return (x ^ (x >> 1)); #endif } @@ -206,8 +199,8 @@ static __inline__ uint32_t most_significant_one32(uint32_t x) \return 1 for odd, or 0 for even. */ static __inline__ int parity8(uint8_t x) { - x = (x ^ (x >> 4)) & 0x0F; - return (0x6996 >> x) & 1; + x = (x ^ (x >> 4)) & 0x0F; + return (0x6996 >> x) & 1; } /*! \brief Find the parity of a 16 bit word. @@ -215,9 +208,9 @@ static __inline__ int parity8(uint8_t x) \return 1 for odd, or 0 for even. */ static __inline__ int parity16(uint16_t x) { - x ^= (x >> 8); - x = (x ^ (x >> 4)) & 0x0F; - return (0x6996 >> x) & 1; + x ^= (x >> 8); + x = (x ^ (x >> 4)) & 0x0F; + return (0x6996 >> x) & 1; } /*! \brief Find the parity of a 32 bit word. @@ -225,10 +218,10 @@ static __inline__ int parity16(uint16_t x) \return 1 for odd, or 0 for even. */ static __inline__ int parity32(uint32_t x) { - x ^= (x >> 16); - x ^= (x >> 8); - x = (x ^ (x >> 4)) & 0x0F; - return (0x6996 >> x) & 1; + x ^= (x >> 16); + x ^= (x >> 8); + x = (x ^ (x >> 4)) & 0x0F; + return (0x6996 >> x) & 1; } #endif |