From: "Robert P. J. Day" <rpjday@crashcourse.ca>
To: Linux PPC Mailing List <linuxppc-dev@ozlabs.org>
Subject: [PATCH] POWERPC: Use "is_power_of_2" macro for simplicity.
Date: Tue, 6 Nov 2007 12:11:42 -0500 (EST) [thread overview]
Message-ID: <Pine.LNX.4.64.0711061210520.25269@localhost.localdomain> (raw)
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
========================================================================
reply other threads:[~2007-11-06 20:01 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Pine.LNX.4.64.0711061210520.25269@localhost.localdomain \
--to=rpjday@crashcourse.ca \
--cc=linuxppc-dev@ozlabs.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).