From: Bjorn Helgaas <bjorn.helgaas@hp.com>
To: Len Brown <lenb@kernel.org>
Cc: linux-acpi@vger.kernel.org
Subject: [PATCH 03/20] ACPI: PCI: simplify buffer management for evaluating _PRT
Date: Mon, 08 Dec 2008 21:30:15 -0700 [thread overview]
Message-ID: <20081209043015.26415.63813.stgit@bob.kio> (raw)
In-Reply-To: <20081209042833.26415.24906.stgit@bob.kio>
Previously, acpi_pci_irq_add_prt() did all its own buffer management.
But now that we have ACPI_ALLOCATE_BUFFER, we no longer need to do
that management. And we don't have to call acpi_get_irq_routing_table()
twice (once to learn the size of the buffer needed, and again to
actually get the table).
Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
---
drivers/acpi/pci_irq.c | 52 +++++++++++-------------------------------------
1 files changed, 12 insertions(+), 40 deletions(-)
diff --git a/drivers/acpi/pci_irq.c b/drivers/acpi/pci_irq.c
index 8250c55..0a31527 100644
--- a/drivers/acpi/pci_irq.c
+++ b/drivers/acpi/pci_irq.c
@@ -245,55 +245,29 @@ acpi_pci_irq_del_entry(int segment, int bus, struct acpi_prt_entry *entry)
int acpi_pci_irq_add_prt(acpi_handle handle, int segment, int bus)
{
- acpi_status status = AE_OK;
- char *pathname = NULL;
- struct acpi_buffer buffer = { 0, NULL };
- struct acpi_pci_routing_table *prt = NULL;
- struct acpi_pci_routing_table *entry = NULL;
+ acpi_status status;
+ struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
+ struct acpi_pci_routing_table *entry;
static int first_time = 1;
-
- pathname = kzalloc(ACPI_PATHNAME_MAX, GFP_KERNEL);
- if (!pathname)
- return -ENOMEM;
-
if (first_time) {
acpi_prt.count = 0;
INIT_LIST_HEAD(&acpi_prt.entries);
first_time = 0;
}
- /*
- * NOTE: We're given a 'handle' to the _PRT object's parent device
- * (either a PCI root bridge or PCI-PCI bridge).
- */
-
- buffer.length = ACPI_PATHNAME_MAX;
- buffer.pointer = pathname;
- acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer);
+ /* 'handle' is the _PRT's parent (root bridge or PCI-PCI bridge) */
+ status = acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer);
+ if (ACPI_FAILURE(status))
+ return -ENODEV;
printk(KERN_DEBUG "ACPI: PCI Interrupt Routing Table [%s._PRT]\n",
- pathname);
+ (char *) buffer.pointer);
- /*
- * Evaluate this _PRT and add its entries to our global list (acpi_prt).
- */
+ kfree(buffer.pointer);
- buffer.length = 0;
+ buffer.length = ACPI_ALLOCATE_BUFFER;
buffer.pointer = NULL;
- kfree(pathname);
- status = acpi_get_irq_routing_table(handle, &buffer);
- if (status != AE_BUFFER_OVERFLOW) {
- ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PRT [%s]",
- acpi_format_exception(status)));
- return -ENODEV;
- }
-
- prt = kzalloc(buffer.length, GFP_KERNEL);
- if (!prt) {
- return -ENOMEM;
- }
- buffer.pointer = prt;
status = acpi_get_irq_routing_table(handle, &buffer);
if (ACPI_FAILURE(status)) {
@@ -303,16 +277,14 @@ int acpi_pci_irq_add_prt(acpi_handle handle, int segment, int bus)
return -ENODEV;
}
- entry = prt;
-
+ entry = buffer.pointer;
while (entry && (entry->length > 0)) {
acpi_pci_irq_add_entry(handle, segment, bus, entry);
entry = (struct acpi_pci_routing_table *)
((unsigned long)entry + entry->length);
}
- kfree(prt);
-
+ kfree(buffer.pointer);
return 0;
}
next prev parent reply other threads:[~2008-12-09 4:30 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-09 4:30 [PATCH 00/20] ACPI: PCI: simplify _PRT handling Bjorn Helgaas
2008-12-09 4:30 ` [PATCH 01/20] ACPI: PCI: use conventional PCI address format Bjorn Helgaas
2008-12-09 4:30 ` [PATCH 02/20] ACPI: PCI: remove unnecessary null pointer checks Bjorn Helgaas
2008-12-09 4:30 ` Bjorn Helgaas [this message]
2008-12-31 4:15 ` [PATCH] ACPI: simplify buffer management for acpi_pci_bind() etc Len Brown
2008-12-09 4:30 ` [PATCH 04/20] ACPI: PCI: ignore _PRT function information Bjorn Helgaas
2008-12-09 4:30 ` [PATCH 05/20] ACPI: PCI: fix GSI/IRQ naming confusion Bjorn Helgaas
2008-12-09 4:30 ` [PATCH 06/20] ACPI: PCI: move struct acpi_prt_entry declaration out of public header file Bjorn Helgaas
2008-12-09 4:30 ` [PATCH 07/20] ACPI: PCI: add a helper to convert _PRT INTx pin number to name Bjorn Helgaas
2008-12-09 4:30 ` [PATCH 08/20] ACPI: PCI: always use the PCI INTx pin values, not the _PRT ones Bjorn Helgaas
2008-12-09 4:30 ` [PATCH 09/20] ACPI: PCI: use 1-based encoding for _PRT quirks Bjorn Helgaas
2008-12-09 4:30 ` [PATCH 10/20] ACPI: PCI: lookup _PRT entry by PCI dev and pin, not segment/bus/dev/pin Bjorn Helgaas
2008-12-09 4:30 ` [PATCH 11/20] ACPI: PCI: tweak _PRT lookup debug Bjorn Helgaas
2008-12-09 4:31 ` [PATCH 12/20] ACPI: PCI: remove callback from acpi_pci_irq_lookup & acpi_pci_irq_derive Bjorn Helgaas
2008-12-09 4:31 ` [PATCH 13/20] ACPI: PCI: use positive logic to simplify code Bjorn Helgaas
2008-12-09 4:31 ` [PATCH 14/20] ACPI: PCI: follow typical PCI INTx swizzling pattern Bjorn Helgaas
2008-12-09 4:31 ` [PATCH 15/20] ACPI: PCI: combine lookup and derive Bjorn Helgaas
2008-12-09 4:31 ` [PATCH 16/20] ACPI: PCI: simplify list of _PRT entries Bjorn Helgaas
2008-12-09 4:31 ` [PATCH 17/20] ACPI: PCI: simplify struct acpi_prt_entry Bjorn Helgaas
2008-12-09 4:31 ` [PATCH 18/20] ACPI: PCI: expand acpi_pci_allocate_irq() and acpi_pci_free_irq() inline Bjorn Helgaas
2008-12-09 4:31 ` [PATCH 19/20] ACPI: PCI: whitespace and useless initialization cleanup Bjorn Helgaas
2008-12-09 4:31 ` [PATCH 20/20] ACPI: PCI: add HP copyright Bjorn Helgaas
2008-12-31 4:17 ` [PATCH 00/20] ACPI: PCI: simplify _PRT handling Len Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20081209043015.26415.63813.stgit@bob.kio \
--to=bjorn.helgaas@hp.com \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox