[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[dm-devel] [patch 10/11] dm: use is_power_of_2()



Use is_power_of_2().

Signed-off-by: Jan Blunck <jblunck suse de>
---
 drivers/md/dm-stripe.c |   13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

--- a/drivers/md/dm-stripe.c
+++ b/drivers/md/dm-stripe.c
@@ -96,12 +96,13 @@ static int stripe_ctr(struct dm_target *
 		return -EINVAL;
 	}
 
-	/*
-	 * chunk_size is a power of two
-	 */
-	if (!chunk_size || (chunk_size & (chunk_size - 1)) ||
-	    (chunk_size < (PAGE_SIZE >> 9))) {
-		ti->error = "Invalid chunk size";
+	if (!is_power_of_2(chunk_size)) {
+		ti->error = "Chunk size is not a power of 2";
+		return -EINVAL;
+	}
+
+	if (chunk_size < (PAGE_SIZE >> 9)) {
+		ti->error = "Chunk size is smaller than page size";
 		return -EINVAL;
 	}
 

-- 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]