Browse Source

Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/pci-2.6

* git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/pci-2.6:
  pci: hotplug: pciehp: fix error code path in hpc_power_off_slot
  PCI: Add DECLARE_PCI_DEVICE_TABLE macro
  PCI: fix up error messages for pci_bus registering
  PCI: fix section mismatch warning in pci_scan_child_bus
  PCI: consolidate duplicated MSI enable functions
  PCI: use dev_printk in quirk messages
Linus Torvalds 17 years ago
parent
commit
12f981f902

+ 4 - 2
Documentation/pci.txt

@@ -123,7 +123,8 @@ initialization with a pointer to a structure describing the driver
 
 
 
 
 The ID table is an array of struct pci_device_id entries ending with an
 The ID table is an array of struct pci_device_id entries ending with an
-all-zero entry.  Each entry consists of:
+all-zero entry; use of the macro DECLARE_PCI_DEVICE_TABLE is the preferred
+method of declaring the table.  Each entry consists of:
 
 
 	vendor,device	Vendor and device ID to match (or PCI_ANY_ID)
 	vendor,device	Vendor and device ID to match (or PCI_ANY_ID)
 
 
@@ -191,7 +192,8 @@ Tips on when/where to use the above attributes:
 
 
 	o Do not mark the struct pci_driver.
 	o Do not mark the struct pci_driver.
 
 
-	o The ID table array should be marked __devinitdata.
+	o The ID table array should be marked __devinitconst; this is done
+	  automatically if the table is declared with DECLARE_PCI_DEVICE_TABLE().
 
 
 	o The probe() and remove() functions should be marked __devinit
 	o The probe() and remove() functions should be marked __devinit
 	  and __devexit respectively.  All initialization functions
 	  and __devexit respectively.  All initialization functions

+ 6 - 4
drivers/pci/bus.c

@@ -145,13 +145,15 @@ void pci_bus_add_devices(struct pci_bus *bus)
 			child_bus = dev->subordinate;
 			child_bus = dev->subordinate;
 			child_bus->dev.parent = child_bus->bridge;
 			child_bus->dev.parent = child_bus->bridge;
 			retval = device_register(&child_bus->dev);
 			retval = device_register(&child_bus->dev);
-			if (!retval)
+			if (retval)
+				dev_err(&dev->dev, "Error registering pci_bus,"
+					" continuing...\n");
+			else
 				retval = device_create_file(&child_bus->dev,
 				retval = device_create_file(&child_bus->dev,
 							&dev_attr_cpuaffinity);
 							&dev_attr_cpuaffinity);
 			if (retval)
 			if (retval)
-				dev_err(&dev->dev, "Error registering pci_bus"
-					" device bridge symlink,"
-					" continuing...\n");
+				dev_err(&dev->dev, "Error creating cpuaffinity"
+					" file, continuing...\n");
 		}
 		}
 	}
 	}
 }
 }

+ 1 - 1
drivers/pci/hotplug-pci.c

@@ -4,7 +4,7 @@
 #include "pci.h"
 #include "pci.h"
 
 
 
 
-unsigned int pci_do_scan_bus(struct pci_bus *bus)
+unsigned int __devinit pci_do_scan_bus(struct pci_bus *bus)
 {
 {
 	unsigned int max;
 	unsigned int max;
 
 

+ 1 - 1
drivers/pci/hotplug/acpiphp_glue.c

@@ -1085,7 +1085,7 @@ static int acpiphp_bus_trim(acpi_handle handle)
  * This function should be called per *physical slot*,
  * This function should be called per *physical slot*,
  * not per each slot object in ACPI namespace.
  * not per each slot object in ACPI namespace.
  */
  */
-static int enable_device(struct acpiphp_slot *slot)
+static int __ref enable_device(struct acpiphp_slot *slot)
 {
 {
 	struct pci_dev *dev;
 	struct pci_dev *dev;
 	struct pci_bus *bus = slot->bridge->pci_bus;
 	struct pci_bus *bus = slot->bridge->pci_bus;

+ 1 - 1
drivers/pci/hotplug/cpci_hotplug_pci.c

@@ -250,7 +250,7 @@ int cpci_led_off(struct slot* slot)
  * Device configuration functions
  * Device configuration functions
  */
  */
 
 
-int cpci_configure_slot(struct slot* slot)
+int __ref cpci_configure_slot(struct slot *slot)
 {
 {
 	struct pci_bus *parent;
 	struct pci_bus *parent;
 	int fn;
 	int fn;

+ 3 - 2
drivers/pci/hotplug/pciehp_hpc.c

@@ -711,7 +711,8 @@ static int hpc_power_off_slot(struct slot * slot)
 	retval = pcie_write_cmd(slot, slot_cmd, cmd_mask);
 	retval = pcie_write_cmd(slot, slot_cmd, cmd_mask);
 	if (retval) {
 	if (retval) {
 		err("%s: Write command failed!\n", __FUNCTION__);
 		err("%s: Write command failed!\n", __FUNCTION__);
-		return -1;
+		retval = -1;
+		goto out;
 	}
 	}
 	dbg("%s: SLOTCTRL %x write cmd %x\n",
 	dbg("%s: SLOTCTRL %x write cmd %x\n",
 	    __FUNCTION__, ctrl->cap_base + SLOTCTRL, slot_cmd);
 	    __FUNCTION__, ctrl->cap_base + SLOTCTRL, slot_cmd);
@@ -722,7 +723,7 @@ static int hpc_power_off_slot(struct slot * slot)
 	 * removed from the slot/adapter.
 	 * removed from the slot/adapter.
 	 */
 	 */
 	msleep(1000);
 	msleep(1000);
-
+ out:
 	if (changed)
 	if (changed)
 		pcie_unmask_bad_dllp(ctrl);
 		pcie_unmask_bad_dllp(ctrl);
 
 

+ 1 - 1
drivers/pci/hotplug/pciehp_pci.c

@@ -167,7 +167,7 @@ static void program_fw_provided_values(struct pci_dev *dev)
 	}
 	}
 }
 }
 
 
-static int pciehp_add_bridge(struct pci_dev *dev)
+static int __ref pciehp_add_bridge(struct pci_dev *dev)
 {
 {
 	struct pci_bus *parent = dev->bus;
 	struct pci_bus *parent = dev->bus;
 	int pass, busnr, start = parent->secondary;
 	int pass, busnr, start = parent->secondary;

+ 1 - 1
drivers/pci/hotplug/shpchp_pci.c

@@ -96,7 +96,7 @@ static void program_fw_provided_values(struct pci_dev *dev)
 	}
 	}
 }
 }
 
 
