Skip to content

Commit

Permalink
[PATCH] PCI: Reduce nr of ptr derefs in drivers/pci/hotplug/pciehprm_…
Browse files Browse the repository at this point in the history
…acpi.c

Here's a small patch to reduce the nr. of pointer dereferences in
drivers/pci/hotplug/pciehprm_acpi.c

Benefits:
 - micro speed optimization due to fewer pointer derefs
 - generated code is slightly smaller
 - better readability

Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Jesper Juhl authored and Greg Kroah-Hartman committed Jan 9, 2006
1 parent f5c99df commit c2dea65
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions drivers/pci/hotplug/pciehprm_acpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,9 @@ int pciehp_get_hp_hw_control_from_firmware(struct pci_dev *dev)
acpi_status status;
acpi_handle chandle, handle = DEVICE_ACPI_HANDLE(&(dev->dev));
struct pci_dev *pdev = dev;
struct pci_bus *parent;
u8 *path_name;

/*
* Per PCI firmware specification, we should run the ACPI _OSC
* method to get control of hotplug hardware before using it.
Expand All @@ -190,17 +192,18 @@ int pciehp_get_hp_hw_control_from_firmware(struct pci_dev *dev)
*/
if (!pdev || !pdev->bus->parent)
break;
parent = pdev->bus->parent;
dbg("Could not find %s in acpi namespace, trying parent\n",
pci_name(pdev));
if (!pdev->bus->parent->self)
if (!parent->self)
/* Parent must be a host bridge */
handle = acpi_get_pci_rootbridge_handle(
pci_domain_nr(pdev->bus->parent),
pdev->bus->parent->number);
pci_domain_nr(parent),
parent->number);
else
handle = DEVICE_ACPI_HANDLE(
&(pdev->bus->parent->self->dev));
pdev = pdev->bus->parent->self;
&(parent->self->dev));
pdev = parent->self;
}

while (handle) {
Expand Down

0 comments on commit c2dea65

Please sign in to comment.