summaryrefslogtreecommitdiffstats
path: root/drivers/pci
diff options
context:
space:
mode:
authorBjorn Helgaas <bhelgaas@google.com>2012-09-10 16:31:08 -0600
committerBjorn Helgaas <bhelgaas@google.com>2012-09-10 16:31:08 -0600
commit2c1f56acb2ddf3aa273b14ebd48d61b930777e52 (patch)
treee6f987756470014a0df9253bb220aebeb117d1f4 /drivers/pci
parentbe017b255eca3db94f6f62f20d05abc6bffab7ee (diff)
parente9bf1040f649d89db3c2e060d1b0b56665a4fb93 (diff)
downloadblackbird-op-linux-2c1f56acb2ddf3aa273b14ebd48d61b930777e52.tar.gz
blackbird-op-linux-2c1f56acb2ddf3aa273b14ebd48d61b930777e52.zip
Merge branch 'pci/feng-avoid-kmalloc' into next
* pci/feng-avoid-kmalloc: PCI: Remove the obsolete no_pci_devices() check PCI: Use pci_device_id on stack for pci_get_subsys/class() to avoid kmalloc
Diffstat (limited to 'drivers/pci')
-rw-r--r--drivers/pci/search.c55
1 files changed, 18 insertions, 37 deletions
diff --git a/drivers/pci/search.c b/drivers/pci/search.c
index d84cdcfaacf3..bf969ba58e59 100644
--- a/drivers/pci/search.c
+++ b/drivers/pci/search.c
@@ -243,30 +243,14 @@ struct pci_dev *pci_get_subsys(unsigned int vendor, unsigned int device,
unsigned int ss_vendor, unsigned int ss_device,
struct pci_dev *from)
{
- struct pci_dev *pdev;
- struct pci_device_id *id;
-
- /*
- * pci_find_subsys() can be called on the ide_setup() path,
- * super-early in boot. But the down_read() will enable local
- * interrupts, which can cause some machines to crash. So here we
- * detect and flag that situation and bail out early.
- */
- if (unlikely(no_pci_devices()))
- return NULL;
-
- id = kzalloc(sizeof(*id), GFP_KERNEL);
- if (!id)
- return NULL;
- id->vendor = vendor;
- id->device = device;
- id->subvendor = ss_vendor;
- id->subdevice = ss_device;
-
- pdev = pci_get_dev_by_id(id, from);
- kfree(id);
-
- return pdev;
+ struct pci_device_id id = {
+ .vendor = vendor,
+ .device = device,
+ .subvendor = ss_vendor,
+ .subdevice = ss_device,
+ };
+
+ return pci_get_dev_by_id(&id, from);
}
/**
@@ -305,19 +289,16 @@ pci_get_device(unsigned int vendor, unsigned int device, struct pci_dev *from)
*/
struct pci_dev *pci_get_class(unsigned int class, struct pci_dev *from)
{
- struct pci_dev *dev;
- struct pci_device_id *id;
-
- id = kzalloc(sizeof(*id), GFP_KERNEL);
- if (!id)
- return NULL;
- id->vendor = id->device = id->subvendor = id->subdevice = PCI_ANY_ID;
- id->class_mask = PCI_ANY_ID;
- id->class = class;
-
- dev = pci_get_dev_by_id(id, from);
- kfree(id);
- return dev;
+ struct pci_device_id id = {
+ .vendor = PCI_ANY_ID,
+ .device = PCI_ANY_ID,
+ .subvendor = PCI_ANY_ID,
+ .subdevice = PCI_ANY_ID,
+ .class_mask = PCI_ANY_ID,
+ .class = class,
+ };
+
+ return pci_get_dev_by_id(&id, from);
}
/**
OpenPOWER on IntegriCloud