Rev 1403 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1403 | Rev 1404 | ||
---|---|---|---|
Line 32... | Line 32... | ||
32 | //#include |
32 | //#include |
33 | #include "drm.h" |
33 | #include "drm.h" |
34 | #include "drmP.h" |
34 | #include "drmP.h" |
35 | #include "drm_crtc.h" |
35 | #include "drm_crtc.h" |
Line -... | Line 36... | ||
- | 36 | ||
- | 37 | unsigned long find_first_bit(const unsigned long *addr, unsigned long size) |
|
- | 38 | { |
|
- | 39 | const unsigned long *p = addr; |
|
- | 40 | unsigned long result = 0; |
|
- | 41 | unsigned long tmp; |
|
- | 42 | ||
- | 43 | while (size & ~(BITS_PER_LONG-1)) { |
|
- | 44 | if ((tmp = *(p++))) |
|
- | 45 | goto found; |
|
- | 46 | result += BITS_PER_LONG; |
|
- | 47 | size -= BITS_PER_LONG; |
|
- | 48 | } |
|
- | 49 | if (!size) |
|
- | 50 | return result; |
|
- | 51 | ||
- | 52 | tmp = (*p) & (~0UL >> (BITS_PER_LONG - size)); |
|
- | 53 | if (tmp == 0UL) /* Are any bits set? */ |
|
- | 54 | return result + size; /* Nope. */ |
|
- | 55 | found: |
|
- | 56 | return result + __ffs(tmp); |
|
- | 57 | } |
|
- | 58 | ||
- | 59 | int find_next_bit(const unsigned long *addr, int size, int offset) |
|
- | 60 | { |
|
- | 61 | const unsigned long *p = addr + (offset >> 5); |
|
- | 62 | int set = 0, bit = offset & 31, res; |
|
- | 63 | ||
- | 64 | if (bit) |
|
- | 65 | { |
|
- | 66 | /* |
|
- | 67 | * Look for nonzero in the first 32 bits: |
|
- | 68 | */ |
|
- | 69 | __asm__("bsfl %1,%0\n\t" |
|
- | 70 | "jne 1f\n\t" |
|
- | 71 | "movl $32, %0\n" |
|
- | 72 | "1:" |
|
- | 73 | : "=r" (set) |
|
- | 74 | : "r" (*p >> bit)); |
|
- | 75 | if (set < (32 - bit)) |
|
- | 76 | return set + offset; |
|
- | 77 | set = 32 - bit; |
|
- | 78 | p++; |
|
- | 79 | } |
|
- | 80 | /* |
|
- | 81 | * No set bit yet, search remaining full words for a bit |
|
- | 82 | */ |
|
- | 83 | res = find_first_bit (p, size - 32 * (p - addr)); |
|
- | 84 | return (offset + set + res); |
|
Line 36... | Line 85... | ||
36 | 85 | } |
|
Line 37... | Line 86... | ||
37 | 86 | ||
38 | #define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x)) |
87 | #define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x)) |