diff options
author | Bjorn Helgaas <bjorn.helgaas@hp.com> | 2008-12-08 23:31:21 -0500 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2008-12-30 21:42:15 -0500 |
commit | 3604a9f445afde2801b8c24b63dd289c33e290a6 (patch) | |
tree | 65fd7f3ab0f8830d76534f085b98cb159ca18889 /drivers/acpi/pci_irq.c | |
parent | 5697b7ca406b4ee0afeef6d9a29b823767716cab (diff) |
ACPI: PCI: simplify list of _PRT entries
We don't need a struct containing a count and a list_head; a simple
list_head is sufficient. The list iterators handle empty lists
fine.
Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi/pci_irq.c')
-rw-r--r-- | drivers/acpi/pci_irq.c | 60 |
1 files changed, 12 insertions, 48 deletions
diff --git a/drivers/acpi/pci_irq.c b/drivers/acpi/pci_irq.c index b03bb84266b2..42b195ed7922 100644 --- a/drivers/acpi/pci_irq.c +++ b/drivers/acpi/pci_irq.c | |||
@@ -42,7 +42,7 @@ | |||
42 | ACPI_MODULE_NAME("pci_irq"); | 42 | ACPI_MODULE_NAME("pci_irq"); |
43 | 43 | ||
44 | struct acpi_prt_entry { | 44 | struct acpi_prt_entry { |
45 | struct list_head node; | 45 | struct list_head list; |
46 | struct acpi_pci_id id; | 46 | struct acpi_pci_id id; |
47 | u8 pin; | 47 | u8 pin; |
48 | struct { | 48 | struct { |
@@ -52,12 +52,7 @@ struct acpi_prt_entry { | |||
52 | u32 irq; | 52 | u32 irq; |
53 | }; | 53 | }; |
54 | 54 | ||
55 | struct acpi_prt_list { | 55 | static LIST_HEAD(acpi_prt_list); |
56 | int count; | ||
57 | struct list_head entries; | ||
58 | }; | ||
59 | |||
60 | static struct acpi_prt_list acpi_prt; | ||
61 | static DEFINE_SPINLOCK(acpi_prt_lock); | 56 | static DEFINE_SPINLOCK(acpi_prt_lock); |
62 | 57 | ||
63 | static inline char pin_name(int pin) | 58 | static inline char pin_name(int pin) |
@@ -72,21 +67,13 @@ static inline char pin_name(int pin) | |||
72 | static struct acpi_prt_entry *acpi_pci_irq_find_prt_entry(struct pci_dev *dev, | 67 | static struct acpi_prt_entry *acpi_pci_irq_find_prt_entry(struct pci_dev *dev, |
73 | int pin) | 68 | int pin) |
74 | { | 69 | { |
75 | struct acpi_prt_entry *entry = NULL; | 70 | struct acpi_prt_entry *entry; |
76 | int segment = pci_domain_nr(dev->bus); | 71 | int segment = pci_domain_nr(dev->bus); |
77 | int bus = dev->bus->number; | 72 | int bus = dev->bus->number; |
78 | int device = PCI_SLOT(dev->devfn); | 73 | int device = PCI_SLOT(dev->devfn); |
79 | 74 | ||
80 | if (!acpi_prt.count) | ||
81 | return NULL; | ||
82 | |||
83 | /* | ||
84 | * Parse through all PRT entries looking for a match on the specified | ||
85 | * PCI device's segment, bus, device, and pin (don't care about func). | ||
86 | * | ||
87 | */ | ||
88 | spin_lock(&acpi_prt_lock); | 75 | spin_lock(&acpi_prt_lock); |
89 | list_for_each_entry(entry, &acpi_prt.entries, node) { | 76 | list_for_each_entry(entry, &acpi_prt_list, list) { |
90 | if ((segment == entry->id.segment) | 77 | if ((segment == entry->id.segment) |
91 | && (bus == entry->id.bus) | 78 | && (bus == entry->id.bus) |
92 | && (device == entry->id.device) | 79 | && (device == entry->id.device) |
@@ -95,7 +82,6 @@ static struct acpi_prt_entry *acpi_pci_irq_find_prt_entry(struct pci_dev *dev, | |||
95 | return entry; | 82 | return entry; |
96 | } | 83 | } |
97 | } | 84 | } |
98 | |||
99 | spin_unlock(&acpi_prt_lock); | 85 | spin_unlock(&acpi_prt_lock); |
100 | return NULL; | 86 | return NULL; |
101 | } | 87 | } |
@@ -201,7 +187,7 @@ static int | |||
201 | acpi_pci_irq_add_entry(acpi_handle handle, | 187 | acpi_pci_irq_add_entry(acpi_handle handle, |
202 | int segment, int bus, struct acpi_pci_routing_table *prt) | 188 | int segment, int bus, struct acpi_pci_routing_table *prt) |
203 | { | 189 | { |
204 | struct acpi_prt_entry *entry = NULL; | 190 | struct acpi_prt_entry *entry; |
205 | 191 | ||
206 | entry = kzalloc(sizeof(struct acpi_prt_entry), GFP_KERNEL); | 192 | entry = kzalloc(sizeof(struct acpi_prt_entry), GFP_KERNEL); |
207 | if (!entry) | 193 | if (!entry) |
@@ -253,35 +239,17 @@ acpi_pci_irq_add_entry(acpi_handle handle, | |||
253 | prt->source, entry->link.index)); | 239 | prt->source, entry->link.index)); |
254 | 240 | ||
255 | spin_lock(&acpi_prt_lock); | 241 | spin_lock(&acpi_prt_lock); |
256 | list_add_tail(&entry->node, &acpi_prt.entries); | 242 | list_add_tail(&entry->list, &acpi_prt_list); |
257 | acpi_prt.count++; | ||
258 | spin_unlock(&acpi_prt_lock); | 243 | spin_unlock(&acpi_prt_lock); |
259 | 244 | ||
260 | return 0; | 245 | return 0; |
261 | } | 246 | } |
262 | 247 | ||
263 | static void | ||
264 | acpi_pci_irq_del_entry(int segment, int bus, struct acpi_prt_entry *entry) | ||
265 | { | ||
266 | if (segment == entry->id.segment && bus == entry->id.bus) { | ||
267 | acpi_prt.count--; | ||
268 | list_del(&entry->node); | ||
269 | kfree(entry); | ||
270 | } | ||
271 | } | ||
272 | |||
273 | int acpi_pci_irq_add_prt(acpi_handle handle, int segment, int bus) | 248 | int acpi_pci_irq_add_prt(acpi_handle handle, int segment, int bus) |
274 | { | 249 | { |
275 | acpi_status status; | 250 | acpi_status status; |
276 | struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; | 251 | struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; |
277 | struct acpi_pci_routing_table *entry; | 252 | struct acpi_pci_routing_table *entry; |
278 | static int first_time = 1; | ||
279 | |||
280 | if (first_time) { | ||
281 | acpi_prt.count = 0; | ||
282 | INIT_LIST_HEAD(&acpi_prt.entries); | ||
283 | first_time = 0; | ||
284 | } | ||
285 | 253 | ||
286 | /* 'handle' is the _PRT's parent (root bridge or PCI-PCI bridge) */ | 254 | /* 'handle' is the _PRT's parent (root bridge or PCI-PCI bridge) */ |
287 | status = acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer); | 255 | status = acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer); |
@@ -317,21 +285,17 @@ int acpi_pci_irq_add_prt(acpi_handle handle, int segment, int bus) | |||
317 | 285 | ||
318 | void acpi_pci_irq_del_prt(int segment, int bus) | 286 | void acpi_pci_irq_del_prt(int segment, int bus) |
319 | { | 287 | { |
320 | struct list_head *node = NULL, *n = NULL; | 288 | struct acpi_prt_entry *entry, *tmp; |
321 | struct acpi_prt_entry *entry = NULL; | ||
322 | |||
323 | if (!acpi_prt.count) { | ||
324 | return; | ||
325 | } | ||
326 | 289 | ||
327 | printk(KERN_DEBUG | 290 | printk(KERN_DEBUG |
328 | "ACPI: Delete PCI Interrupt Routing Table for %04x:%02x\n", | 291 | "ACPI: Delete PCI Interrupt Routing Table for %04x:%02x\n", |
329 | segment, bus); | 292 | segment, bus); |
330 | spin_lock(&acpi_prt_lock); | 293 | spin_lock(&acpi_prt_lock); |
331 | list_for_each_safe(node, n, &acpi_prt.entries) { | 294 | list_for_each_entry_safe(entry, tmp, &acpi_prt_list, list) { |
332 | entry = list_entry(node, struct acpi_prt_entry, node); | 295 | if (segment == entry->id.segment && bus == entry->id.bus) { |
333 | 296 | list_del(&entry->list); | |
334 | acpi_pci_irq_del_entry(segment, bus, entry); | 297 | kfree(entry); |
298 | } | ||
335 | } | 299 | } |
336 | spin_unlock(&acpi_prt_lock); | 300 | spin_unlock(&acpi_prt_lock); |
337 | } | 301 | } |