-int shpchp_configure_device(struct slot *p_slot)
+int __ref shpchp_configure_device(struct slot *p_slot)
 {
 {
 	struct pci_dev *dev;
 	struct pci_dev *dev;
 	struct pci_bus *parent = p_slot->ctrl->pci_dev->subordinate;
 	struct pci_bus *parent = p_slot->ctrl->pci_dev->subordinate;

+ 4 - 4
drivers/pci/probe.c

@@ -286,7 +286,7 @@ static void pci_read_bases(struct pci_dev *dev, unsigned int howmany, int rom)
 	}
 	}
 }
 }
 
 
-void pci_read_bridge_bases(struct pci_bus *child)
+void __devinit pci_read_bridge_bases(struct pci_bus *child)
 {
 {
 	struct pci_dev *dev = child->self;
 	struct pci_dev *dev = child->self;
 	u8 io_base_lo, io_limit_lo;
 	u8 io_base_lo, io_limit_lo;
@@ -472,7 +472,7 @@ static void pci_fixup_parent_subordinate_busnr(struct pci_bus *child, int max)
  * them, we proceed to assigning numbers to the remaining buses in
  * them, we proceed to assigning numbers to the remaining buses in
  * order to avoid overlaps between old and new bus numbers.
  * order to avoid overlaps between old and new bus numbers.
  */
  */
-int pci_scan_bridge(struct pci_bus *bus, struct pci_dev * dev, int max, int pass)
+int __devinit pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max, int pass)
 {
 {
 	struct pci_bus *child;
 	struct pci_bus *child;
 	int is_cardbus = (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS);
 	int is_cardbus = (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS);
@@ -1008,7 +1008,7 @@ int pci_scan_slot(struct pci_bus *bus, int devfn)
 	return nr;
 	return nr;
 }
 }
 
 
-unsigned int pci_scan_child_bus(struct pci_bus *bus)
+unsigned int __devinit pci_scan_child_bus(struct pci_bus *bus)
 {
 {
 	unsigned int devfn, pass, max = bus->secondary;
 	unsigned int devfn, pass, max = bus->secondary;
 	struct pci_dev *dev;
 	struct pci_dev *dev;
@@ -1116,7 +1116,7 @@ err_out:
 	return NULL;
 	return NULL;
 }
 }
 
 
-struct pci_bus *pci_scan_bus_parented(struct device *parent,
+struct pci_bus * __devinit pci_scan_bus_parented(struct device *parent,
 		int bus, struct pci_ops *ops, void *sysdata)
 		int bus, struct pci_ops *ops, void *sysdata)
 {
 {
 	struct pci_bus *b;
 	struct pci_bus *b;

+ 8 - 33
drivers/pci/quirks.c

@@ -1652,9 +1652,8 @@ static void __devinit quirk_via_cx700_pci_parking_caching(struct pci_dev *dev)
 			pci_write_config_byte(dev, 0x75, 0x1);
 			pci_write_config_byte(dev, 0x75, 0x1);
 			pci_write_config_byte(dev, 0x77, 0x0);
 			pci_write_config_byte(dev, 0x77, 0x0);
 
 
-			printk(KERN_INFO
-				"PCI: VIA CX700 PCI parking/caching fixup on %s\n",
-				pci_name(dev));
+			dev_info(&dev->dev,
+				"Disabling VIA CX700 PCI parking/caching\n");
 		}
 		}
 	}
 	}
 }
 }
