term/serial: Improve detection of duplicate serial ports

We currently rely on some pretty fragile comparison by name to
identify whether a serial port being configured is identical

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
This commit is contained in:
Benjamin Herrenschmidt authored and Daniel Kiper committed 2023-01-19 17:39:04 +01:00
1 parent e37dbba665
commit 35782e165f
6 files changed
+52 -36

No files matched your search

+16
View File
@@ -364,6 +364,14 @@ grub_serial_ns8250_add_port (grub_port_t port, struct grub_serial_config *config
return &com_ports[i];
}
FOR_SERIAL_PORTS (p)
if (p->mmio == false && p->port == port)
{
if (config != NULL)
grub_serial_port_configure (p, config);
return p;
}
grub_outb (0x5a, port + UART_SR);
if (grub_inb (port + UART_SR) != 0x5a)
return NULL;
@@ -409,6 +417,14 @@ grub_serial_ns8250_add_mmio (grub_addr_t addr, unsigned int acc_size,
return &com_ports[i];
}
FOR_SERIAL_PORTS (p)
if (p->mmio == true && p->mmio_base == addr)
{
if (config != NULL)
grub_serial_port_configure (p, config);
return p;
}
p = grub_malloc (sizeof (*p));
if (p == NULL)
return NULL;