Skip to content

Commit aabb4af

Browse files
andy-shevdavem330
authored andcommitted
net: core: Use the bitmap API to allocate bitmaps
Use bitmap_zalloc() and bitmap_free() instead of hand-writing them. It is less verbose and it improves the type checking and semantic. While at it, add missing header inclusion (should be bitops.h, but with the above change it becomes bitmap.h). Suggested-by: Sergey Ryazanov <[email protected]> Reviewed-by: Simon Horman <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Andy Shevchenko <[email protected]> Reviewed-by: Przemek Kitszel <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 8f6b846 commit aabb4af

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

net/core/dev.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
*/
7070

7171
#include <linux/uaccess.h>
72-
#include <linux/bitops.h>
72+
#include <linux/bitmap.h>
7373
#include <linux/capability.h>
7474
#include <linux/cpu.h>
7575
#include <linux/types.h>
@@ -1080,7 +1080,7 @@ static int __dev_alloc_name(struct net *net, const char *name, char *buf)
10801080
return -EINVAL;
10811081

10821082
/* Use one page as a bit array of possible slots */
1083-
inuse = (unsigned long *) get_zeroed_page(GFP_ATOMIC);
1083+
inuse = bitmap_zalloc(max_netdevices, GFP_ATOMIC);
10841084
if (!inuse)
10851085
return -ENOMEM;
10861086

@@ -1109,7 +1109,7 @@ static int __dev_alloc_name(struct net *net, const char *name, char *buf)
11091109
}
11101110

11111111
i = find_first_zero_bit(inuse, max_netdevices);
1112-
free_page((unsigned long) inuse);
1112+
bitmap_free(inuse);
11131113
}
11141114

11151115
snprintf(buf, IFNAMSIZ, name, i);

0 commit comments

Comments
 (0)