aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/isdn/mISDN
diff options
context:
space:
mode:
authorAkinobu Mita <akinobu.mita@gmail.com>2012-11-28 20:27:45 -0500
committerDavid S. Miller <davem@davemloft.net>2012-11-30 12:10:57 -0500
commit481af03bfbc1e07954310689831ad2695b7c6a44 (patch)
treeb9781c35dcf9990c7f94ec3cbc0c6c93063fbddb /drivers/isdn/mISDN
parent6e22ce2c6e4315522526279365d6e86e8f67a5fa (diff)
mISDN: improve bitops usage
This improves bitops usages in several points: - Convert u64 to a proper bitmap declaration. This enables to remove superfluous typecasting from 'u64' to 'unsigned long *'. - Convert superfluous atomic bitops to non atomic bitops. The bitmap is allocated on the stack and it is not accessed by any other threads, so using atomic bitops is not necessary. - Use find_next_zero_bit and find_next_zero_bit instead of calling test_bit() for each bit. Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Cc: Karsten Keil <isdn@linux-pingi.de> Cc: netdev@vger.kernel.org Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/isdn/mISDN')
-rw-r--r--drivers/isdn/mISDN/tei.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/drivers/isdn/mISDN/tei.c b/drivers/isdn/mISDN/tei.c
index be88728f1106..592f597d8951 100644
--- a/drivers/isdn/mISDN/tei.c
+++ b/drivers/isdn/mISDN/tei.c
@@ -250,7 +250,7 @@ tei_debug(struct FsmInst *fi, char *fmt, ...)
250static int 250static int
251get_free_id(struct manager *mgr) 251get_free_id(struct manager *mgr)
252{ 252{
253 u64 ids = 0; 253 DECLARE_BITMAP(ids, 64) = { [0 ... BITS_TO_LONGS(64) - 1] = 0 };
254 int i; 254 int i;
255 struct layer2 *l2; 255 struct layer2 *l2;
256 256
@@ -261,11 +261,11 @@ get_free_id(struct manager *mgr)
261 __func__); 261 __func__);
262 return -EBUSY; 262 return -EBUSY;
263 } 263 }
264 test_and_set_bit(l2->ch.nr, (u_long *)&ids); 264 __set_bit(l2->ch.nr, ids);
265 } 265 }
266 for (i = 1; i < 64; i++) 266 i = find_next_zero_bit(ids, 64, 1);
267 if (!test_bit(i, (u_long *)&ids)) 267 if (i < 64)
268 return i; 268 return i;
269 printk(KERN_WARNING "%s: more as 63 layer2 for one device\n", 269 printk(KERN_WARNING "%s: more as 63 layer2 for one device\n",
270 __func__); 270 __func__);
271 return -EBUSY; 271 return -EBUSY;
@@ -274,7 +274,7 @@ get_free_id(struct manager *mgr)
274static int 274static int
275get_free_tei(struct manager *mgr) 275get_free_tei(struct manager *mgr)
276{ 276{
277 u64 ids = 0; 277 DECLARE_BITMAP(ids, 64) = { [0 ... BITS_TO_LONGS(64) - 1] = 0 };
278 int i; 278 int i;
279 struct layer2 *l2; 279 struct layer2 *l2;
280 280
@@ -288,11 +288,11 @@ get_free_tei(struct manager *mgr)
288 continue; 288 continue;
289 i -= 64; 289 i -= 64;
290 290
291 test_and_set_bit(i, (u_long *)&ids); 291 __set_bit(i, ids);
292 } 292 }
293 for (i = 0; i < 64; i++) 293 i = find_first_zero_bit(ids, 64);
294 if (!test_bit(i, (u_long *)&ids)) 294 if (i < 64)
295 return i + 64; 295 return i + 64;
296 printk(KERN_WARNING "%s: more as 63 dynamic tei for one device\n", 296 printk(KERN_WARNING "%s: more as 63 dynamic tei for one device\n",
297 __func__); 297 __func__);
298 return -1; 298 return -1;