Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

x86: Avoid magic number with ELCR register accesses

Define PIC_ELCR1 and PIC_ELCR2 macros for accesses to the ELCR registers
implemented by many chipsets in their embedded 8259A PIC cores, avoiding
magic numbers that are difficult to handle, and complementing the macros
we already have for registers originally defined with discrete 8259A PIC
implementations. No functional change.

Signed-off-by: Maciej W. Rozycki <macro@orcam.me.uk>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/alpine.DEB.2.21.2107200237300.9461@angie.orcam.me.uk

authored by

Maciej W. Rozycki and committed by
Thomas Gleixner
d2531661 0e8c6f56

+15 -11
+2
arch/x86/include/asm/i8259.h
··· 19 19 #define PIC_MASTER_OCW3 PIC_MASTER_ISR 20 20 #define PIC_SLAVE_CMD 0xa0 21 21 #define PIC_SLAVE_IMR 0xa1 22 + #define PIC_ELCR1 0x4d0 23 + #define PIC_ELCR2 0x4d1 22 24 23 25 /* i8259A PIC related value */ 24 26 #define PIC_CASCADE_IR 2
+3 -3
arch/x86/kernel/acpi/boot.c
··· 570 570 unsigned int old, new; 571 571 572 572 /* Real old ELCR mask */ 573 - old = inb(0x4d0) | (inb(0x4d1) << 8); 573 + old = inb(PIC_ELCR1) | (inb(PIC_ELCR2) << 8); 574 574 575 575 /* 576 576 * If we use ACPI to set PCI IRQs, then we should clear ELCR ··· 596 596 return; 597 597 598 598 pr_warn("setting ELCR to %04x (from %04x)\n", new, old); 599 - outb(new, 0x4d0); 600 - outb(new >> 8, 0x4d1); 599 + outb(new, PIC_ELCR1); 600 + outb(new >> 8, PIC_ELCR2); 601 601 } 602 602 603 603 int acpi_gsi_to_irq(u32 gsi, unsigned int *irqp)
+1 -1
arch/x86/kernel/apic/io_apic.c
··· 764 764 static bool EISA_ELCR(unsigned int irq) 765 765 { 766 766 if (irq < nr_legacy_irqs()) { 767 - unsigned int port = 0x4d0 + (irq >> 3); 767 + unsigned int port = PIC_ELCR1 + (irq >> 3); 768 768 return (inb(port) >> (irq & 7)) & 1; 769 769 } 770 770 apic_printk(APIC_VERBOSE, KERN_INFO
+1 -1
arch/x86/kernel/apic/vector.c
··· 1299 1299 1300 1300 pr_debug("... PIC ISR: %04x\n", v); 1301 1301 1302 - v = inb(0x4d1) << 8 | inb(0x4d0); 1302 + v = inb(PIC_ELCR2) << 8 | inb(PIC_ELCR1); 1303 1303 pr_debug("... PIC ELCR: %04x\n", v); 1304 1304 } 1305 1305
+4 -4
arch/x86/kernel/i8259.c
··· 235 235 */ 236 236 static void restore_ELCR(char *trigger) 237 237 { 238 - outb(trigger[0], 0x4d0); 239 - outb(trigger[1], 0x4d1); 238 + outb(trigger[0], PIC_ELCR1); 239 + outb(trigger[1], PIC_ELCR2); 240 240 } 241 241 242 242 static void save_ELCR(char *trigger) 243 243 { 244 244 /* IRQ 0,1,2,8,13 are marked as reserved */ 245 - trigger[0] = inb(0x4d0) & 0xF8; 246 - trigger[1] = inb(0x4d1) & 0xDE; 245 + trigger[0] = inb(PIC_ELCR1) & 0xF8; 246 + trigger[1] = inb(PIC_ELCR2) & 0xDE; 247 247 } 248 248 249 249 static void i8259A_resume(void)
+2 -1
arch/x86/kernel/mpparse.c
··· 19 19 #include <linux/smp.h> 20 20 #include <linux/pci.h> 21 21 22 + #include <asm/i8259.h> 22 23 #include <asm/io_apic.h> 23 24 #include <asm/acpi.h> 24 25 #include <asm/irqdomain.h> ··· 252 251 { 253 252 unsigned int port; 254 253 255 - port = 0x4d0 + (irq >> 3); 254 + port = PIC_ELCR1 + (irq >> 3); 256 255 return (inb(port) >> (irq & 7)) & 1; 257 256 } 258 257
+2 -1
arch/x86/pci/irq.c
··· 18 18 #include <linux/irq.h> 19 19 #include <linux/acpi.h> 20 20 21 + #include <asm/i8259.h> 21 22 #include <asm/pc-conf-reg.h> 22 23 #include <asm/pci_x86.h> 23 24 ··· 159 158 void elcr_set_level_irq(unsigned int irq) 160 159 { 161 160 unsigned char mask = 1 << (irq & 7); 162 - unsigned int port = 0x4d0 + (irq >> 3); 161 + unsigned int port = PIC_ELCR1 + (irq >> 3); 163 162 unsigned char val; 164 163 static u16 elcr_irq_mask; 165 164