aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas Pitre <nico@cam.org>2007-10-11 01:06:03 -0400
committerPierre Ossman <drzeus@drzeus.cx>2007-10-11 13:09:08 -0400
commit019a5f56ec195aceadada18aaaad0f67294bdaef (patch)
treed31830cf7ec683ef6fd6719236011c9ded649847
parentc783837bc69dd0f329a441c1704f5a02d01d1bd5 (diff)
mmc: don't use weight32()
Using weight32() to determine if a value is a power of 2 is a rather heavi weight solution. The classic idiom is (x & (x - 1)) == 0, but the kernel already provide a is_power_of_2 function for it. Signed-off-by: Nicolas Pitre <nico@cam.org> Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
-rw-r--r--drivers/mmc/host/mmci.c3
-rw-r--r--drivers/mmc/host/tifm_sd.c3
2 files changed, 4 insertions, 2 deletions
diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
index 4a72772f4fe4..d0eb0a2abf4d 100644
--- a/drivers/mmc/host/mmci.c
+++ b/drivers/mmc/host/mmci.c
@@ -16,6 +16,7 @@
16#include <linux/delay.h> 16#include <linux/delay.h>
17#include <linux/err.h> 17#include <linux/err.h>
18#include <linux/highmem.h> 18#include <linux/highmem.h>
19#include <linux/log2.h>
19#include <linux/mmc/host.h> 20#include <linux/mmc/host.h>
20#include <linux/amba/bus.h> 21#include <linux/amba/bus.h>
21#include <linux/clk.h> 22#include <linux/clk.h>
@@ -391,7 +392,7 @@ static void mmci_request(struct mmc_host *mmc, struct mmc_request *mrq)
391 392
392 WARN_ON(host->mrq != NULL); 393 WARN_ON(host->mrq != NULL);
393 394
394 if (mrq->data && (hweight32(mrq->data->blksz) > 1)) { 395 if (mrq->data && !is_power_of_2(mrq->data->blksz)) {
395 printk(KERN_ERR "%s: Unsupported block size (%d bytes)\n", 396 printk(KERN_ERR "%s: Unsupported block size (%d bytes)\n",
396 mmc_hostname(mmc), mrq->data->blksz); 397 mmc_hostname(mmc), mrq->data->blksz);
397 mrq->cmd->error = -EINVAL; 398 mrq->cmd->error = -EINVAL;
diff --git a/drivers/mmc/host/tifm_sd.c b/drivers/mmc/host/tifm_sd.c
index 951392d2ce37..9b904795eb77 100644
--- a/drivers/mmc/host/tifm_sd.c
+++ b/drivers/mmc/host/tifm_sd.c
@@ -16,6 +16,7 @@
16#include <linux/mmc/host.h> 16#include <linux/mmc/host.h>
17#include <linux/highmem.h> 17#include <linux/highmem.h>
18#include <linux/scatterlist.h> 18#include <linux/scatterlist.h>
19#include <linux/log2.h>
19#include <asm/io.h> 20#include <asm/io.h>
20 21
21#define DRIVER_NAME "tifm_sd" 22#define DRIVER_NAME "tifm_sd"
@@ -637,7 +638,7 @@ static void tifm_sd_request(struct mmc_host *mmc, struct mmc_request *mrq)
637 goto err_out; 638 goto err_out;
638 } 639 }
639 640
640 if (mrq->data && (hweight32(mrq->data->blksz) > 1)) { 641 if (mrq->data && !is_power_of_2(mrq->data->blksz)) {
641 printk(KERN_ERR "%s: Unsupported block size (%d bytes)\n", 642 printk(KERN_ERR "%s: Unsupported block size (%d bytes)\n",
642 sock->dev.bus_id, mrq->data->blksz); 643 sock->dev.bus_id, mrq->data->blksz);
643 mrq->cmd->error = -EINVAL; 644 mrq->cmd->error = -EINVAL;