diff options
author | Greg Kroah-Hartman <gregkh@suse.de> | 2005-12-13 12:04:03 -0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2005-12-13 12:04:03 -0800 |
commit | 1d73f8fce5c1442af64cb5de4056420a2728f396 (patch) | |
tree | 6cafd2711c2bfa5a6b23ec075887bdd310284a4d /pci | |
parent | eff9e116197faa36249e2d68a76342cd380288b1 (diff) | |
download | patches-1d73f8fce5c1442af64cb5de4056420a2728f396.tar.gz |
pci and driver core patches
Diffstat (limited to 'pci')
6 files changed, 580 insertions, 0 deletions
diff --git a/pci/pci-document-sysfs-rom-file-interface.patch b/pci/pci-document-sysfs-rom-file-interface.patch new file mode 100644 index 0000000000000..f9b8ca75476c0 --- /dev/null +++ b/pci/pci-document-sysfs-rom-file-interface.patch @@ -0,0 +1,65 @@ +From jesse.barnes@intel.com Fri Dec 9 14:06:51 2005 +From: Jesse Barnes <jesse.barnes@intel.com> +To: gregkh@suse.de, linux-kernel@vger.kernel.org, Ian Romanick <idr@us.ibm.com> +Subject: PCI: document sysfs rom file interface +Date: Fri, 9 Dec 2005 11:55:03 -0800 +Message-Id: <200512091155.03552.jesse.barnes@intel.com> + +idr gently pointed out today that not only is the sysfs rom file +interface somewhat unintuitive (despite my efforts and initial +implementation), but it's also undocumented! This patch to +Documentation/filesystems/sysfs-pci.txt corrects the latter problem; the +former is a userland ABI now though, so we're stuck with it for awhile +at least. + +Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org> +Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> + +--- + Documentation/filesystems/sysfs-pci.txt | 21 +++++++++++++++------ + 1 file changed, 15 insertions(+), 6 deletions(-) + +--- gregkh-2.6.orig/Documentation/filesystems/sysfs-pci.txt ++++ gregkh-2.6/Documentation/filesystems/sysfs-pci.txt +@@ -1,4 +1,5 @@ + Accessing PCI device resources through sysfs ++-------------------------------------------- + + sysfs, usually mounted at /sys, provides access to PCI resources on platforms + that support it. For example, a given bus might look like this: +@@ -47,14 +48,21 @@ files, each with their own function. + binary - file contains binary data + cpumask - file contains a cpumask type + +-The read only files are informational, writes to them will be ignored. +-Writable files can be used to perform actions on the device (e.g. changing +-config space, detaching a device). mmapable files are available via an +-mmap of the file at offset 0 and can be used to do actual device programming +-from userspace. Note that some platforms don't support mmapping of certain +-resources, so be sure to check the return value from any attempted mmap. ++The read only files are informational, writes to them will be ignored, with ++the exception of the 'rom' file. Writable files can be used to perform ++actions on the device (e.g. changing config space, detaching a device). ++mmapable files are available via an mmap of the file at offset 0 and can be ++used to do actual device programming from userspace. Note that some platforms ++don't support mmapping of certain resources, so be sure to check the return ++value from any attempted mmap. ++ ++The 'rom' file is special in that it provides read-only access to the device's ++ROM file, if available. It's disabled by default, however, so applications ++should write the string "1" to the file to enable it before attempting a read ++call, and disable it following the access by writing "0" to the file. + + Accessing legacy resources through sysfs ++---------------------------------------- + + Legacy I/O port and ISA memory resources are also provided in sysfs if the + underlying platform supports them. They're located in the PCI class heirarchy, +@@ -75,6 +83,7 @@ simply dereference the returned pointer + to access legacy memory space. + + Supporting PCI access on new platforms ++-------------------------------------- + + In order to support PCI resource mapping as described above, Linux platform + code must define HAVE_PCI_MMAP and provide a pci_mmap_page_range function. diff --git a/pci/pci-express-must-be-initialized-before-pci-hotplug.patch b/pci/pci-express-must-be-initialized-before-pci-hotplug.patch new file mode 100644 index 0000000000000..62bfb629d7f01 --- /dev/null +++ b/pci/pci-express-must-be-initialized-before-pci-hotplug.patch @@ -0,0 +1,44 @@ +From owner-linux-pci@atrey.karlin.mff.cuni.cz Sun Dec 11 16:15:28 2005 +Date: Mon, 12 Dec 2005 11:12:01 +1100 +From: Anton Blanchard <anton@samba.org> +To: Greg Kroah-Hartman <gregkh@suse.de> +Cc: <miltonm@bga.com>, <rajesh.shah@intel.com> +Subject: PCI express must be initialized before PCI hotplug +Message-ID: <20051212001201.GF23641@krispykreme> +Content-Disposition: inline + + +From: Milton Miller <miltonm@bga.com> + +PCI express hotplug uses the pcieportbus driver so pcie must be +initialized before hotplug/. This patch changes the link order. + +Signed-Off-By: Milton Miller <miltonm@bga.com> +Acked-by: Anton Blanchard <anton@samba.org> +Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> + + +--- + drivers/pci/Makefile | 7 +++---- + 1 file changed, 3 insertions(+), 4 deletions(-) + +--- gregkh-2.6.orig/drivers/pci/Makefile ++++ gregkh-2.6/drivers/pci/Makefile +@@ -6,6 +6,9 @@ obj-y += access.o bus.o probe.o remove. + pci-driver.o search.o pci-sysfs.o rom.o setup-res.o + obj-$(CONFIG_PROC_FS) += proc.o + ++# Build PCI Express stuff if needed ++obj-$(CONFIG_PCIEPORTBUS) += pcie/ ++ + obj-$(CONFIG_HOTPLUG) += hotplug.o + + # Build the PCI Hotplug drivers if we were asked to +@@ -40,7 +43,3 @@ endif + ifeq ($(CONFIG_PCI_DEBUG),y) + EXTRA_CFLAGS += -DDEBUG + endif +- +-# Build PCI Express stuff if needed +-obj-$(CONFIG_PCIEPORTBUS) += pcie/ +- diff --git a/pci/reduce-nr-of-ptr-derefs-in-drivers-pci-hotplug-cpqphp_core.c.patch b/pci/reduce-nr-of-ptr-derefs-in-drivers-pci-hotplug-cpqphp_core.c.patch new file mode 100644 index 0000000000000..92fb684903e86 --- /dev/null +++ b/pci/reduce-nr-of-ptr-derefs-in-drivers-pci-hotplug-cpqphp_core.c.patch @@ -0,0 +1,210 @@ +From jesper.juhl@gmail.com Sat Dec 10 21:43:02 2005 +From: Jesper Juhl <jesper.juhl@gmail.com> +Subject: [PATCH] Reduce nr of ptr derefs in drivers/pci/hotplug/cpqphp_core.c +Date: Sun, 11 Dec 2005 06:42:18 +0100 +Cc: Torben Mathiasen <torben.mathiasen@hp.com>, greg@kroah.com, Andrew Morton <akpm@osdl.org>, Jesper Juhl <jesper.juhl@gmail.com> +Content-Disposition: inline +Message-Id: <200512110642.18473.jesper.juhl@gmail.com> + +Here's a small patch to reduce the nr of pointer dereferences in +drivers/pci/hotplug/cpqphp_core.c + +Benefits of this patch: + - micro speed optimization due to fewer pointer derefs + - generated code is slightly smaller + - tiny line length and whitespace cleanup + - better readability + +Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com> +Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> +--- + drivers/pci/hotplug/cpqphp_core.c | 121 +++++++++++++++++++++----------------- + 1 file changed, 67 insertions(+), 54 deletions(-) + +--- gregkh-2.6.orig/drivers/pci/hotplug/cpqphp_core.c ++++ gregkh-2.6/drivers/pci/hotplug/cpqphp_core.c +@@ -327,7 +327,9 @@ static int ctrl_slot_setup(struct contro + void __iomem *smbios_start, + void __iomem *smbios_table) + { +- struct slot *new_slot; ++ struct slot *slot; ++ struct hotplug_slot *hotplug_slot; ++ struct hotplug_slot_info *hotplug_slot_info; + u8 number_of_slots; + u8 slot_device; + u8 slot_number; +@@ -345,93 +347,105 @@ static int ctrl_slot_setup(struct contro + slot_number = ctrl->first_slot; + + while (number_of_slots) { +- new_slot = kmalloc(sizeof(*new_slot), GFP_KERNEL); +- if (!new_slot) ++ slot = kmalloc(sizeof(*slot), GFP_KERNEL); ++ if (!slot) + goto error; + +- memset(new_slot, 0, sizeof(struct slot)); +- new_slot->hotplug_slot = kmalloc(sizeof(*(new_slot->hotplug_slot)), ++ memset(slot, 0, sizeof(struct slot)); ++ slot->hotplug_slot = kmalloc(sizeof(*(slot->hotplug_slot)), + GFP_KERNEL); +- if (!new_slot->hotplug_slot) ++ if (!slot->hotplug_slot) + goto error_slot; +- memset(new_slot->hotplug_slot, 0, sizeof(struct hotplug_slot)); ++ hotplug_slot = slot->hotplug_slot; ++ memset(hotplug_slot, 0, sizeof(struct hotplug_slot)); + +- new_slot->hotplug_slot->info = +- kmalloc(sizeof(*(new_slot->hotplug_slot->info)), ++ hotplug_slot->info = ++ kmalloc(sizeof(*(hotplug_slot->info)), + GFP_KERNEL); +- if (!new_slot->hotplug_slot->info) ++ if (!hotplug_slot->info) + goto error_hpslot; +- memset(new_slot->hotplug_slot->info, 0, ++ hotplug_slot_info = hotplug_slot->info; ++ memset(hotplug_slot_info, 0, + sizeof(struct hotplug_slot_info)); +- new_slot->hotplug_slot->name = kmalloc(SLOT_NAME_SIZE, GFP_KERNEL); +- if (!new_slot->hotplug_slot->name) ++ hotplug_slot->name = kmalloc(SLOT_NAME_SIZE, GFP_KERNEL); ++ ++ if (!hotplug_slot->name) + goto error_info; + +- new_slot->ctrl = ctrl; +- new_slot->bus = ctrl->bus; +- new_slot->device = slot_device; +- new_slot->number = slot_number; +- dbg("slot->number = %d\n",new_slot->number); ++ slot->ctrl = ctrl; ++ slot->bus = ctrl->bus; ++ slot->device = slot_device; ++ slot->number = slot_number; ++ dbg("slot->number = %d\n", slot->number); + + slot_entry = get_SMBIOS_entry(smbios_start, smbios_table, 9, + slot_entry); + +- while (slot_entry && (readw(slot_entry + SMBIOS_SLOT_NUMBER) != new_slot->number)) { ++ while (slot_entry && (readw(slot_entry + SMBIOS_SLOT_NUMBER) != ++ slot->number)) { + slot_entry = get_SMBIOS_entry(smbios_start, + smbios_table, 9, slot_entry); + } + +- new_slot->p_sm_slot = slot_entry; ++ slot->p_sm_slot = slot_entry; + +- init_timer(&new_slot->task_event); +- new_slot->task_event.expires = jiffies + 5 * HZ; +- new_slot->task_event.function = cpqhp_pushbutton_thread; ++ init_timer(&slot->task_event); ++ slot->task_event.expires = jiffies + 5 * HZ; ++ slot->task_event.function = cpqhp_pushbutton_thread; + + //FIXME: these capabilities aren't used but if they are + // they need to be correctly implemented +- new_slot->capabilities |= PCISLOT_REPLACE_SUPPORTED; +- new_slot->capabilities |= PCISLOT_INTERLOCK_SUPPORTED; ++ slot->capabilities |= PCISLOT_REPLACE_SUPPORTED; ++ slot->capabilities |= PCISLOT_INTERLOCK_SUPPORTED; + +- if (is_slot64bit(new_slot)) +- new_slot->capabilities |= PCISLOT_64_BIT_SUPPORTED; +- if (is_slot66mhz(new_slot)) +- new_slot->capabilities |= PCISLOT_66_MHZ_SUPPORTED; ++ if (is_slot64bit(slot)) ++ slot->capabilities |= PCISLOT_64_BIT_SUPPORTED; ++ if (is_slot66mhz(slot)) ++ slot->capabilities |= PCISLOT_66_MHZ_SUPPORTED; + if (ctrl->speed == PCI_SPEED_66MHz) +- new_slot->capabilities |= PCISLOT_66_MHZ_OPERATION; ++ slot->capabilities |= PCISLOT_66_MHZ_OPERATION; + +- ctrl_slot = slot_device - (readb(ctrl->hpc_reg + SLOT_MASK) >> 4); ++ ctrl_slot = ++ slot_device - (readb(ctrl->hpc_reg + SLOT_MASK) >> 4); + + // Check presence +- new_slot->capabilities |= ((((~tempdword) >> 23) | ((~tempdword) >> 15)) >> ctrl_slot) & 0x02; ++ slot->capabilities |= ++ ((((~tempdword) >> 23) | ++ ((~tempdword) >> 15)) >> ctrl_slot) & 0x02; + // Check the switch state +- new_slot->capabilities |= ((~tempdword & 0xFF) >> ctrl_slot) & 0x01; ++ slot->capabilities |= ++ ((~tempdword & 0xFF) >> ctrl_slot) & 0x01; + // Check the slot enable +- new_slot->capabilities |= ((read_slot_enable(ctrl) << 2) >> ctrl_slot) & 0x04; ++ slot->capabilities |= ++ ((read_slot_enable(ctrl) << 2) >> ctrl_slot) & 0x04; + + /* register this slot with the hotplug pci core */ +- new_slot->hotplug_slot->release = &release_slot; +- new_slot->hotplug_slot->private = new_slot; +- make_slot_name(new_slot->hotplug_slot->name, SLOT_NAME_SIZE, new_slot); +- new_slot->hotplug_slot->ops = &cpqphp_hotplug_slot_ops; ++ hotplug_slot->release = &release_slot; ++ hotplug_slot->private = slot; ++ make_slot_name(hotplug_slot->name, SLOT_NAME_SIZE, slot); ++ hotplug_slot->ops = &cpqphp_hotplug_slot_ops; + +- new_slot->hotplug_slot->info->power_status = get_slot_enabled(ctrl, new_slot); +- new_slot->hotplug_slot->info->attention_status = cpq_get_attention_status(ctrl, new_slot); +- new_slot->hotplug_slot->info->latch_status = cpq_get_latch_status(ctrl, new_slot); +- new_slot->hotplug_slot->info->adapter_status = get_presence_status(ctrl, new_slot); ++ hotplug_slot_info->power_status = get_slot_enabled(ctrl, slot); ++ hotplug_slot_info->attention_status = ++ cpq_get_attention_status(ctrl, slot); ++ hotplug_slot_info->latch_status = ++ cpq_get_latch_status(ctrl, slot); ++ hotplug_slot_info->adapter_status = ++ get_presence_status(ctrl, slot); + +- dbg ("registering bus %d, dev %d, number %d, " ++ dbg("registering bus %d, dev %d, number %d, " + "ctrl->slot_device_offset %d, slot %d\n", +- new_slot->bus, new_slot->device, +- new_slot->number, ctrl->slot_device_offset, ++ slot->bus, slot->device, ++ slot->number, ctrl->slot_device_offset, + slot_number); +- result = pci_hp_register (new_slot->hotplug_slot); ++ result = pci_hp_register(hotplug_slot); + if (result) { +- err ("pci_hp_register failed with error %d\n", result); ++ err("pci_hp_register failed with error %d\n", result); + goto error_name; + } + +- new_slot->next = ctrl->slot; +- ctrl->slot = new_slot; ++ slot->next = ctrl->slot; ++ ctrl->slot = slot; + + number_of_slots--; + slot_device++; +@@ -439,15 +453,14 @@ static int ctrl_slot_setup(struct contro + } + + return 0; +- + error_name: +- kfree(new_slot->hotplug_slot->name); ++ kfree(hotplug_slot->name); + error_info: +- kfree(new_slot->hotplug_slot->info); ++ kfree(hotplug_slot_info); + error_hpslot: +- kfree(new_slot->hotplug_slot); ++ kfree(hotplug_slot); + error_slot: +- kfree(new_slot); ++ kfree(slot); + error: + return result; + } diff --git a/pci/reduce-nr-of-ptr-derefs-in-drivers-pci-hotplug-pciehp_core.c.patch b/pci/reduce-nr-of-ptr-derefs-in-drivers-pci-hotplug-pciehp_core.c.patch new file mode 100644 index 0000000000000..38064bd20e3e1 --- /dev/null +++ b/pci/reduce-nr-of-ptr-derefs-in-drivers-pci-hotplug-pciehp_core.c.patch @@ -0,0 +1,157 @@ +From jesper.juhl@gmail.com Sat Dec 10 21:48:55 2005 +From: Jesper Juhl <jesper.juhl@gmail.com> +Subject: [PATCH] Reduce nr of ptr derefs in drivers/pci/hotplug/pciehp_core.c +Date: Sun, 11 Dec 2005 06:41:42 +0100 +Cc: greg@kroah.com, <kristen.c.accardi@intel.com>, Andrew Morton <akpm@osdl.org>, Jesper Juhl <jesper.juhl@gmail.com> +Content-Disposition: inline +Message-Id: <200512110641.42992.jesper.juhl@gmail.com> + +Here's a small patch to reduce the nr. of pointer dereferences in +drivers/pci/hotplug/pciehp_core.c + +Benefits: + - micro speed optimization due to fewer pointer derefs + - generated code is slightly smaller + - small line length cleanup + - better readability + +Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com> +Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> +--- + drivers/pci/hotplug/pciehp_core.c | 90 +++++++++++++++++++++----------------- + 1 file changed, 50 insertions(+), 40 deletions(-) + +--- gregkh-2.6.orig/drivers/pci/hotplug/pciehp_core.c ++++ gregkh-2.6/drivers/pci/hotplug/pciehp_core.c +@@ -103,7 +103,10 @@ static void release_slot(struct hotplug_ + + static int init_slots(struct controller *ctrl) + { +- struct slot *new_slot; ++ struct slot *slot; ++ struct hpc_ops *hpc_ops; ++ struct hotplug_slot *hotplug_slot; ++ struct hotplug_slot_info *hotplug_slot_info; + u8 number_of_slots; + u8 slot_device; + u32 slot_number; +@@ -114,59 +117,66 @@ static int init_slots(struct controller + slot_number = ctrl->first_slot; + + while (number_of_slots) { +- new_slot = kmalloc(sizeof(*new_slot), GFP_KERNEL); +- if (!new_slot) ++ slot = kmalloc(sizeof(*slot), GFP_KERNEL); ++ if (!slot) + goto error; + +- memset(new_slot, 0, sizeof(struct slot)); +- new_slot->hotplug_slot = +- kmalloc(sizeof(*(new_slot->hotplug_slot)), ++ memset(slot, 0, sizeof(struct slot)); ++ slot->hotplug_slot = ++ kmalloc(sizeof(*(slot->hotplug_slot)), + GFP_KERNEL); +- if (!new_slot->hotplug_slot) ++ if (!slot->hotplug_slot) + goto error_slot; +- memset(new_slot->hotplug_slot, 0, sizeof(struct hotplug_slot)); ++ hotplug_slot = slot->hotplug_slot; ++ memset(hotplug_slot, 0, sizeof(struct hotplug_slot)); + +- new_slot->hotplug_slot->info = +- kmalloc(sizeof(*(new_slot->hotplug_slot->info)), ++ hotplug_slot->info = ++ kmalloc(sizeof(*(hotplug_slot->info)), + GFP_KERNEL); +- if (!new_slot->hotplug_slot->info) ++ if (!hotplug_slot->info) + goto error_hpslot; +- memset(new_slot->hotplug_slot->info, 0, ++ hotplug_slot_info = hotplug_slot->info; ++ memset(hotplug_slot_info, 0, + sizeof(struct hotplug_slot_info)); +- new_slot->hotplug_slot->name = kmalloc(SLOT_NAME_SIZE, +- GFP_KERNEL); +- if (!new_slot->hotplug_slot->name) ++ hotplug_slot->name = kmalloc(SLOT_NAME_SIZE, GFP_KERNEL); ++ if (!hotplug_slot->name) + goto error_info; + +- new_slot->ctrl = ctrl; +- new_slot->bus = ctrl->slot_bus; +- new_slot->device = slot_device; +- new_slot->hpc_ops = ctrl->hpc_ops; ++ slot->ctrl = ctrl; ++ slot->bus = ctrl->slot_bus; ++ slot->device = slot_device; ++ slot->hpc_ops = hpc_ops = ctrl->hpc_ops; + +- new_slot->number = ctrl->first_slot; +- new_slot->hp_slot = slot_device - ctrl->slot_device_offset; ++ slot->number = ctrl->first_slot; ++ slot->hp_slot = slot_device - ctrl->slot_device_offset; + + /* register this slot with the hotplug pci core */ +- new_slot->hotplug_slot->private = new_slot; +- new_slot->hotplug_slot->release = &release_slot; +- make_slot_name(new_slot->hotplug_slot->name, SLOT_NAME_SIZE, new_slot); +- new_slot->hotplug_slot->ops = &pciehp_hotplug_slot_ops; +- +- new_slot->hpc_ops->get_power_status(new_slot, &(new_slot->hotplug_slot->info->power_status)); +- new_slot->hpc_ops->get_attention_status(new_slot, &(new_slot->hotplug_slot->info->attention_status)); +- new_slot->hpc_ops->get_latch_status(new_slot, &(new_slot->hotplug_slot->info->latch_status)); +- new_slot->hpc_ops->get_adapter_status(new_slot, &(new_slot->hotplug_slot->info->adapter_status)); +- +- dbg("Registering bus=%x dev=%x hp_slot=%x sun=%x slot_device_offset=%x\n", +- new_slot->bus, new_slot->device, new_slot->hp_slot, new_slot->number, ctrl->slot_device_offset); +- result = pci_hp_register (new_slot->hotplug_slot); ++ hotplug_slot->private = slot; ++ hotplug_slot->release = &release_slot; ++ make_slot_name(hotplug_slot->name, SLOT_NAME_SIZE, slot); ++ hotplug_slot->ops = &pciehp_hotplug_slot_ops; ++ ++ hpc_ops->get_power_status(slot, ++ &(hotplug_slot_info->power_status)); ++ hpc_ops->get_attention_status(slot, ++ &(hotplug_slot_info->attention_status)); ++ hpc_ops->get_latch_status(slot, ++ &(hotplug_slot_info->latch_status)); ++ hpc_ops->get_adapter_status(slot, ++ &(hotplug_slot_info->adapter_status)); ++ ++ dbg("Registering bus=%x dev=%x hp_slot=%x sun=%x " ++ "slot_device_offset=%x\n", ++ slot->bus, slot->device, slot->hp_slot, slot->number, ++ ctrl->slot_device_offset); ++ result = pci_hp_register(hotplug_slot); + if (result) { + err ("pci_hp_register failed with error %d\n", result); + goto error_name; + } + +- new_slot->next = ctrl->slot; +- ctrl->slot = new_slot; ++ slot->next = ctrl->slot; ++ ctrl->slot = slot; + + number_of_slots--; + slot_device++; +@@ -176,13 +186,13 @@ static int init_slots(struct controller + return 0; + + error_name: +- kfree(new_slot->hotplug_slot->name); ++ kfree(hotplug_slot->name); + error_info: +- kfree(new_slot->hotplug_slot->info); ++ kfree(hotplug_slot_info); + error_hpslot: +- kfree(new_slot->hotplug_slot); ++ kfree(hotplug_slot); + error_slot: +- kfree(new_slot); ++ kfree(slot); + error: + return result; + } diff --git a/pci/reduce-nr-of-ptr-derefs-in-drivers-pci-hotplug-pciehprm_acpi.c.patch b/pci/reduce-nr-of-ptr-derefs-in-drivers-pci-hotplug-pciehprm_acpi.c.patch new file mode 100644 index 0000000000000..d6e08e4603796 --- /dev/null +++ b/pci/reduce-nr-of-ptr-derefs-in-drivers-pci-hotplug-pciehprm_acpi.c.patch @@ -0,0 +1,58 @@ +From jesper.juhl@gmail.com Sat Dec 10 21:43:24 2005 +From: Jesper Juhl <jesper.juhl@gmail.com> +Subject: [PATCH] Reduce nr of ptr derefs in drivers/pci/hotplug/pciehprm_acpi.c +Date: Sun, 11 Dec 2005 06:43:09 +0100 +Cc: <kristen.c.accardi@intel.com>, Andrew Morton <akpm@osdl.org>, Jesper Juhl <jesper.juhl@gmail.com>, greg@kroah.com +Content-Disposition: inline +Message-Id: <200512110643.10020.jesper.juhl@gmail.com> + +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> +--- + drivers/pci/hotplug/pciehprm_acpi.c | 13 ++++++++----- + 1 file changed, 8 insertions(+), 5 deletions(-) + +--- gregkh-2.6.orig/drivers/pci/hotplug/pciehprm_acpi.c ++++ gregkh-2.6/drivers/pci/hotplug/pciehprm_acpi.c +@@ -174,7 +174,9 @@ int pciehp_get_hp_hw_control_from_firmwa + 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. +@@ -190,17 +192,18 @@ int pciehp_get_hp_hw_control_from_firmwa + */ + 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) { diff --git a/pci/reduce-nr-of-ptr-derefs-in-drivers-pci-hotplug-rpaphp_pci.c.patch b/pci/reduce-nr-of-ptr-derefs-in-drivers-pci-hotplug-rpaphp_pci.c.patch new file mode 100644 index 0000000000000..3b232494cf04b --- /dev/null +++ b/pci/reduce-nr-of-ptr-derefs-in-drivers-pci-hotplug-rpaphp_pci.c.patch @@ -0,0 +1,46 @@ +From jesper.juhl@gmail.com Sat Dec 10 21:43:18 2005 +From: Jesper Juhl <jesper.juhl@gmail.com> +Subject: [PATCH] Reduce nr of ptr derefs in drivers/pci/hotplug/rpaphp_pci.c +Date: Sun, 11 Dec 2005 06:42:38 +0100 +Cc: <lxie@us.ibm.com>, Andrew Morton <akpm@osdl.org>, Jesper Juhl <jesper.juhl@gmail.com>, greg@kroah.com +Content-Disposition: inline +Message-Id: <200512110642.38672.jesper.juhl@gmail.com> + +Here's a small patch to reduce the nr. of pointer dereferences in +drivers/pci/hotplug/rpaphp_pci.c + +Benefits: + - micro speed optimization due to fewer pointer derefs + - generated code should be slightly smaller + - better readability + +note: due to lack of both hardware and cross-compile tools this patch is, + unfortunately, completely untested. + +Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com> +Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> +--- + drivers/pci/hotplug/rpaphp_pci.c | 9 +++++---- + 1 file changed, 5 insertions(+), 4 deletions(-) + +--- gregkh-2.6.orig/drivers/pci/hotplug/rpaphp_pci.c ++++ gregkh-2.6/drivers/pci/hotplug/rpaphp_pci.c +@@ -336,13 +336,14 @@ EXPORT_SYMBOL_GPL(rpaphp_unconfig_pci_ad + + static int setup_pci_hotplug_slot_info(struct slot *slot) + { ++ struct hotplug_slot_info *hotplug_slot_info = slot->hotplug_slot->info; ++ + dbg("%s Initilize the PCI slot's hotplug->info structure ...\n", + __FUNCTION__); +- rpaphp_get_power_status(slot, &slot->hotplug_slot->info->power_status); ++ rpaphp_get_power_status(slot, &hotplug_slot_info->power_status); + rpaphp_get_pci_adapter_status(slot, 1, +- &slot->hotplug_slot->info-> +- adapter_status); +- if (slot->hotplug_slot->info->adapter_status == NOT_VALID) { ++ &hotplug_slot_info->adapter_status); ++ if (hotplug_slot_info->adapter_status == NOT_VALID) { + err("%s: NOT_VALID: skip dn->full_name=%s\n", + __FUNCTION__, slot->dn->full_name); + return -EINVAL; |