aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/tty/serial/8250/8250.c91
-rw-r--r--include/linux/serial_8250.h1
2 files changed, 60 insertions, 32 deletions
diff --git a/drivers/tty/serial/8250/8250.c b/drivers/tty/serial/8250/8250.c
index 662188d6cddf..47d061b9ad4d 100644
--- a/drivers/tty/serial/8250/8250.c
+++ b/drivers/tty/serial/8250/8250.c
@@ -3112,7 +3112,7 @@ static struct uart_8250_port *serial8250_find_match_or_unused(struct uart_port *
3112} 3112}
3113 3113
3114/** 3114/**
3115 * serial8250_register_port - register a serial port 3115 * serial8250_register_8250_port - register a serial port
3116 * @port: serial port template 3116 * @port: serial port template
3117 * 3117 *
3118 * Configure the serial port specified by the request. If the 3118 * Configure the serial port specified by the request. If the
@@ -3124,52 +3124,56 @@ static struct uart_8250_port *serial8250_find_match_or_unused(struct uart_port *
3124 * 3124 *
3125 * On success the port is ready to use and the line number is returned. 3125 * On success the port is ready to use and the line number is returned.
3126 */ 3126 */
3127int serial8250_register_port(struct uart_port *port) 3127int serial8250_register_8250_port(struct uart_8250_port *up)
3128{ 3128{
3129 struct uart_8250_port *uart; 3129 struct uart_8250_port *uart;
3130 int ret = -ENOSPC; 3130 int ret = -ENOSPC;
3131 3131
3132 if (port->uartclk == 0) 3132 if (up->port.uartclk == 0)
3133 return -EINVAL; 3133 return -EINVAL;
3134 3134
3135 mutex_lock(&serial_mutex); 3135 mutex_lock(&serial_mutex);
3136 3136
3137 uart = serial8250_find_match_or_unused(port); 3137 uart = serial8250_find_match_or_unused(&up->port);
3138 if (uart) { 3138 if (uart) {
3139 uart_remove_one_port(&serial8250_reg, &uart->port); 3139 uart_remove_one_port(&serial8250_reg, &uart->port);
3140 3140
3141 uart->port.iobase = port->iobase; 3141 uart->port.iobase = up->port.iobase;
3142 uart->port.membase = port->membase; 3142 uart->port.membase = up->port.membase;
3143 uart->port.irq = port->irq; 3143 uart->port.irq = up->port.irq;
3144 uart->port.irqflags = port->irqflags; 3144 uart->port.irqflags = up->port.irqflags;
3145 uart->port.uartclk = port->uartclk; 3145 uart->port.uartclk = up->port.uartclk;
3146 uart->port.fifosize = port->fifosize; 3146 uart->port.fifosize = up->port.fifosize;
3147 uart->port.regshift = port->regshift; 3147 uart->port.regshift = up->port.regshift;
3148 uart->port.iotype = port->iotype; 3148 uart->port.iotype = up->port.iotype;
3149 uart->port.flags = port->flags | UPF_BOOT_AUTOCONF; 3149 uart->port.flags = up->port.flags | UPF_BOOT_AUTOCONF;
3150 uart->port.mapbase = port->mapbase; 3150 uart->port.mapbase = up->port.mapbase;
3151 uart->port.private_data = port->private_data; 3151 uart->port.private_data = up->port.private_data;
3152 if (port->dev) 3152 if (up->port.dev)
3153 uart->port.dev = port->dev; 3153 uart->port.dev = up->port.dev;
3154 3154
3155 if (port->flags & UPF_FIXED_TYPE) 3155 if (up->port.flags & UPF_FIXED_TYPE)
3156 serial8250_init_fixed_type_port(uart, port->type); 3156 serial8250_init_fixed_type_port(uart, up->port.type);
3157 3157
3158 set_io_from_upio(&uart->port); 3158 set_io_from_upio(&uart->port);
3159 /* Possibly override default I/O functions. */ 3159 /* Possibly override default I/O functions. */
3160 if (port->serial_in) 3160 if (up->port.serial_in)
3161 uart->port.serial_in = port->serial_in; 3161 uart->port.serial_in = up->port.serial_in;
3162 if (port->serial_out) 3162 if (up->port.serial_out)
3163 uart->port.serial_out = port->serial_out; 3163 uart->port.serial_out = up->port.serial_out;
3164 if (port->handle_irq) 3164 if (up->port.handle_irq)
3165 uart->port.handle_irq = port->handle_irq; 3165 uart->port.handle_irq = up->port.handle_irq;
3166 /* Possibly override set_termios call */ 3166 /* Possibly override set_termios call */
3167 if (port->set_termios) 3167 if (up->port.set_termios)
3168 uart->port.set_termios = port->set_termios; 3168 uart->port.set_termios = up->port.set_termios;
3169 if (port->pm) 3169 if (up->port.pm)
3170 uart->port.pm = port->pm; 3170 uart->port.pm = up->port.pm;
3171 if (port->handle_break) 3171 if (up->port.handle_break)
3172 uart->port.handle_break = port->handle_break; 3172 uart->port.handle_break = up->port.handle_break;
3173 if (up->dl_read)
3174 uart->dl_read = up->dl_read;
3175 if (up->dl_write)
3176 uart->dl_write = up->dl_write;
3173 3177
3174 if (serial8250_isa_config != NULL) 3178 if (serial8250_isa_config != NULL)
3175 serial8250_isa_config(0, &uart->port, 3179 serial8250_isa_config(0, &uart->port,
@@ -3183,6 +3187,29 @@ int serial8250_register_port(struct uart_port *port)
3183 3187
3184 return ret; 3188 return ret;
3185} 3189}
3190EXPORT_SYMBOL(serial8250_register_8250_port);
3191
3192/**
3193 * serial8250_register_port - register a serial port
3194 * @port: serial port template
3195 *
3196 * Configure the serial port specified by the request. If the
3197 * port exists and is in use, it is hung up and unregistered
3198 * first.
3199 *
3200 * The port is then probed and if necessary the IRQ is autodetected
3201 * If this fails an error is returned.
3202 *
3203 * On success the port is ready to use and the line number is returned.
3204 */
3205int serial8250_register_port(struct uart_port *port)
3206{
3207 struct uart_8250_port up;
3208
3209 memset(&up, 0, sizeof(up));
3210 memcpy(&up.port, port, sizeof(*port));
3211 return serial8250_register_8250_port(&up);
3212}
3186EXPORT_SYMBOL(serial8250_register_port); 3213EXPORT_SYMBOL(serial8250_register_port);
3187 3214
3188/** 3215/**
diff --git a/include/linux/serial_8250.h b/include/linux/serial_8250.h
index a522fd977aad..10dbce5205af 100644
--- a/include/linux/serial_8250.h
+++ b/include/linux/serial_8250.h
@@ -69,6 +69,7 @@ enum {
69struct uart_port; 69struct uart_port;
70struct uart_8250_port; 70struct uart_8250_port;
71 71
72int serial8250_register_8250_port(struct uart_8250_port *);
72int serial8250_register_port(struct uart_port *); 73int serial8250_register_port(struct uart_port *);
73void serial8250_unregister_port(int line); 74void serial8250_unregister_port(int line);
74void serial8250_suspend_port(int line); 75void serial8250_suspend_port(int line);