lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:	Tue, 19 Oct 2010 01:21:23 +0400
From:	Cyrill Gorcunov <gorcunov@...il.com>
To:	Thomas Gleixner <tglx@...utronix.de>, Ingo Molnar <mingo@...e.hu>,
	"H. Peter Anvin" <hpa@...or.com>
Cc:	LKML <linux-kernel@...r.kernel.org>
Subject: [PATCH -tip] x86, io-apic: Simplify ioapic_register_intr

Instead of setting IRQ_LEVEL flag early and then check for
IRQ being remapped and spread set_irq_chip_and_handler_name
over function body several times, defer IRQ_LEVEL setting
and save irq_chip in local variable with subsequent call depending
on IRQ level. This seems to be more natural and easier to read
in result.

And 'trigger' parameter has int type, not long.

Signed-off-by: Cyrill Gorcunov <gorcunov@...nvz.org>
---

Please review, thanks! Complains are welcome.

 arch/x86/kernel/apic/io_apic.c |   37 ++++++++++++++-----------------------
 1 files changed, 14 insertions(+), 23 deletions(-)

diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
index 98c27b3..af5c911 100644
--- a/arch/x86/kernel/apic/io_apic.c
+++ b/arch/x86/kernel/apic/io_apic.c
@@ -1228,35 +1228,26 @@ static inline int IO_APIC_irq_trigger(int irq)
 }
 #endif
 
-static void ioapic_register_intr(unsigned int irq, unsigned long trigger)
+static void ioapic_register_intr(unsigned int irq, int trigger)
 {
-
-	if ((trigger == IOAPIC_AUTO && IO_APIC_irq_trigger(irq)) ||
-	    trigger == IOAPIC_LEVEL)
-		irq_set_status_flags(irq, IRQ_LEVEL);
-	else
-		irq_clear_status_flags(irq, IRQ_LEVEL);
+	struct irq_chip *chip;
 
 	if (irq_remapped(get_irq_chip_data(irq))) {
 		irq_set_status_flags(irq, IRQ_MOVE_PCNTXT);
-		if (trigger)
-			set_irq_chip_and_handler_name(irq, &ir_ioapic_chip,
-						      handle_fasteoi_irq,
-						     "fasteoi");
-		else
-			set_irq_chip_and_handler_name(irq, &ir_ioapic_chip,
-						      handle_edge_irq, "edge");
-		return;
-	}
+		chip = &ir_ioapic_chip;
+	} else
+		chip = &ioapic_chip;
 
 	if ((trigger == IOAPIC_AUTO && IO_APIC_irq_trigger(irq)) ||
-	    trigger == IOAPIC_LEVEL)
-		set_irq_chip_and_handler_name(irq, &ioapic_chip,
-					      handle_fasteoi_irq,
-					      "fasteoi");
-	else
-		set_irq_chip_and_handler_name(irq, &ioapic_chip,
-					      handle_edge_irq, "edge");
+		trigger == IOAPIC_LEVEL) {
+		irq_set_status_flags(irq, IRQ_LEVEL);
+		set_irq_chip_and_handler_name(irq, chip,
+				handle_fasteoi_irq, "fasteoi");
+	} else {
+		irq_clear_status_flags(irq, IRQ_LEVEL);
+		set_irq_chip_and_handler_name(irq, chip,
+				 handle_edge_irq, "edge");
+	}
 }
 
 static int setup_ioapic_entry(int apic_id, int irq,
-- 
1.7.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