diff options
-rw-r--r-- | arch/mips/txx9/rbtx4927/irq.c | 6 | ||||
-rw-r--r-- | arch/mips/txx9/rbtx4938/irq.c | 8 | ||||
-rw-r--r-- | include/asm-mips/txx9/generic.h | 18 |
3 files changed, 25 insertions, 7 deletions
diff --git a/arch/mips/txx9/rbtx4927/irq.c b/arch/mips/txx9/rbtx4927/irq.c index 22076e3f03a8..9c14ebb26cb4 100644 --- a/arch/mips/txx9/rbtx4927/irq.c +++ b/arch/mips/txx9/rbtx4927/irq.c | |||
@@ -133,9 +133,9 @@ static int toshiba_rbtx4927_irq_nested(int sw_irq) | |||
133 | u8 level3; | 133 | u8 level3; |
134 | 134 | ||
135 | level3 = readb(rbtx4927_imstat_addr) & 0x1f; | 135 | level3 = readb(rbtx4927_imstat_addr) & 0x1f; |
136 | if (level3) | 136 | if (unlikely(!level3)) |
137 | sw_irq = RBTX4927_IRQ_IOC + fls(level3) - 1; | 137 | return -1; |
138 | return sw_irq; | 138 | return RBTX4927_IRQ_IOC + __fls8(level3); |
139 | } | 139 | } |
140 | 140 | ||
141 | static void __init toshiba_rbtx4927_irq_ioc_init(void) | 141 | static void __init toshiba_rbtx4927_irq_ioc_init(void) |
diff --git a/arch/mips/txx9/rbtx4938/irq.c b/arch/mips/txx9/rbtx4938/irq.c index ca2f8306ce93..7d21befb8932 100644 --- a/arch/mips/txx9/rbtx4938/irq.c +++ b/arch/mips/txx9/rbtx4938/irq.c | |||
@@ -85,10 +85,10 @@ static int toshiba_rbtx4938_irq_nested(int sw_irq) | |||
85 | u8 level3; | 85 | u8 level3; |
86 | 86 | ||
87 | level3 = readb(rbtx4938_imstat_addr); | 87 | level3 = readb(rbtx4938_imstat_addr); |
88 | if (level3) | 88 | if (unlikely(!level3)) |
89 | /* must use fls so onboard ATA has priority */ | 89 | return -1; |
90 | sw_irq = RBTX4938_IRQ_IOC + fls(level3) - 1; | 90 | /* must use fls so onboard ATA has priority */ |
91 | return sw_irq; | 91 | return RBTX4938_IRQ_IOC + __fls8(level3); |
92 | } | 92 | } |
93 | 93 | ||
94 | static void __init | 94 | static void __init |
diff --git a/include/asm-mips/txx9/generic.h b/include/asm-mips/txx9/generic.h index 1e1a9f2d2379..dc85515eac13 100644 --- a/include/asm-mips/txx9/generic.h +++ b/include/asm-mips/txx9/generic.h | |||
@@ -64,4 +64,22 @@ struct physmap_flash_data; | |||
64 | void txx9_physmap_flash_init(int no, unsigned long addr, unsigned long size, | 64 | void txx9_physmap_flash_init(int no, unsigned long addr, unsigned long size, |
65 | const struct physmap_flash_data *pdata); | 65 | const struct physmap_flash_data *pdata); |
66 | 66 | ||
67 | /* 8 bit version of __fls(): find first bit set (returns 0..7) */ | ||
68 | static inline unsigned int __fls8(unsigned char x) | ||
69 | { | ||
70 | int r = 7; | ||
71 | |||
72 | if (!(x & 0xf0)) { | ||
73 | r -= 4; | ||
74 | x <<= 4; | ||
75 | } | ||
76 | if (!(x & 0xc0)) { | ||
77 | r -= 2; | ||
78 | x <<= 2; | ||
79 | } | ||
80 | if (!(x & 0x80)) | ||
81 | r -= 1; | ||
82 | return r; | ||
83 | } | ||
84 | |||
67 | #endif /* __ASM_TXX9_GENERIC_H */ | 85 | #endif /* __ASM_TXX9_GENERIC_H */ |