From fd2d7a6e60068779bc72029f867b51d3dc2fe0cc Mon Sep 17 00:00:00 2001 From: Jiri Slaby Date: Mon, 5 Mar 2012 14:52:28 +0100 Subject: [PATCH] TTY: simserial, remove static initialization We do not use any of the preinitialized rs_state members for something real. So there is no need to initialize them. At the places we used them for printing, just print the values. And since only one port is supported, get rid of the loop. This simplifies simrs_init a heap. Thus we can handle fail paths in a standard way without panicing. Signed-off-by: Jiri Slaby Cc: Tony Luck Cc: Fenghua Yu Signed-off-by: Greg Kroah-Hartman --- arch/ia64/hp/sim/simserial.c | 94 +++++++++++------------------------- 1 file changed, 27 insertions(+), 67 deletions(-) diff --git a/arch/ia64/hp/sim/simserial.c b/arch/ia64/hp/sim/simserial.c index c65c49d31e7f..64ab004b4763 100644 --- a/arch/ia64/hp/sim/simserial.c +++ b/arch/ia64/hp/sim/simserial.c @@ -49,44 +49,7 @@ static char *serial_name = "SimSerial driver"; static char *serial_version = "0.6"; -/* - * This has been extracted from asm/serial.h. We need one eventually but - * I don't know exactly what we're going to put in it so just fake one - * for now. - */ -#define BASE_BAUD ( 1843200 / 16 ) - -#define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST) - -/* - * Most of the values here are meaningless to this particular driver. - * However some values must be preserved for the code (leveraged from serial.c - * to work correctly). - * port must not be 0 - * type must not be UNKNOWN - * So I picked arbitrary (guess from where?) values instead - */ -static struct serial_state rs_table[NR_PORTS]={ - /* UART CLK PORT IRQ FLAGS */ - { BASE_BAUD, 0x3F8, 0, STD_COM_FLAGS, PORT_16550 } /* ttyS0 */ -}; - -/* - * Just for the fun of it ! - */ -static struct serial_uart_config uart_config[] = { - { "unknown", 1, 0 }, - { "8250", 1, 0 }, - { "16450", 1, 0 }, - { "16550", 1, 0 }, - { "16550A", 16, UART_CLEAR_FIFO | UART_USE_FIFO }, - { "cirrus", 1, 0 }, - { "ST16650", 1, UART_CLEAR_FIFO | UART_STARTECH }, - { "ST16650V2", 32, UART_CLEAR_FIFO | UART_USE_FIFO | - UART_STARTECH }, - { "TI16750", 64, UART_CLEAR_FIFO | UART_USE_FIFO}, - { NULL, 0} -}; +static struct serial_state rs_table[NR_PORTS]; struct tty_driver *hp_simserial_driver; @@ -592,11 +555,6 @@ static int startup(struct tty_struct *tty, struct serial_state *state) goto errout; } - if (!state->port || !state->type) { - set_bit(TTY_IO_ERROR, &tty->flags); - free_page(page); - goto errout; - } if (state->xmit.buf) free_page(page); else @@ -725,9 +683,8 @@ static int rs_open(struct tty_struct *tty, struct file * filp) static inline void line_info(struct seq_file *m, struct serial_state *state) { - seq_printf(m, "%d: uart:%s port:%lX irq:%d\n", - state->line, uart_config[state->type].name, - state->port, state->irq); + seq_printf(m, "%d: uart:16550 port:3F8 irq:%d\n", + state->line, state->irq); } static int rs_proc_show(struct seq_file *m, void *v) @@ -796,11 +753,10 @@ static const struct tty_operations hp_ops = { /* * The serial driver boot-time initialization code! */ -static int __init -simrs_init (void) +static int __init simrs_init(void) { - int i, rc; - struct serial_state *state; + struct serial_state *state; + int retval; if (!ia64_platform_is("hpsim")) return -ENODEV; @@ -828,29 +784,33 @@ simrs_init (void) /* * Let's have a little bit of fun ! */ - for (i = 0, state = rs_table; i < NR_PORTS; i++,state++) { - tty_port_init(&state->tport); - state->tport.close_delay = 0; /* XXX really 0? */ + state = rs_table; + tty_port_init(&state->tport); + state->tport.close_delay = 0; /* XXX really 0? */ + + retval = hpsim_get_irq(KEYBOARD_INTR); + if (retval < 0) { + printk(KERN_ERR "%s: out of interrupt vectors!\n", + __func__); + goto err_free_tty; + } - if (state->type == PORT_UNKNOWN) continue; + state->irq = retval; - if (!state->irq) { - if ((rc = hpsim_get_irq(KEYBOARD_INTR)) < 0) - panic("%s: out of interrupt vectors!\n", - __func__); - state->irq = rc; - } + /* the port is imaginary */ + printk(KERN_INFO "ttyS%d at 0x03f8 (irq = %d) is a 16550\n", + state->line, state->irq); - printk(KERN_INFO "ttyS%d at 0x%04lx (irq = %d) is a %s\n", - state->line, - state->port, state->irq, - uart_config[state->type].name); + retval = tty_register_driver(hp_simserial_driver); + if (retval) { + printk(KERN_ERR "Couldn't register simserial driver\n"); + goto err_free_tty; } - if (tty_register_driver(hp_simserial_driver)) - panic("Couldn't register simserial driver\n"); - return 0; +err_free_tty: + put_tty_driver(hp_simserial_driver); + return retval; } #ifndef MODULE -- 2.20.1