aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty/serial
diff options
context:
space:
mode:
authorPeter Hurley <peter@hurleysoftware.com>2015-02-24 14:25:06 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-03-26 13:13:59 -0400
commit6e28157173037b779fcf90715416a21a1e5ea2f9 (patch)
tree8278114ed122fe407d4f23e0f74c321fa8bea4c2 /drivers/tty/serial
parentdf519e7bd33cf56d8a5ce357dfb94248d427b688 (diff)
serial: 8250: Separate 8250 console interface
Prepare for 8250 core split; separate shared console interface from the console definition of the universal driver. Introduce 8250 shared console interface; serial8250_console_write() and serial8250_console_setup() which decouples the console operation from the port structure storage. Rename existing serial8250_console* identifiers to univ8250_console*. Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/serial')
-rw-r--r--drivers/tty/serial/8250/8250_core.c65
1 files changed, 41 insertions, 24 deletions
diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c
index 924ee1e13828..625f81c9b55e 100644
--- a/drivers/tty/serial/8250/8250_core.c
+++ b/drivers/tty/serial/8250/8250_core.c
@@ -3222,10 +3222,9 @@ static void serial8250_console_putchar(struct uart_port *port, int ch)
3222 * 3222 *
3223 * The console_lock must be held when we get here. 3223 * The console_lock must be held when we get here.
3224 */ 3224 */
3225static void 3225static void serial8250_console_write(struct uart_8250_port *up, const char *s,
3226serial8250_console_write(struct console *co, const char *s, unsigned int count) 3226 unsigned int count)
3227{ 3227{
3228 struct uart_8250_port *up = &serial8250_ports[co->index];
3229 struct uart_port *port = &up->port; 3228 struct uart_port *port = &up->port;
3230 unsigned long flags; 3229 unsigned long flags;
3231 unsigned int ier; 3230 unsigned int ier;
@@ -3297,14 +3296,35 @@ serial8250_console_write(struct console *co, const char *s, unsigned int count)
3297 serial8250_rpm_put(up); 3296 serial8250_rpm_put(up);
3298} 3297}
3299 3298
3300static int serial8250_console_setup(struct console *co, char *options) 3299static void univ8250_console_write(struct console *co, const char *s,
3300 unsigned int count)
3301{
3302 struct uart_8250_port *up = &serial8250_ports[co->index];
3303
3304 serial8250_console_write(up, s, count);
3305}
3306
3307static int serial8250_console_setup(struct uart_8250_port *up, char *options)
3301{ 3308{
3302 struct uart_port *port; 3309 struct uart_port *port = &up->port;
3303 int baud = 9600; 3310 int baud = 9600;
3304 int bits = 8; 3311 int bits = 8;
3305 int parity = 'n'; 3312 int parity = 'n';
3306 int flow = 'n'; 3313 int flow = 'n';
3307 3314
3315 if (!port->iobase && !port->membase)
3316 return -ENODEV;
3317
3318 if (options)
3319 uart_parse_options(options, &baud, &parity, &bits, &flow);
3320
3321 return uart_set_options(port, port->cons, baud, parity, bits, flow);
3322}
3323
3324static int univ8250_console_setup(struct console *co, char *options)
3325{
3326 struct uart_8250_port *up;
3327
3308 /* 3328 /*
3309 * Check whether an invalid uart number has been specified, and 3329 * Check whether an invalid uart number has been specified, and
3310 * if so, search for the first available port that does have 3330 * if so, search for the first available port that does have
@@ -3312,18 +3332,15 @@ static int serial8250_console_setup(struct console *co, char *options)
3312 */ 3332 */
3313 if (co->index >= nr_uarts) 3333 if (co->index >= nr_uarts)
3314 co->index = 0; 3334 co->index = 0;
3315 port = &serial8250_ports[co->index].port; 3335 up = &serial8250_ports[co->index];
3316 if (!port->iobase && !port->membase) 3336 /* link port to console */
3317 return -ENODEV; 3337 up->port.cons = co;
3318
3319 if (options)
3320 uart_parse_options(options, &baud, &parity, &bits, &flow);
3321 3338
3322 return uart_set_options(port, co, baud, parity, bits, flow); 3339 return serial8250_console_setup(up, options);
3323} 3340}
3324 3341
3325/** 3342/**
3326 * serial8250_console_match - non-standard console matching 3343 * univ8250_console_match - non-standard console matching
3327 * @co: registering console 3344 * @co: registering console
3328 * @name: name from console command line 3345 * @name: name from console command line
3329 * @idx: index from console command line 3346 * @idx: index from console command line
@@ -3339,8 +3356,8 @@ static int serial8250_console_setup(struct console *co, char *options)
3339 * 3356 *
3340 * Returns 0 if console matches; otherwise non-zero to use default matching 3357 * Returns 0 if console matches; otherwise non-zero to use default matching
3341 */ 3358 */
3342static int serial8250_console_match(struct console *co, char *name, int idx, 3359static int univ8250_console_match(struct console *co, char *name, int idx,
3343 char *options) 3360 char *options)
3344{ 3361{
3345 char match[] = "uart"; /* 8250-specific earlycon name */ 3362 char match[] = "uart"; /* 8250-specific earlycon name */
3346 unsigned char iotype; 3363 unsigned char iotype;
@@ -3366,32 +3383,32 @@ static int serial8250_console_match(struct console *co, char *name, int idx,
3366 continue; 3383 continue;
3367 3384
3368 co->index = i; 3385 co->index = i;
3369 return serial8250_console_setup(co, options); 3386 return univ8250_console_setup(co, options);
3370 } 3387 }
3371 3388
3372 return -ENODEV; 3389 return -ENODEV;
3373} 3390}
3374 3391
3375static struct console serial8250_console = { 3392static struct console univ8250_console = {
3376 .name = "ttyS", 3393 .name = "ttyS",
3377 .write = serial8250_console_write, 3394 .write = univ8250_console_write,
3378 .device = uart_console_device, 3395 .device = uart_console_device,
3379 .setup = serial8250_console_setup, 3396 .setup = univ8250_console_setup,
3380 .match = serial8250_console_match, 3397 .match = univ8250_console_match,
3381 .flags = CON_PRINTBUFFER | CON_ANYTIME, 3398 .flags = CON_PRINTBUFFER | CON_ANYTIME,
3382 .index = -1, 3399 .index = -1,
3383 .data = &serial8250_reg, 3400 .data = &serial8250_reg,
3384}; 3401};
3385 3402
3386static int __init serial8250_console_init(void) 3403static int __init univ8250_console_init(void)
3387{ 3404{
3388 serial8250_isa_init_ports(); 3405 serial8250_isa_init_ports();
3389 register_console(&serial8250_console); 3406 register_console(&univ8250_console);
3390 return 0; 3407 return 0;
3391} 3408}
3392console_initcall(serial8250_console_init); 3409console_initcall(univ8250_console_init);
3393 3410
3394#define SERIAL8250_CONSOLE &serial8250_console 3411#define SERIAL8250_CONSOLE &univ8250_console
3395#else 3412#else
3396#define SERIAL8250_CONSOLE NULL 3413#define SERIAL8250_CONSOLE NULL
3397#endif 3414#endif