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

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

 



Use is_power_of_2().

Signed-off-by: Jan Blunck <jblunck@xxxxxxx>
---
 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;
 	}
 

-- 

--
dm-devel mailing list
dm-devel@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/dm-devel

[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux