From: Cyrill Gorcunov <gorcunov@openvz.org>
To: yinghai@kernel.org, mingo@elte.hu, hpa@zytor.com, tglx@linutronix.de
Cc: linux-kernel@vger.kernel.org, Cyrill Gorcunov <gorcunov@openvz.org>
Subject: [rfc 1/2] x86,ioapic: introduce for_each_irq_pin helper
Date: Sat, 01 Aug 2009 11:47:59 +0400 [thread overview]
Message-ID: <20090801075435.597863129@openvz.org> (raw)
In-Reply-To: 20090801074758.502095557@openvz.org
[-- Attachment #1: x86-ioapic-for-each --]
[-- Type: text/plain, Size: 3377 bytes --]
This allow us to save a few lines of code.
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
---
arch/x86/kernel/apic/io_apic.c | 43 ++++++++++++++---------------------------
1 file changed, 15 insertions(+), 28 deletions(-)
Index: linux-2.6.git/arch/x86/kernel/apic/io_apic.c
=====================================================================
--- linux-2.6.git.orig/arch/x86/kernel/apic/io_apic.c
+++ linux-2.6.git/arch/x86/kernel/apic/io_apic.c
@@ -66,6 +66,8 @@
#include <asm/apic.h>
#define __apicdebuginit(type) static type __init
+#define for_each_irq_pin(entry, head) \
+ for (entry = head; entry; entry = entry->next)
/*
* Is the SiS APIC rmw bug present ?
@@ -410,7 +412,7 @@ static bool io_apic_level_ack_pending(st
unsigned long flags;
spin_lock_irqsave(&ioapic_lock, flags);
- for (entry = cfg->irq_2_pin; entry != NULL; entry = entry->next) {
+ for_each_irq_pin(entry, cfg->irq_2_pin) {
unsigned int reg;
int pin;
@@ -490,22 +492,21 @@ static void ioapic_mask_entry(int apic,
*/
static void add_pin_to_irq_node(struct irq_cfg *cfg, int node, int apic, int pin)
{
- struct irq_pin_list **entryp, *entry;
+ struct irq_pin_list **last, *entry;
- for (entryp = &cfg->irq_2_pin;
- *entryp != NULL;
- entryp = &(*entryp)->next) {
- entry = *entryp;
- /* not again, please */
+ /* don't allow duplicates */
+ last = &cfg->irq_2_pin;
+ for_each_irq_pin(entry, cfg->irq_2_pin) {
if (entry->apic == apic && entry->pin == pin)
return;
+ last = &entry->next;
}
entry = get_one_free_irq_2_pin(node);
entry->apic = apic;
entry->pin = pin;
- *entryp = entry;
+ *last = entry;
}
/*
@@ -517,7 +518,7 @@ static void __init replace_pin_at_irq_no
{
struct irq_pin_list *entry;
- for (entry = cfg->irq_2_pin; entry != NULL; entry = entry->next) {
+ for_each_irq_pin(entry, cfg->irq_2_pin) {
if (entry->apic == oldapic && entry->pin == oldpin) {
entry->apic = newapic;
entry->pin = newpin;
@@ -537,7 +538,7 @@ static void io_apic_modify_irq(struct ir
int pin;
struct irq_pin_list *entry;
- for (entry = cfg->irq_2_pin; entry != NULL; entry = entry->next) {
+ for_each_irq_pin(entry, cfg->irq_2_pin) {
unsigned int reg;
pin = entry->pin;
reg = io_apic_read(entry->apic, 0x10 + pin * 2);
@@ -1669,12 +1670,8 @@ __apicdebuginit(void) print_IO_APIC(void
if (!entry)
continue;
printk(KERN_DEBUG "IRQ%d ", irq);
- for (;;) {
+ for_each_irq_pin(entry, cfg->irq_2_pin)
printk("-> %d:%d", entry->apic, entry->pin);
- if (!entry->next)
- break;
- entry = entry->next;
- }
printk("\n");
}
@@ -2227,7 +2224,7 @@ static void __target_IO_APIC_irq(unsigne
struct irq_pin_list *entry;
u8 vector = cfg->vector;
- for (entry = cfg->irq_2_pin; entry != NULL; entry = entry->next) {
+ for_each_irq_pin(entry, cfg->irq_2_pin) {
unsigned int reg;
apic = entry->apic;
@@ -2556,20 +2553,10 @@ static void ack_apic_level(unsigned int
#ifdef CONFIG_INTR_REMAP
static void __eoi_ioapic_irq(unsigned int irq, struct irq_cfg *cfg)
{
- int apic, pin;
struct irq_pin_list *entry;
- entry = cfg->irq_2_pin;
- for (;;) {
-
- if (!entry)
- break;
-
- apic = entry->apic;
- pin = entry->pin;
- io_apic_eoi(apic, pin);
- entry = entry->next;
- }
+ for_each_irq_pin(entry, cfg->irq_2_pin)
+ io_apic_eoi(entry->apic, entry->pin);
}
static void
next prev parent reply other threads:[~2009-08-01 7:54 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-01 7:47 [rfc 0/2] x86,ioapic simplification,bugfix Cyrill Gorcunov
2009-08-01 7:47 ` Cyrill Gorcunov [this message]
2009-08-04 14:11 ` [rfc 1/2] x86,ioapic: introduce for_each_irq_pin helper Ingo Molnar
2009-08-04 14:16 ` [tip:x86/apic] x86, ioapic: Introduce for_each_irq_pin() helper tip-bot for Cyrill Gorcunov
2009-08-05 10:55 ` tip-bot for Cyrill Gorcunov
2009-08-01 7:48 ` [rfc 2/2] x86,ioapic: throw BUG instead of NULL dereference Cyrill Gorcunov
2009-08-04 14:16 ` [tip:x86/apic] x86, ioapic: Throw " tip-bot for Cyrill Gorcunov
2009-08-05 10:55 ` tip-bot for Cyrill Gorcunov
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=20090801075435.597863129@openvz.org \
--to=gorcunov@openvz.org \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=tglx@linutronix.de \
--cc=yinghai@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.