Commit bc12b70f authored by Peter Zijlstra's avatar Peter Zijlstra
Browse files

x86/earlyprintk: Clean up pciserial



While working on a GRUB patch to support PCI-serial, a number of
cleanups were suggested that apply to the code I took inspiration from.

Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>   # pci_ids.h
Reviewed-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Link: https://lkml.kernel.org/r/YwdeyCEtW+wa+QhH@worktop.programming.kicks-ass.net
parent b90cb105
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -264,11 +264,11 @@ static __init void early_pci_serial_init(char *s)
	bar0 = read_pci_config(bus, slot, func, PCI_BASE_ADDRESS_0);

	/*
	 * Verify it is a UART type device
	 * Verify it is a 16550-UART type device
	 */
	if (((classcode >> 16 != PCI_CLASS_COMMUNICATION_MODEM) &&
	     (classcode >> 16 != PCI_CLASS_COMMUNICATION_SERIAL)) ||
	   (((classcode >> 8) & 0xff) != 0x02)) /* 16550 I/F at BAR0 */ {
	    (((classcode >> 8) & 0xff) != PCI_SERIAL_16550_COMPATIBLE)) {
		if (!force)
			return;
	}
@@ -276,11 +276,11 @@ static __init void early_pci_serial_init(char *s)
	/*
	 * Determine if it is IO or memory mapped
	 */
	if (bar0 & 0x01) {
	if ((bar0 & PCI_BASE_ADDRESS_SPACE) == PCI_BASE_ADDRESS_SPACE_IO) {
		/* it is IO mapped */
		serial_in = io_serial_in;
		serial_out = io_serial_out;
		early_serial_base = bar0&0xfffffffc;
		early_serial_base = bar0 & PCI_BASE_ADDRESS_IO_MASK;
		write_pci_config(bus, slot, func, PCI_COMMAND,
				 cmdreg|PCI_COMMAND_IO);
	} else {
@@ -289,7 +289,7 @@ static __init void early_pci_serial_init(char *s)
		serial_out = mem32_serial_out;
		/* WARNING! assuming the address is always in the first 4G */
		early_serial_base =
			(unsigned long)early_ioremap(bar0 & 0xfffffff0, 0x10);
			(unsigned long)early_ioremap(bar0 & PCI_BASE_ADDRESS_MEM_MASK, 0x10);
		write_pci_config(bus, slot, func, PCI_COMMAND,
				 cmdreg|PCI_COMMAND_MEMORY);
	}
+3 −0
Original line number Diff line number Diff line
@@ -75,6 +75,9 @@
#define PCI_CLASS_COMMUNICATION_MODEM	0x0703
#define PCI_CLASS_COMMUNICATION_OTHER	0x0780

/* Interface for SERIAL/MODEM */
#define PCI_SERIAL_16550_COMPATIBLE	0x02

#define PCI_BASE_CLASS_SYSTEM		0x08
#define PCI_CLASS_SYSTEM_PIC		0x0800
#define PCI_CLASS_SYSTEM_PIC_IOAPIC	0x080010