diff options
author | Heiko Carstens <heiko.carstens@de.ibm.com> | 2013-09-23 06:01:44 -0400 |
---|---|---|
committer | Martin Schwidefsky <schwidefsky@de.ibm.com> | 2013-10-24 11:16:56 -0400 |
commit | 7d7c7b24e416afb2637be8447e03ca4457c100fd (patch) | |
tree | 3f6df4a49ba2fdaaa01e824d77811777d745cc6d /drivers/s390 | |
parent | b1cb7e2b6c3e8758e7406422b66c54c066737977 (diff) |
s390/bitops: rename find_first_bit_left() to find_first_bit_inv()
find_first_bit_left() and friends have nothing to do with the normal
LSB0 bit numbering for big endian machines used in Linux (least
significant bit has bit number 0).
Instead they use MSB0 bit numbering, where the most signficant bit has
bit number 0. So rename find_first_bit_left() and friends to
find_first_bit_inv(), to avoid any confusion.
Also provide inv versions of set_bit, clear_bit and test_bit.
This also removes the confusing use of e.g. set_bit() in airq.c which
uses a "be_to_le" bit number conversion, which could imply that instead
set_bit_le() could be used. But that is entirely wrong since the _le
bitops variant uses yet another bit numbering scheme.
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Diffstat (limited to 'drivers/s390')
-rw-r--r-- | drivers/s390/cio/airq.c | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/drivers/s390/cio/airq.c b/drivers/s390/cio/airq.c index d028fd800c9c..f055df0b167f 100644 --- a/drivers/s390/cio/airq.c +++ b/drivers/s390/cio/airq.c | |||
@@ -194,15 +194,14 @@ EXPORT_SYMBOL(airq_iv_release); | |||
194 | */ | 194 | */ |
195 | unsigned long airq_iv_alloc_bit(struct airq_iv *iv) | 195 | unsigned long airq_iv_alloc_bit(struct airq_iv *iv) |
196 | { | 196 | { |
197 | const unsigned long be_to_le = BITS_PER_LONG - 1; | ||
198 | unsigned long bit; | 197 | unsigned long bit; |
199 | 198 | ||
200 | if (!iv->avail) | 199 | if (!iv->avail) |
201 | return -1UL; | 200 | return -1UL; |
202 | spin_lock(&iv->lock); | 201 | spin_lock(&iv->lock); |
203 | bit = find_first_bit_left(iv->avail, iv->bits); | 202 | bit = find_first_bit_inv(iv->avail, iv->bits); |
204 | if (bit < iv->bits) { | 203 | if (bit < iv->bits) { |
205 | clear_bit(bit ^ be_to_le, iv->avail); | 204 | clear_bit_inv(bit, iv->avail); |
206 | if (bit >= iv->end) | 205 | if (bit >= iv->end) |
207 | iv->end = bit + 1; | 206 | iv->end = bit + 1; |
208 | } else | 207 | } else |
@@ -220,19 +219,17 @@ EXPORT_SYMBOL(airq_iv_alloc_bit); | |||
220 | */ | 219 | */ |
221 | void airq_iv_free_bit(struct airq_iv *iv, unsigned long bit) | 220 | void airq_iv_free_bit(struct airq_iv *iv, unsigned long bit) |
222 | { | 221 | { |
223 | const unsigned long be_to_le = BITS_PER_LONG - 1; | ||
224 | |||
225 | if (!iv->avail) | 222 | if (!iv->avail) |
226 | return; | 223 | return; |
227 | spin_lock(&iv->lock); | 224 | spin_lock(&iv->lock); |
228 | /* Clear (possibly left over) interrupt bit */ | 225 | /* Clear (possibly left over) interrupt bit */ |
229 | clear_bit(bit ^ be_to_le, iv->vector); | 226 | clear_bit_inv(bit, iv->vector); |
230 | /* Make the bit position available again */ | 227 | /* Make the bit position available again */ |
231 | set_bit(bit ^ be_to_le, iv->avail); | 228 | set_bit_inv(bit, iv->avail); |
232 | if (bit == iv->end - 1) { | 229 | if (bit == iv->end - 1) { |
233 | /* Find new end of bit-field */ | 230 | /* Find new end of bit-field */ |
234 | while (--iv->end > 0) | 231 | while (--iv->end > 0) |
235 | if (!test_bit((iv->end - 1) ^ be_to_le, iv->avail)) | 232 | if (!test_bit_inv(iv->end - 1, iv->avail)) |
236 | break; | 233 | break; |
237 | } | 234 | } |
238 | spin_unlock(&iv->lock); | 235 | spin_unlock(&iv->lock); |
@@ -251,15 +248,13 @@ EXPORT_SYMBOL(airq_iv_free_bit); | |||
251 | unsigned long airq_iv_scan(struct airq_iv *iv, unsigned long start, | 248 | unsigned long airq_iv_scan(struct airq_iv *iv, unsigned long start, |
252 | unsigned long end) | 249 | unsigned long end) |
253 | { | 250 | { |
254 | const unsigned long be_to_le = BITS_PER_LONG - 1; | ||
255 | unsigned long bit; | 251 | unsigned long bit; |
256 | 252 | ||
257 | /* Find non-zero bit starting from 'ivs->next'. */ | 253 | /* Find non-zero bit starting from 'ivs->next'. */ |
258 | bit = find_next_bit_left(iv->vector, end, start); | 254 | bit = find_next_bit_inv(iv->vector, end, start); |
259 | if (bit >= end) | 255 | if (bit >= end) |
260 | return -1UL; | 256 | return -1UL; |
261 | /* Clear interrupt bit (find left uses big-endian bit numbers) */ | 257 | clear_bit_inv(bit, iv->vector); |
262 | clear_bit(bit ^ be_to_le, iv->vector); | ||
263 | return bit; | 258 | return bit; |
264 | } | 259 | } |
265 | EXPORT_SYMBOL(airq_iv_scan); | 260 | EXPORT_SYMBOL(airq_iv_scan); |