Skip to content

Commit

Permalink
PCI: is_power_of_2 in drivers/pci/pci.c
Browse files Browse the repository at this point in the history
Replacing n & (n - 1) for power of 2 check by is_power_of_2(n)

Signed-off-by: vignesh babu <vignesh.babu@wipro.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
vignesh babu authored and Greg Kroah-Hartman committed Oct 12, 2007
1 parent 40730d1 commit 229f5af
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/pci/pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <linux/module.h>
#include <linux/spinlock.h>
#include <linux/string.h>
#include <linux/log2.h>
#include <asm/dma.h> /* isa_dma_bridge_buggy */
#include "pci.h"

Expand Down Expand Up @@ -1454,7 +1455,7 @@ int pcix_set_mmrbc(struct pci_dev *dev, int mmrbc)
int cap, err = -EINVAL;
u32 stat, cmd, v, o;

if (mmrbc < 512 || mmrbc > 4096 || (mmrbc & (mmrbc-1)))
if (mmrbc < 512 || mmrbc > 4096 || !is_power_of_2(mmrbc))
goto out;

v = ffs(mmrbc) - 10;
Expand Down Expand Up @@ -1526,7 +1527,7 @@ int pcie_set_readrq(struct pci_dev *dev, int rq)
int cap, err = -EINVAL;
u16 ctl, v;

if (rq < 128 || rq > 4096 || (rq & (rq-1)))
if (rq < 128 || rq > 4096 || !is_power_of_2(rq))
goto out;

v = (ffs(rq) - 8) << 12;
Expand Down

0 comments on commit 229f5af

Please sign in to comment.