Commit 229f5afd authored by vignesh babu's avatar vignesh babu Committed by Greg Kroah-Hartman

PCI: is_power_of_2 in drivers/pci/pci.c

Replacing n & (n - 1) for power of 2 check by is_power_of_2(n)
Signed-off-by: default avatarvignesh babu <vignesh.babu@wipro.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 40730d10
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/string.h> #include <linux/string.h>
#include <linux/log2.h>
#include <asm/dma.h> /* isa_dma_bridge_buggy */ #include <asm/dma.h> /* isa_dma_bridge_buggy */
#include "pci.h" #include "pci.h"
...@@ -1454,7 +1455,7 @@ int pcix_set_mmrbc(struct pci_dev *dev, int mmrbc) ...@@ -1454,7 +1455,7 @@ int pcix_set_mmrbc(struct pci_dev *dev, int mmrbc)
int cap, err = -EINVAL; int cap, err = -EINVAL;
u32 stat, cmd, v, o; 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; goto out;
v = ffs(mmrbc) - 10; v = ffs(mmrbc) - 10;
...@@ -1526,7 +1527,7 @@ int pcie_set_readrq(struct pci_dev *dev, int rq) ...@@ -1526,7 +1527,7 @@ int pcie_set_readrq(struct pci_dev *dev, int rq)
int cap, err = -EINVAL; int cap, err = -EINVAL;
u16 ctl, v; u16 ctl, v;
if (rq < 128 || rq > 4096 || (rq & (rq-1))) if (rq < 128 || rq > 4096 || !is_power_of_2(rq))
goto out; goto out;
v = (ffs(rq) - 8) << 12; v = (ffs(rq) - 8) << 12;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment