diff options
author | vignesh babu <vignesh.babu@wipro.com> | 2007-10-19 17:38:44 -0400 |
---|---|---|
committer | Alasdair G Kergon <agk@redhat.com> | 2007-10-19 21:01:06 -0400 |
commit | 6f3c3f0afa50782dc1742c968646c491657d255a (patch) | |
tree | cb1f69504094cec60564be51c405bba5eb66c322 /drivers | |
parent | ae9da83f6d800fe1f3b23bfbc8f7222ad1c5bb74 (diff) |
dm: use is_power_of_2
Replacing n & (n - 1) for power of 2 check by is_power_of_2(n)
Signed-off-by: vignesh babu <vignesh.babu@wipro.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/md/dm-raid1.c | 3 | ||||
-rw-r--r-- | drivers/md/dm-snap.c | 3 | ||||
-rw-r--r-- | drivers/md/dm-stripe.c | 3 |
3 files changed, 6 insertions, 3 deletions
diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c index 6f60f307fae2..2b2ca371e20b 100644 --- a/drivers/md/dm-raid1.c +++ b/drivers/md/dm-raid1.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <linux/time.h> | 19 | #include <linux/time.h> |
20 | #include <linux/vmalloc.h> | 20 | #include <linux/vmalloc.h> |
21 | #include <linux/workqueue.h> | 21 | #include <linux/workqueue.h> |
22 | #include <linux/log2.h> | ||
22 | 23 | ||
23 | #define DM_MSG_PREFIX "raid1" | 24 | #define DM_MSG_PREFIX "raid1" |
24 | #define DM_IO_PAGES 64 | 25 | #define DM_IO_PAGES 64 |
@@ -995,7 +996,7 @@ static void free_context(struct mirror_set *ms, struct dm_target *ti, | |||
995 | 996 | ||
996 | static inline int _check_region_size(struct dm_target *ti, uint32_t size) | 997 | static inline int _check_region_size(struct dm_target *ti, uint32_t size) |
997 | { | 998 | { |
998 | return !(size % (PAGE_SIZE >> 9) || (size & (size - 1)) || | 999 | return !(size % (PAGE_SIZE >> 9) || !is_power_of_2(size) || |
999 | size > ti->len); | 1000 | size > ti->len); |
1000 | } | 1001 | } |
1001 | 1002 | ||
diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c index 98a633f3d6b0..cee16fadd9ee 100644 --- a/drivers/md/dm-snap.c +++ b/drivers/md/dm-snap.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/module.h> | 17 | #include <linux/module.h> |
18 | #include <linux/slab.h> | 18 | #include <linux/slab.h> |
19 | #include <linux/vmalloc.h> | 19 | #include <linux/vmalloc.h> |
20 | #include <linux/log2.h> | ||
20 | 21 | ||
21 | #include "dm-snap.h" | 22 | #include "dm-snap.h" |
22 | #include "dm-bio-list.h" | 23 | #include "dm-bio-list.h" |
@@ -415,7 +416,7 @@ static int set_chunk_size(struct dm_snapshot *s, const char *chunk_size_arg, | |||
415 | chunk_size = round_up(chunk_size, PAGE_SIZE >> 9); | 416 | chunk_size = round_up(chunk_size, PAGE_SIZE >> 9); |
416 | 417 | ||
417 | /* Check chunk_size is a power of 2 */ | 418 | /* Check chunk_size is a power of 2 */ |
418 | if (chunk_size & (chunk_size - 1)) { | 419 | if (!is_power_of_2(chunk_size)) { |
419 | *error = "Chunk size is not a power of 2"; | 420 | *error = "Chunk size is not a power of 2"; |
420 | return -EINVAL; | 421 | return -EINVAL; |
421 | } | 422 | } |
diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c index 51f5e0760012..969944a8aba2 100644 --- a/drivers/md/dm-stripe.c +++ b/drivers/md/dm-stripe.c | |||
@@ -11,6 +11,7 @@ | |||
11 | #include <linux/blkdev.h> | 11 | #include <linux/blkdev.h> |
12 | #include <linux/bio.h> | 12 | #include <linux/bio.h> |
13 | #include <linux/slab.h> | 13 | #include <linux/slab.h> |
14 | #include <linux/log2.h> | ||
14 | 15 | ||
15 | #define DM_MSG_PREFIX "striped" | 16 | #define DM_MSG_PREFIX "striped" |
16 | 17 | ||
@@ -99,7 +100,7 @@ static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv) | |||
99 | /* | 100 | /* |
100 | * chunk_size is a power of two | 101 | * chunk_size is a power of two |
101 | */ | 102 | */ |
102 | if (!chunk_size || (chunk_size & (chunk_size - 1)) || | 103 | if (!is_power_of_2(chunk_size) || |
103 | (chunk_size < (PAGE_SIZE >> SECTOR_SHIFT))) { | 104 | (chunk_size < (PAGE_SIZE >> SECTOR_SHIFT))) { |
104 | ti->error = "Invalid chunk size"; | 105 | ti->error = "Invalid chunk size"; |
105 | return -EINVAL; | 106 | return -EINVAL; |