aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2012-03-05 08:52:28 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-03-08 15:48:26 -0500
commitfd2d7a6e60068779bc72029f867b51d3dc2fe0cc (patch)
treecfa68f135a001233d2cef7bfad0ca4cf684230d2
parent01bd730d92bd002adc3f3317d8e3328c629b436c (diff)
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 <jslaby@suse.cz> Cc: Tony Luck <tony.luck@intel.com> Cc: Fenghua Yu <fenghua.yu@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--arch/ia64/hp/sim/simserial.c94
1 files changed, 27 insertions, 67 deletions
diff --git a/arch/ia64/hp/sim/simserial.c b/arch/ia64/hp/sim/simserial.c
index c65c49d31e7..64ab004b476 100644
--- a/arch/ia64/hp/sim/simserial.c
+++ b/arch/ia64/hp/sim/simserial.c
@@ -49,44 +49,7 @@
49static char *serial_name = "SimSerial driver"; 49static char *serial_name = "SimSerial driver";
50static char *serial_version = "0.6"; 50static char *serial_version = "0.6";
51 51
52/* 52static struct serial_state rs_table[NR_PORTS];
53 * This has been extracted from asm/serial.h. We need one eventually but
54 * I don't know exactly what we're going to put in it so just fake one
55 * for now.
56 */
57#define BASE_BAUD ( 1843200 / 16 )
58
59#define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST)
60
61/*
62 * Most of the values here are meaningless to this particular driver.
63 * However some values must be preserved for the code (leveraged from serial.c
64 * to work correctly).
65 * port must not be 0
66 * type must not be UNKNOWN
67 * So I picked arbitrary (guess from where?) values instead
68 */
69static struct serial_state rs_table[NR_PORTS]={
70 /* UART CLK PORT IRQ FLAGS */
71 { BASE_BAUD, 0x3F8, 0, STD_COM_FLAGS, PORT_16550 } /* ttyS0 */
72};
73
74/*
75 * Just for the fun of it !
76 */
77static struct serial_uart_config uart_config[] = {
78 { "unknown", 1, 0 },
79 { "8250", 1, 0 },
80 { "16450", 1, 0 },
81 { "16550", 1, 0 },
82 { "16550A", 16, UART_CLEAR_FIFO | UART_USE_FIFO },
83 { "cirrus", 1, 0 },
84 { "ST16650", 1, UART_CLEAR_FIFO | UART_STARTECH },
85 { "ST16650V2", 32, UART_CLEAR_FIFO | UART_USE_FIFO |
86 UART_STARTECH },
87 { "TI16750", 64, UART_CLEAR_FIFO | UART_USE_FIFO},
88 { NULL, 0}
89};
90 53
91struct tty_driver *hp_simserial_driver; 54struct tty_driver *hp_simserial_driver;
92 55
@@ -592,11 +555,6 @@ static int startup(struct tty_struct *tty, struct serial_state *state)
592 goto errout; 555 goto errout;
593 } 556 }
594 557
595 if (!state->port || !state->type) {
596 set_bit(TTY_IO_ERROR, &tty->flags);
597 free_page(page);
598 goto errout;
599 }
600 if (state->xmit.buf) 558 if (state->xmit.buf)
601 free_page(page); 559 free_page(page);
602 else 560 else
@@ -725,9 +683,8 @@ static int rs_open(struct tty_struct *tty, struct file * filp)
725 683
726static inline void line_info(struct seq_file *m, struct serial_state *state) 684static inline void line_info(struct seq_file *m, struct serial_state *state)
727{ 685{
728 seq_printf(m, "%d: uart:%s port:%lX irq:%d\n", 686 seq_printf(m, "%d: uart:16550 port:3F8 irq:%d\n",
729 state->line, uart_config[state->type].name, 687 state->line, state->irq);
730 state->port, state->irq);
731} 688}
732 689
733static int rs_proc_show(struct seq_file *m, void *v) 690static int rs_proc_show(struct seq_file *m, void *v)
@@ -796,11 +753,10 @@ static const struct tty_operations hp_ops = {
796/* 753/*
797 * The serial driver boot-time initialization code! 754 * The serial driver boot-time initialization code!
798 */ 755 */
799static int __init 756static int __init simrs_init(void)
800simrs_init (void)
801{ 757{
802 int i, rc; 758 struct serial_state *state;
803 struct serial_state *state; 759 int retval;
804 760
805 if (!ia64_platform_is("hpsim")) 761 if (!ia64_platform_is("hpsim"))
806 return -ENODEV; 762 return -ENODEV;
@@ -828,29 +784,33 @@ simrs_init (void)
828 /* 784 /*
829 * Let's have a little bit of fun ! 785 * Let's have a little bit of fun !
830 */ 786 */
831 for (i = 0, state = rs_table; i < NR_PORTS; i++,state++) { 787 state = rs_table;
832 tty_port_init(&state->tport); 788 tty_port_init(&state->tport);
833 state->tport.close_delay = 0; /* XXX really 0? */ 789 state->tport.close_delay = 0; /* XXX really 0? */
790
791 retval = hpsim_get_irq(KEYBOARD_INTR);
792 if (retval < 0) {
793 printk(KERN_ERR "%s: out of interrupt vectors!\n",
794 __func__);
795 goto err_free_tty;
796 }
834 797
835 if (state->type == PORT_UNKNOWN) continue; 798 state->irq = retval;
836 799
837 if (!state->irq) { 800 /* the port is imaginary */
838 if ((rc = hpsim_get_irq(KEYBOARD_INTR)) < 0) 801 printk(KERN_INFO "ttyS%d at 0x03f8 (irq = %d) is a 16550\n",
839 panic("%s: out of interrupt vectors!\n", 802 state->line, state->irq);
840 __func__);
841 state->irq = rc;
842 }
843 803
844 printk(KERN_INFO "ttyS%d at 0x%04lx (irq = %d) is a %s\n", 804 retval = tty_register_driver(hp_simserial_driver);
845 state->line, 805 if (retval) {
846 state->port, state->irq, 806 printk(KERN_ERR "Couldn't register simserial driver\n");
847 uart_config[state->type].name); 807 goto err_free_tty;
848 } 808 }
849 809
850 if (tty_register_driver(hp_simserial_driver))
851 panic("Couldn't register simserial driver\n");
852
853 return 0; 810 return 0;
811err_free_tty:
812 put_tty_driver(hp_simserial_driver);
813 return retval;
854} 814}
855 815
856#ifndef MODULE 816#ifndef MODULE