diff options
author | Rasmus Villemoes <linux@rasmusvillemoes.dk> | 2014-08-06 19:10:16 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-08-06 21:01:26 -0400 |
commit | 9279d3286e10736766edcaf815ae10e00856e448 (patch) | |
tree | e1cf25875387eed2cc32dbdd1fc5aa2042ff35e0 | |
parent | a855174878f06d197ddfde5cbe1e69a1d4a2df27 (diff) |
lib: bitmap: change parameter of bitmap_*_region to unsigned
Changing the pos parameter of __reg_op to unsigned allows the compiler
to generate slightly smaller and simpler code. Also update its callers
bitmap_*_region to receive and pass unsigned int. The return types of
bitmap_find_free_region and bitmap_allocate_region are still int to
allow a negative error code to be returned. An int is certainly capable
of representing any realistic return value.
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | include/linux/bitmap.h | 6 | ||||
-rw-r--r-- | lib/bitmap.c | 12 |
2 files changed, 9 insertions, 9 deletions
diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h index 83c1c7d25073..210037833356 100644 --- a/include/linux/bitmap.h +++ b/include/linux/bitmap.h | |||
@@ -140,9 +140,9 @@ extern void bitmap_onto(unsigned long *dst, const unsigned long *orig, | |||
140 | const unsigned long *relmap, int bits); | 140 | const unsigned long *relmap, int bits); |
141 | extern void bitmap_fold(unsigned long *dst, const unsigned long *orig, | 141 | extern void bitmap_fold(unsigned long *dst, const unsigned long *orig, |
142 | int sz, int bits); | 142 | int sz, int bits); |
143 | extern int bitmap_find_free_region(unsigned long *bitmap, int bits, int order); | 143 | extern int bitmap_find_free_region(unsigned long *bitmap, unsigned int bits, int order); |
144 | extern void bitmap_release_region(unsigned long *bitmap, int pos, int order); | 144 | extern void bitmap_release_region(unsigned long *bitmap, unsigned int pos, int order); |
145 | extern int bitmap_allocate_region(unsigned long *bitmap, int pos, int order); | 145 | extern int bitmap_allocate_region(unsigned long *bitmap, unsigned int pos, int order); |
146 | extern void bitmap_copy_le(void *dst, const unsigned long *src, int nbits); | 146 | extern void bitmap_copy_le(void *dst, const unsigned long *src, int nbits); |
147 | extern int bitmap_ord_to_pos(const unsigned long *bitmap, int n, int bits); | 147 | extern int bitmap_ord_to_pos(const unsigned long *bitmap, int n, int bits); |
148 | 148 | ||
diff --git a/lib/bitmap.c b/lib/bitmap.c index 2714df9f5cdb..c2f3807b3601 100644 --- a/lib/bitmap.c +++ b/lib/bitmap.c | |||
@@ -1042,7 +1042,7 @@ enum { | |||
1042 | REG_OP_RELEASE, /* clear all bits in region */ | 1042 | REG_OP_RELEASE, /* clear all bits in region */ |
1043 | }; | 1043 | }; |
1044 | 1044 | ||
1045 | static int __reg_op(unsigned long *bitmap, int pos, int order, int reg_op) | 1045 | static int __reg_op(unsigned long *bitmap, unsigned int pos, int order, int reg_op) |
1046 | { | 1046 | { |
1047 | int nbits_reg; /* number of bits in region */ | 1047 | int nbits_reg; /* number of bits in region */ |
1048 | int index; /* index first long of region in bitmap */ | 1048 | int index; /* index first long of region in bitmap */ |
@@ -1108,11 +1108,11 @@ done: | |||
1108 | * Return the bit offset in bitmap of the allocated region, | 1108 | * Return the bit offset in bitmap of the allocated region, |
1109 | * or -errno on failure. | 1109 | * or -errno on failure. |
1110 | */ | 1110 | */ |
1111 | int bitmap_find_free_region(unsigned long *bitmap, int bits, int order) | 1111 | int bitmap_find_free_region(unsigned long *bitmap, unsigned int bits, int order) |
1112 | { | 1112 | { |
1113 | int pos, end; /* scans bitmap by regions of size order */ | 1113 | unsigned int pos, end; /* scans bitmap by regions of size order */ |
1114 | 1114 | ||
1115 | for (pos = 0 ; (end = pos + (1 << order)) <= bits; pos = end) { | 1115 | for (pos = 0 ; (end = pos + (1U << order)) <= bits; pos = end) { |
1116 | if (!__reg_op(bitmap, pos, order, REG_OP_ISFREE)) | 1116 | if (!__reg_op(bitmap, pos, order, REG_OP_ISFREE)) |
1117 | continue; | 1117 | continue; |
1118 | __reg_op(bitmap, pos, order, REG_OP_ALLOC); | 1118 | __reg_op(bitmap, pos, order, REG_OP_ALLOC); |
@@ -1133,7 +1133,7 @@ EXPORT_SYMBOL(bitmap_find_free_region); | |||
1133 | * | 1133 | * |
1134 | * No return value. | 1134 | * No return value. |
1135 | */ | 1135 | */ |
1136 | void bitmap_release_region(unsigned long *bitmap, int pos, int order) | 1136 | void bitmap_release_region(unsigned long *bitmap, unsigned int pos, int order) |
1137 | { | 1137 | { |
1138 | __reg_op(bitmap, pos, order, REG_OP_RELEASE); | 1138 | __reg_op(bitmap, pos, order, REG_OP_RELEASE); |
1139 | } | 1139 | } |
@@ -1150,7 +1150,7 @@ EXPORT_SYMBOL(bitmap_release_region); | |||
1150 | * Return 0 on success, or %-EBUSY if specified region wasn't | 1150 | * Return 0 on success, or %-EBUSY if specified region wasn't |
1151 | * free (not all bits were zero). | 1151 | * free (not all bits were zero). |
1152 | */ | 1152 | */ |
1153 | int bitmap_allocate_region(unsigned long *bitmap, int pos, int order) | 1153 | int bitmap_allocate_region(unsigned long *bitmap, unsigned int pos, int order) |
1154 | { | 1154 | { |
1155 | if (!__reg_op(bitmap, pos, order, REG_OP_ISFREE)) | 1155 | if (!__reg_op(bitmap, pos, order, REG_OP_ISFREE)) |
1156 | return -EBUSY; | 1156 | return -EBUSY; |