linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] POWERPC: Use "is_power_of_2" macro for simplicity.
@ 2007-11-06 17:11 Robert P. J. Day
  0 siblings, 0 replies; only message in thread
From: Robert P. J. Day @ 2007-11-06 17:11 UTC (permalink / raw)
  To: Linux PPC Mailing List


Signed-off-by: Robert P. J. Day <rpjday@crashcourse.ca>

---

diff --git a/arch/powerpc/lib/rheap.c b/arch/powerpc/lib/rheap.c
index 22c3b4f..53b4e91 100644
--- a/arch/powerpc/lib/rheap.c
+++ b/arch/powerpc/lib/rheap.c
@@ -19,6 +19,7 @@
 #include <linux/mm.h>
 #include <linux/err.h>
 #include <linux/slab.h>
+#include <linux/log2.h>

 #include <asm/rheap.h>

@@ -254,8 +255,7 @@ rh_info_t *rh_create(unsigned int alignment)
 {
 	rh_info_t *info;

-	/* Alignment must be a power of two */
-	if ((alignment & (alignment - 1)) != 0)
+	if (!is_power_of_2(alignment))
 		return ERR_PTR(-EINVAL);

 	info = kmalloc(sizeof(*info), GFP_KERNEL);
@@ -303,8 +303,7 @@ void rh_init(rh_info_t * info, unsigned int alignment, int max_blocks,
 	int i;
 	rh_block_t *blk;

-	/* Alignment must be a power of two */
-	if ((alignment & (alignment - 1)) != 0)
+	if (!is_power_of_2(alignment))
 		return;

 	info->alignment = alignment;
@@ -446,8 +445,7 @@ unsigned long rh_alloc_align(rh_info_t * info, int size, int alignment, const ch
 	rh_block_t *newblk;
 	unsigned long start, sp_size;

-	/* Validate size, and alignment must be power of two */
-	if (size <= 0 || (alignment & (alignment - 1)) != 0)
+	if (size <= 0 || !is_power_of_2(alignment))
 		return (unsigned long) -EINVAL;

 	/* Align to configured alignment */
-- 
========================================================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry
Waterloo, Ontario, CANADA

http://crashcourse.ca
========================================================================

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2007-11-06 20:01 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-11-06 17:11 [PATCH] POWERPC: Use "is_power_of_2" macro for simplicity Robert P. J. Day

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).