Skip to content

Commit

Permalink
mmc: don't use weight32()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Nicolas Pitre authored and Pierre Ossman committed Oct 11, 2007
1 parent c783837 commit 019a5f5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion drivers/mmc/host/mmci.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <linux/delay.h>
#include <linux/err.h>
#include <linux/highmem.h>
#include <linux/log2.h>
#include <linux/mmc/host.h>
#include <linux/amba/bus.h>
#include <linux/clk.h>
Expand Down Expand Up @@ -391,7 +392,7 @@ static void mmci_request(struct mmc_host *mmc, struct mmc_request *mrq)

WARN_ON(host->mrq != NULL);

if (mrq->data && (hweight32(mrq->data->blksz) > 1)) {
if (mrq->data && !is_power_of_2(mrq->data->blksz)) {
printk(KERN_ERR "%s: Unsupported block size (%d bytes)\n",
mmc_hostname(mmc), mrq->data->blksz);
mrq->cmd->error = -EINVAL;
Expand Down
3 changes: 2 additions & 1 deletion drivers/mmc/host/tifm_sd.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <linux/mmc/host.h>
#include <linux/highmem.h>
#include <linux/scatterlist.h>
#include <linux/log2.h>
#include <asm/io.h>

#define DRIVER_NAME "tifm_sd"
Expand Down Expand Up @@ -637,7 +638,7 @@ static void tifm_sd_request(struct mmc_host *mmc, struct mmc_request *mrq)
goto err_out;
}

if (mrq->data && (hweight32(mrq->data->blksz) > 1)) {
if (mrq->data && !is_power_of_2(mrq->data->blksz)) {
printk(KERN_ERR "%s: Unsupported block size (%d bytes)\n",
sock->dev.bus_id, mrq->data->blksz);
mrq->cmd->error = -EINVAL;
Expand Down

0 comments on commit 019a5f5

Please sign in to comment.