@@ -1726,32 +1725,6 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_HT2
 			quirk_msi_ht_cap);
 			quirk_msi_ht_cap);
 
 
 
 
-/*
- *  Force enable MSI mapping capability on HT bridges
- */
-static void __devinit quirk_msi_ht_cap_enable(struct pci_dev *dev)
-{
-	int pos, ttl = 48;
-
-	pos = pci_find_ht_capability(dev, HT_CAPTYPE_MSI_MAPPING);
-	while (pos && ttl--) {
-		u8 flags;
-
-		if (pci_read_config_byte(dev, pos + HT_MSI_FLAGS, &flags) == 0) {
-			printk(KERN_INFO "PCI: Enabling HT MSI Mapping on %s\n",
-			       pci_name(dev));
-
-			pci_write_config_byte(dev, pos + HT_MSI_FLAGS,
-					      flags | HT_MSI_FLAGS_ENABLE);
-		}
-		pos = pci_find_next_ht_capability(dev, pos,
-						  HT_CAPTYPE_MSI_MAPPING);
-	}
-}
-DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_SERVERWORKS,
-			 PCI_DEVICE_ID_SERVERWORKS_HT1000_PXB,
-			 quirk_msi_ht_cap_enable);
-
 /* The nVidia CK804 chipset may have 2 HT MSI mappings.
 /* The nVidia CK804 chipset may have 2 HT MSI mappings.
  * MSI are supported if the MSI capability set in any of these mappings.
  * MSI are supported if the MSI capability set in any of these mappings.
  */
  */
@@ -1778,9 +1751,8 @@ static void __devinit quirk_nvidia_ck804_msi_ht_cap(struct pci_dev *dev)
 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_CK804_PCIE,
 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_CK804_PCIE,
 			quirk_nvidia_ck804_msi_ht_cap);
 			quirk_nvidia_ck804_msi_ht_cap);
 
 
-/*
- *  Force enable MSI mapping capability on HT bridges  */
-static inline void ht_enable_msi_mapping(struct pci_dev *dev)
+/* Force enable MSI mapping capability on HT bridges */
+static void __devinit ht_enable_msi_mapping(struct pci_dev *dev)
 {
 {
 	int pos, ttl = 48;
 	int pos, ttl = 48;
 
 
@@ -1799,6 +1771,9 @@ static inline void ht_enable_msi_mapping(struct pci_dev *dev)
 						  HT_CAPTYPE_MSI_MAPPING);
 						  HT_CAPTYPE_MSI_MAPPING);
 	}
 	}
 }
 }
+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_SERVERWORKS,
+			 PCI_DEVICE_ID_SERVERWORKS_HT1000_PXB,
+			 ht_enable_msi_mapping);
 
 
 static void __devinit nv_msi_ht_cap_quirk(struct pci_dev *dev)
 static void __devinit nv_msi_ht_cap_quirk(struct pci_dev *dev)
 {
 {
@@ -1830,7 +1805,7 @@ static void __devinit nv_msi_ht_cap_quirk(struct pci_dev *dev)
 
 
 		if (pci_read_config_byte(dev, pos + HT_MSI_FLAGS,
 		if (pci_read_config_byte(dev, pos + HT_MSI_FLAGS,
 					 &flags) == 0) {
 					 &flags) == 0) {
-			dev_info(&dev->dev, "Quirk disabling HT MSI mapping");
+			dev_info(&dev->dev, "Disabling HT MSI mapping");
 			pci_write_config_byte(dev, pos + HT_MSI_FLAGS,
 			pci_write_config_byte(dev, pos + HT_MSI_FLAGS,
 					      flags & ~HT_MSI_FLAGS_ENABLE);
 					      flags & ~HT_MSI_FLAGS_ENABLE);
 		}
 		}

+ 10 - 0
include/linux/pci.h

@@ -388,6 +388,16 @@ struct pci_driver {
 
 
 #define	to_pci_driver(drv) container_of(drv, struct pci_driver, driver)
 #define	to_pci_driver(drv) container_of(drv, struct pci_driver, driver)
 
 
+/**
+ * DECLARE_PCI_DEVICE_TABLE - macro used to describe a pci device table
+ * @_table: device table name
+ *
+ * This macro is used to create a struct pci_device_id array (a device table)
+ * in a generic manner.
+ */
+#define DECLARE_PCI_DEVICE_TABLE(_table) \
+	const struct pci_device_id _table[] __devinitconst
+
 /**
 /**
  * PCI_DEVICE - macro used to describe a specific pci device
  * PCI_DEVICE - macro used to describe a specific pci device
  * @vend: the 16 bit PCI Vendor ID
  * @vend: the 16 bit PCI Vendor ID