Commit 8440838b authored by David S. Miller's avatar David S. Miller Committed by Linus Torvalds

serial: fix device name reporting when minor space is shared between drivers

The multiple drivers share the minor space occupied by a particular major
number, the actual index within the device name's space is indicated by
the tty_driver->name_base + uart_port->line

Another usable formula is (uart_driver->minor - MINOR_BASE) + port->line

Use those to print the device names properly in such situations in
serial_core.c and 8250.c
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarAlan Cox <alan@redhat.com>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent a7be18d4
...@@ -57,6 +57,13 @@ static unsigned int share_irqs = SERIAL8250_SHARE_IRQS; ...@@ -57,6 +57,13 @@ static unsigned int share_irqs = SERIAL8250_SHARE_IRQS;
static unsigned int nr_uarts = CONFIG_SERIAL_8250_RUNTIME_UARTS; static unsigned int nr_uarts = CONFIG_SERIAL_8250_RUNTIME_UARTS;
static struct uart_driver serial8250_reg;
static int serial_index(struct uart_port *port)
{
return (serial8250_reg.minor - 64) + port->line;
}
/* /*
* Debugging. * Debugging.
*/ */
...@@ -997,7 +1004,7 @@ static void autoconfig(struct uart_8250_port *up, unsigned int probeflags) ...@@ -997,7 +1004,7 @@ static void autoconfig(struct uart_8250_port *up, unsigned int probeflags)
return; return;
DEBUG_AUTOCONF("ttyS%d: autoconf (0x%04x, 0x%p): ", DEBUG_AUTOCONF("ttyS%d: autoconf (0x%04x, 0x%p): ",
up->port.line, up->port.iobase, up->port.membase); serial_index(&up->port), up->port.iobase, up->port.membase);
/* /*
* We really do need global IRQs disabled here - we're going to * We really do need global IRQs disabled here - we're going to
...@@ -1132,7 +1139,7 @@ static void autoconfig(struct uart_8250_port *up, unsigned int probeflags) ...@@ -1132,7 +1139,7 @@ static void autoconfig(struct uart_8250_port *up, unsigned int probeflags)
if (up->capabilities != uart_config[up->port.type].flags) { if (up->capabilities != uart_config[up->port.type].flags) {
printk(KERN_WARNING printk(KERN_WARNING
"ttyS%d: detected caps %08x should be %08x\n", "ttyS%d: detected caps %08x should be %08x\n",
up->port.line, up->capabilities, serial_index(&up->port), up->capabilities,
uart_config[up->port.type].flags); uart_config[up->port.type].flags);
} }
...@@ -1857,7 +1864,8 @@ static int serial8250_startup(struct uart_port *port) ...@@ -1857,7 +1864,8 @@ static int serial8250_startup(struct uart_port *port)
*/ */
if (!(up->port.flags & UPF_BUGGY_UART) && if (!(up->port.flags & UPF_BUGGY_UART) &&
(serial_inp(up, UART_LSR) == 0xff)) { (serial_inp(up, UART_LSR) == 0xff)) {
printk("ttyS%d: LSR safety check engaged!\n", up->port.line); printk(KERN_INFO "ttyS%d: LSR safety check engaged!\n",
serial_index(&up->port));
return -ENODEV; return -ENODEV;
} }
...@@ -1912,7 +1920,8 @@ static int serial8250_startup(struct uart_port *port) ...@@ -1912,7 +1920,8 @@ static int serial8250_startup(struct uart_port *port)
*/ */
if (!(iir1 & UART_IIR_NO_INT) && (iir & UART_IIR_NO_INT)) { if (!(iir1 & UART_IIR_NO_INT) && (iir & UART_IIR_NO_INT)) {
up->bugs |= UART_BUG_THRE; up->bugs |= UART_BUG_THRE;
pr_debug("ttyS%d - using backup timer\n", port->line); pr_debug("ttyS%d - using backup timer\n",
serial_index(port));
} }
} }
...@@ -1972,7 +1981,7 @@ static int serial8250_startup(struct uart_port *port) ...@@ -1972,7 +1981,7 @@ static int serial8250_startup(struct uart_port *port)
if (!(up->bugs & UART_BUG_TXEN)) { if (!(up->bugs & UART_BUG_TXEN)) {
up->bugs |= UART_BUG_TXEN; up->bugs |= UART_BUG_TXEN;
pr_debug("ttyS%d - enabling bad tx status workarounds\n", pr_debug("ttyS%d - enabling bad tx status workarounds\n",
port->line); serial_index(port));
} }
} else { } else {
up->bugs &= ~UART_BUG_TXEN; up->bugs &= ~UART_BUG_TXEN;
...@@ -2633,7 +2642,6 @@ static int serial8250_console_early_setup(void) ...@@ -2633,7 +2642,6 @@ static int serial8250_console_early_setup(void)
return serial8250_find_port_for_earlycon(); return serial8250_find_port_for_earlycon();
} }
static struct uart_driver serial8250_reg;
static struct console serial8250_console = { static struct console serial8250_console = {
.name = "ttyS", .name = "ttyS",
.write = serial8250_console_write, .write = serial8250_console_write,
......
...@@ -2051,7 +2051,8 @@ int uart_suspend_port(struct uart_driver *drv, struct uart_port *port) ...@@ -2051,7 +2051,8 @@ int uart_suspend_port(struct uart_driver *drv, struct uart_port *port)
"transmitter\n", "transmitter\n",
port->dev ? port->dev->bus_id : "", port->dev ? port->dev->bus_id : "",
port->dev ? ": " : "", port->dev ? ": " : "",
drv->dev_name, port->line); drv->dev_name,
drv->tty_driver->name_base + port->line);
ops->shutdown(port); ops->shutdown(port);
} }
...@@ -2176,7 +2177,9 @@ uart_report_port(struct uart_driver *drv, struct uart_port *port) ...@@ -2176,7 +2177,9 @@ uart_report_port(struct uart_driver *drv, struct uart_port *port)
printk(KERN_INFO "%s%s%s%d at %s (irq = %d) is a %s\n", printk(KERN_INFO "%s%s%s%d at %s (irq = %d) is a %s\n",
port->dev ? port->dev->bus_id : "", port->dev ? port->dev->bus_id : "",
port->dev ? ": " : "", port->dev ? ": " : "",
drv->dev_name, port->line, address, port->irq, uart_type(port)); drv->dev_name,
drv->tty_driver->name_base + port->line,
address, port->irq, uart_type(port));
} }
static void static void
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment