[openib-general] patch pci-create-__pci_bus_find_cap_start-from-__pci_bus_find_cap.patch added to gregkh-2.6 tree

gregkh at suse.de gregkh at suse.de
Wed Dec 6 22:11:57 PST 2006


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

     Subject: PCI: Create __pci_bus_find_cap_start() from __pci_bus_find_cap()

to my gregkh-2.6 tree.  Its filename is

     pci-create-__pci_bus_find_cap_start-from-__pci_bus_find_cap.patch

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


>From owner-linux-pci at atrey.karlin.mff.cuni.cz Tue Nov 21 23:26:32 2006
From: Michael Ellerman <michael at ellerman.id.au>
To: linux-pci at atrey.karlin.mff.cuni.cz
Cc: Greg Kroah-Hartman <greg at kroah.com>, Benjamin Herrenschmidt <benh at kernel.crashing.org>, Eric W.Biederman <ebiederm at xmission.com>, Segher Boessenkool <segher at kernel.crashing.org>, <support at pathscale.com>, <openib-general at openib.org>, <brice at myri.com>
Date: Wed, 22 Nov 2006 18:26:16 +1100
Subject: PCI: Create __pci_bus_find_cap_start() from __pci_bus_find_cap()
Message-Id: <20061122072621.BC4B967C35 at ozlabs.org>

The current implementation of __pci_bus_find_cap() does two things,
first it determines the start of the capability chain for the device,
and then it trys to find the requested capability.

Split these out, so that we can use the two parts independantly in
a subsequent patch. Externally visible behaviour should be unchanged.

Signed-off-by: Michael Ellerman <michael at ellerman.id.au>
Signed-off-by: Greg Kroah-Hartman <gregkh at suse.de>

---
 drivers/pci/pci.c |   28 +++++++++++++++++++---------
 1 file changed, 19 insertions(+), 9 deletions(-)

--- gregkh-2.6.orig/drivers/pci/pci.c
+++ gregkh-2.6/drivers/pci/pci.c
@@ -96,10 +96,10 @@ int pci_find_next_capability(struct pci_
 }
 EXPORT_SYMBOL_GPL(pci_find_next_capability);
 
-static int __pci_bus_find_cap(struct pci_bus *bus, unsigned int devfn, u8 hdr_type, int cap)
+static int __pci_bus_find_cap_start(struct pci_bus *bus,
+				    unsigned int devfn, u8 hdr_type)
 {
 	u16 status;
-	u8 pos;
 
 	pci_bus_read_config_word(bus, devfn, PCI_STATUS, &status);
 	if (!(status & PCI_STATUS_CAP_LIST))
@@ -108,15 +108,14 @@ static int __pci_bus_find_cap(struct pci
 	switch (hdr_type) {
 	case PCI_HEADER_TYPE_NORMAL:
 	case PCI_HEADER_TYPE_BRIDGE:
-		pos = PCI_CAPABILITY_LIST;
-		break;
+		return PCI_CAPABILITY_LIST;
 	case PCI_HEADER_TYPE_CARDBUS:
-		pos = PCI_CB_CAPABILITY_LIST;
-		break;
+		return PCI_CB_CAPABILITY_LIST;
 	default:
 		return 0;
 	}
-	return __pci_find_next_cap(bus, devfn, pos, cap);
+
+	return 0;
 }
 
 /**
@@ -140,7 +139,13 @@ static int __pci_bus_find_cap(struct pci
  */
 int pci_find_capability(struct pci_dev *dev, int cap)
 {
-	return __pci_bus_find_cap(dev->bus, dev->devfn, dev->hdr_type, cap);
+	int pos;
+
+	pos = __pci_bus_find_cap_start(dev->bus, dev->devfn, dev->hdr_type);
+	if (pos)
+		pos = __pci_find_next_cap(dev->bus, dev->devfn, pos, cap);
+
+	return pos;
 }
 
 /**
@@ -158,11 +163,16 @@ int pci_find_capability(struct pci_dev *
  */
 int pci_bus_find_capability(struct pci_bus *bus, unsigned int devfn, int cap)
 {
+	int pos;
 	u8 hdr_type;
 
 	pci_bus_read_config_byte(bus, devfn, PCI_HEADER_TYPE, &hdr_type);
 
-	return __pci_bus_find_cap(bus, devfn, hdr_type & 0x7f, cap);
+	pos = __pci_bus_find_cap_start(bus, devfn, hdr_type & 0x7f);
+	if (pos)
+		pos = __pci_find_next_cap(bus, devfn, pos, cap);
+
+	return pos;
 }
 
 /**


Patches currently in gregkh-2.6 which might be from michael at ellerman.id.au are





More information about the general mailing list