From: Bjorn Helgaas <bjorn.helgaas@hp.com>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org,
Russell King <rmk+serial@arm.linux.org.uk>,
Jeff Garzik <jeff@garzik.org>,
Andrew Morton <akpm@linux-foundation.org>
Subject: [patch 1/2] 8250: add serial8250_register_port_at() for requesting specific ttyS lines
Date: Wed, 16 Jan 2008 10:05:42 -0700 [thread overview]
Message-ID: <20080116170914.709127164@ldl.fc.hp.com> (raw)
In-Reply-To: 20080116170541.511233227@ldl.fc.hp.com
[-- Attachment #1: 8250-register-at --]
[-- Type: text/plain, Size: 3742 bytes --]
Add an interface for registering a new UART with a specific ttyS name.
Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Index: work5/include/linux/serial_8250.h
===================================================================
--- work5.orig/include/linux/serial_8250.h 2008-01-15 16:31:49.000000000 -0700
+++ work5/include/linux/serial_8250.h 2008-01-15 16:32:42.000000000 -0700
@@ -56,6 +56,7 @@
struct uart_port;
int serial8250_register_port(struct uart_port *);
+int serial8250_register_port_at(struct uart_port *, int line);
void serial8250_unregister_port(int line);
void serial8250_suspend_port(int line);
void serial8250_resume_port(int line);
Index: work5/drivers/serial/8250.c
===================================================================
--- work5.orig/drivers/serial/8250.c 2008-01-15 16:31:49.000000000 -0700
+++ work5/drivers/serial/8250.c 2008-01-16 09:32:20.000000000 -0700
@@ -2785,6 +2785,25 @@
return NULL;
}
+static int serial8250_add_port(struct uart_8250_port *uart, struct uart_port *port)
+{
+ uart_remove_one_port(&serial8250_reg, &uart->port);
+
+ uart->port.iobase = port->iobase;
+ uart->port.membase = port->membase;
+ uart->port.irq = port->irq;
+ uart->port.uartclk = port->uartclk;
+ uart->port.fifosize = port->fifosize;
+ uart->port.regshift = port->regshift;
+ uart->port.iotype = port->iotype;
+ uart->port.flags = port->flags | UPF_BOOT_AUTOCONF;
+ uart->port.mapbase = port->mapbase;
+ if (port->dev)
+ uart->port.dev = port->dev;
+
+ return uart_add_one_port(&serial8250_reg, &uart->port);
+}
+
/**
* serial8250_register_port - register a serial port
* @port: serial port template
@@ -2809,32 +2828,58 @@
mutex_lock(&serial_mutex);
uart = serial8250_find_match_or_unused(port);
- if (uart) {
- uart_remove_one_port(&serial8250_reg, &uart->port);
+ if (uart)
+ ret = serial8250_add_port(uart, port);
- uart->port.iobase = port->iobase;
- uart->port.membase = port->membase;
- uart->port.irq = port->irq;
- uart->port.uartclk = port->uartclk;
- uart->port.fifosize = port->fifosize;
- uart->port.regshift = port->regshift;
- uart->port.iotype = port->iotype;
- uart->port.flags = port->flags | UPF_BOOT_AUTOCONF;
- uart->port.mapbase = port->mapbase;
- if (port->dev)
- uart->port.dev = port->dev;
-
- ret = uart_add_one_port(&serial8250_reg, &uart->port);
- if (ret == 0)
- ret = uart->port.line;
- }
mutex_unlock(&serial_mutex);
+ if (ret == 0)
+ return uart->port.line;
return ret;
}
EXPORT_SYMBOL(serial8250_register_port);
/**
+ * serial8250_register_port_at - register a serial port at a specific line
+ * @port: serial port template
+ * @line: desired line
+ *
+ * Same as serial8250_register_port(), except that we request a
+ * specific ttyS name. This is used for well-known ports like
+ * COM1-COM4, which people expect to always be ttyS0-ttyS3.
+ *
+ * This fails if the requested line is already in use, even though
+ * other lines might still be available. The caller can retry with
+ * serial8250_register_port() if desired.
+ */
+int serial8250_register_port_at(struct uart_port *port, int line)
+{
+ struct uart_8250_port *uart;
+ int ret;
+
+ if (port->uartclk == 0)
+ return -EINVAL;
+
+ if (line >= nr_uarts)
+ return -ENOSPC;
+
+ mutex_lock(&serial_mutex);
+
+ uart = &serial8250_ports[line];
+ if (uart->port.type == PORT_UNKNOWN && uart->port.iobase == 0)
+ ret = serial8250_add_port(uart, port);
+ else
+ ret = -EBUSY;
+
+ mutex_unlock(&serial_mutex);
+
+ if (ret == 0)
+ return uart->port.line;
+ return ret;
+}
+EXPORT_SYMBOL(serial8250_register_port_at);
+
+/**
* serial8250_unregister_port - remove a 16x50 serial port at runtime
* @line: serial line number
*
--
WARNING: multiple messages have this Message-ID (diff)
From: Bjorn Helgaas <bjorn.helgaas@hp.com>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: linux-kernel@vger.kernel.org
Cc: linux-serial@vger.kernel.org
Cc: Russell King <rmk+serial@arm.linux.org.uk>
Cc: Jeff Garzik <jeff@garzik.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Subject: [patch 1/2] 8250: add serial8250_register_port_at() for requesting specific ttyS lines
Date: Wed, 16 Jan 2008 10:05:42 -0700 [thread overview]
Message-ID: <20080116170914.709127164@ldl.fc.hp.com> (raw)
In-Reply-To: 20080116170541.511233227@ldl.fc.hp.com
[-- Attachment #1: 8250-register-at --]
[-- Type: text/plain, Size: 3742 bytes --]
Add an interface for registering a new UART with a specific ttyS name.
Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Index: work5/include/linux/serial_8250.h
===================================================================
--- work5.orig/include/linux/serial_8250.h 2008-01-15 16:31:49.000000000 -0700
+++ work5/include/linux/serial_8250.h 2008-01-15 16:32:42.000000000 -0700
@@ -56,6 +56,7 @@
struct uart_port;
int serial8250_register_port(struct uart_port *);
+int serial8250_register_port_at(struct uart_port *, int line);
void serial8250_unregister_port(int line);
void serial8250_suspend_port(int line);
void serial8250_resume_port(int line);
Index: work5/drivers/serial/8250.c
===================================================================
--- work5.orig/drivers/serial/8250.c 2008-01-15 16:31:49.000000000 -0700
+++ work5/drivers/serial/8250.c 2008-01-16 09:32:20.000000000 -0700
@@ -2785,6 +2785,25 @@
return NULL;
}
+static int serial8250_add_port(struct uart_8250_port *uart, struct uart_port *port)
+{
+ uart_remove_one_port(&serial8250_reg, &uart->port);
+
+ uart->port.iobase = port->iobase;
+ uart->port.membase = port->membase;
+ uart->port.irq = port->irq;
+ uart->port.uartclk = port->uartclk;
+ uart->port.fifosize = port->fifosize;
+ uart->port.regshift = port->regshift;
+ uart->port.iotype = port->iotype;
+ uart->port.flags = port->flags | UPF_BOOT_AUTOCONF;
+ uart->port.mapbase = port->mapbase;
+ if (port->dev)
+ uart->port.dev = port->dev;
+
+ return uart_add_one_port(&serial8250_reg, &uart->port);
+}
+
/**
* serial8250_register_port - register a serial port
* @port: serial port template
@@ -2809,32 +2828,58 @@
mutex_lock(&serial_mutex);
uart = serial8250_find_match_or_unused(port);
- if (uart) {
- uart_remove_one_port(&serial8250_reg, &uart->port);
+ if (uart)
+ ret = serial8250_add_port(uart, port);
- uart->port.iobase = port->iobase;
- uart->port.membase = port->membase;
- uart->port.irq = port->irq;
- uart->port.uartclk = port->uartclk;
- uart->port.fifosize = port->fifosize;
- uart->port.regshift = port->regshift;
- uart->port.iotype = port->iotype;
- uart->port.flags = port->flags | UPF_BOOT_AUTOCONF;
- uart->port.mapbase = port->mapbase;
- if (port->dev)
- uart->port.dev = port->dev;
-
- ret = uart_add_one_port(&serial8250_reg, &uart->port);
- if (ret == 0)
- ret = uart->port.line;
- }
mutex_unlock(&serial_mutex);
+ if (ret == 0)
+ return uart->port.line;
return ret;
}
EXPORT_SYMBOL(serial8250_register_port);
/**
+ * serial8250_register_port_at - register a serial port at a specific line
+ * @port: serial port template
+ * @line: desired line
+ *
+ * Same as serial8250_register_port(), except that we request a
+ * specific ttyS name. This is used for well-known ports like
+ * COM1-COM4, which people expect to always be ttyS0-ttyS3.
+ *
+ * This fails if the requested line is already in use, even though
+ * other lines might still be available. The caller can retry with
+ * serial8250_register_port() if desired.
+ */
+int serial8250_register_port_at(struct uart_port *port, int line)
+{
+ struct uart_8250_port *uart;
+ int ret;
+
+ if (port->uartclk == 0)
+ return -EINVAL;
+
+ if (line >= nr_uarts)
+ return -ENOSPC;
+
+ mutex_lock(&serial_mutex);
+
+ uart = &serial8250_ports[line];
+ if (uart->port.type == PORT_UNKNOWN && uart->port.iobase == 0)
+ ret = serial8250_add_port(uart, port);
+ else
+ ret = -EBUSY;
+
+ mutex_unlock(&serial_mutex);
+
+ if (ret == 0)
+ return uart->port.line;
+ return ret;
+}
+EXPORT_SYMBOL(serial8250_register_port_at);
+
+/**
* serial8250_unregister_port - remove a 16x50 serial port at runtime
* @line: serial line number
*
--
next prev parent reply other threads:[~2008-01-16 17:08 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-16 17:05 [patch 0/2] serial: explicitly request ttyS0-3 for COM1-4 Bjorn Helgaas
2008-01-16 17:05 ` Bjorn Helgaas
2008-01-16 17:05 ` Bjorn Helgaas [this message]
2008-01-16 17:05 ` [patch 1/2] 8250: add serial8250_register_port_at() for requesting specific ttyS lines Bjorn Helgaas
2008-01-16 17:05 ` [patch 2/2] 8250_pnp: register x86 COM ports at the conventional ttyS names Bjorn Helgaas
2008-01-16 17:05 ` Bjorn Helgaas
2008-01-16 18:42 ` Russell King
2008-01-16 18:44 ` H. Peter Anvin
2008-01-16 19:47 ` Bjorn Helgaas
2008-01-16 19:49 ` H. Peter Anvin
2008-01-16 18:39 ` [patch 0/2] serial: explicitly request ttyS0-3 for COM1-4 Russell King
2008-01-16 19:59 ` Bjorn Helgaas
2008-01-16 20:14 ` Russell King
2008-01-17 16:07 ` Bjorn Helgaas
2008-01-17 16:16 ` Russell King
2008-01-17 17:56 ` Bjorn Helgaas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080116170914.709127164@ldl.fc.hp.com \
--to=bjorn.helgaas@hp.com \
--cc=akpm@linux-foundation.org \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=jeff@garzik.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=rmk+serial@arm.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.