From rshah1@unix-os.sc.intel.com Thu Oct 13 13:21:00 2005 Message-Id: <20051013190821.278182580@csdlinux-2.jf.intel.com> Date: Thu, 13 Oct 2005 12:05:39 -0700 From: rajesh.shah@intel.com To: kristen.c.accardi@intel.com, gregkh@suse.de Cc: david.keck@amd.com, akpm@osdl.org, Rajesh Shah Subject: [patch 4/9] shpchp: detect SHPC capability before doing a lot of work Content-Disposition: inline; filename=shpc-04-probe-bail-early.patch The shpc driver registers its probe function for all pci-pci bridges in the system. Not all of them will be shpc capable, so look for this capability early in the probe function and return if there's no work to do on this bridge. The old shpc driver did some initialization work on all bridges before detecting that shpc is not supported and unwinds the work it's already done in that case. Signed-off-by: Rajesh Shah Signed-off-by: Greg Kroah-Hartman --- drivers/pci/hotplug/shpchp_core.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) --- gregkh-2.6.orig/drivers/pci/hotplug/shpchp_core.c +++ gregkh-2.6/drivers/pci/hotplug/shpchp_core.c @@ -351,6 +351,17 @@ static int get_cur_bus_speed (struct hot return 0; } +static int is_shpc_capable(struct pci_dev *dev) +{ + if ((dev->vendor == PCI_VENDOR_ID_AMD) || (dev->device == + PCI_DEVICE_ID_AMD_GOLAM_7450)) + return 1; + if (pci_find_capability(dev, PCI_CAP_ID_SHPC)) + return 1; + + return 0; +} + static int shpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { int rc; @@ -359,6 +370,9 @@ static int shpc_probe(struct pci_dev *pd int first_device_num; /* first PCI device number supported by this SHPC */ int num_ctlr_slots; /* number of slots supported by this SHPC */ + if (!is_shpc_capable(pdev)) + return -ENODEV; + ctrl = (struct controller *) kmalloc(sizeof(struct controller), GFP_KERNEL); if (!ctrl) { err("%s : out of memory\n", __FUNCTION__);