Skip to contentSkip to conversation

patch pci-is_power_of_2-in-drivers-pci-pci.c.patch added to

KJ [email protected] 1 participant 1 message Aug 14, 2007

Subsystems (2)
lore
Share & tools
lore

[email protected]

author Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

Subject: PCI: is_power_of_2 in drivers/pci/pci.c

to my gregkh-2.6 tree. Its filename is

pci-is_power_of_2-in-drivers-pci-pci.c.patch

This tree can be found at
http://www.kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/patches/

From [email protected] Tue Aug 14 15:26:37 2007
From: vignesh babu <[email protected]>
Date: Mon, 13 Aug 2007 18:23:14 +0530
Subject: PCI: is_power_of_2 in drivers/pci/pci.c
To: [email protected]
Cc: [email protected], Kernel Janitors List <[email protected]>
Message-ID: <[email protected]>

Replacing n & (n - 1) for power of 2 check by is_power_of_2(n)

---
 drivers/pci/pci.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/pci/pci.c +3 -2
@@ -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"
 
@@ -1454,7 +1455,7 @@ int pcix_set_mmrbc(struct pci_dev *dev, 
 	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;
@@ -1526,7 +1527,7 @@ int pcie_set_readrq(struct pci_dev *dev,
 	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;

Patches currently in gregkh-2.6 which might be from [email protected] are

pci/pci-is_power_of_2-in-drivers-pci-pci.c.patch
_______________________________________________
REMINDER: this mailing list moved to vger.kernel.org and current one will be discontinued soon. To resubscribe, send email to [email protected] with
&quot;subscribe kernel-janitors&quot; in message body and follow instructions.

Kernel-janitors mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/kernel-janitors