jsm: define init function as __devinit
[safe/jmp/linux-2.6] / drivers / serial / jsm / jsm_tty.c
index 7d82370..3306963 100644 (file)
@@ -142,10 +142,10 @@ static void jsm_tty_send_xchar(struct uart_port *port, char ch)
 {
        unsigned long lock_flags;
        struct jsm_channel *channel = (struct jsm_channel *)port;
-       struct termios *termios;
+       struct ktermios *termios;
 
        spin_lock_irqsave(&port->lock, lock_flags);
-       termios = port->info->tty->termios;
+       termios = port->info->port.tty->termios;
        if (ch == termios->c_cc[VSTART])
                channel->ch_bd->bd_ops->send_start_character(channel);
 
@@ -161,6 +161,11 @@ static void jsm_tty_stop_rx(struct uart_port *port)
        channel->ch_bd->bd_ops->disable_receiver(channel);
 }
 
+static void jsm_tty_enable_ms(struct uart_port *port)
+{
+       /* Nothing needed */
+}
+
 static void jsm_tty_break(struct uart_port *port, int break_state)
 {
        unsigned long lock_flags;
@@ -180,7 +185,7 @@ static int jsm_tty_open(struct uart_port *port)
        struct jsm_board *brd;
        int rc = 0;
        struct jsm_channel *channel = (struct jsm_channel *)port;
-       struct termios *termios;
+       struct ktermios *termios;
 
        /* Get board pointer from our array of majors we have allocated */
        brd = channel->ch_bd;
@@ -194,31 +199,28 @@ static int jsm_tty_open(struct uart_port *port)
        /* Drop locks, as malloc with GFP_KERNEL can sleep */
 
        if (!channel->ch_rqueue) {
-               channel->ch_rqueue = (u8 *) kmalloc(RQUEUESIZE, GFP_KERNEL);
+               channel->ch_rqueue = kzalloc(RQUEUESIZE, GFP_KERNEL);
                if (!channel->ch_rqueue) {
                        jsm_printk(INIT, ERR, &channel->ch_bd->pci_dev,
                                "unable to allocate read queue buf");
                        return -ENOMEM;
                }
-               memset(channel->ch_rqueue, 0, RQUEUESIZE);
        }
        if (!channel->ch_equeue) {
-               channel->ch_equeue = (u8 *) kmalloc(EQUEUESIZE, GFP_KERNEL);
+               channel->ch_equeue = kzalloc(EQUEUESIZE, GFP_KERNEL);
                if (!channel->ch_equeue) {
                        jsm_printk(INIT, ERR, &channel->ch_bd->pci_dev,
                                "unable to allocate error queue buf");
                        return -ENOMEM;
                }
-               memset(channel->ch_equeue, 0, EQUEUESIZE);
        }
        if (!channel->ch_wqueue) {
-               channel->ch_wqueue = (u8 *) kmalloc(WQUEUESIZE, GFP_KERNEL);
+               channel->ch_wqueue = kzalloc(WQUEUESIZE, GFP_KERNEL);
                if (!channel->ch_wqueue) {
                        jsm_printk(INIT, ERR, &channel->ch_bd->pci_dev,
                                "unable to allocate write queue buf");
                        return -ENOMEM;
                }
-               memset(channel->ch_wqueue, 0, WQUEUESIZE);
        }
 
        channel->ch_flags &= ~(CH_OPENING);
@@ -242,7 +244,7 @@ static int jsm_tty_open(struct uart_port *port)
        channel->ch_cached_lsr = 0;
        channel->ch_stops_sent = 0;
 
-       termios = port->info->tty->termios;
+       termios = port->info->port.tty->termios;
        channel->ch_c_cflag     = termios->c_cflag;
        channel->ch_c_iflag     = termios->c_iflag;
        channel->ch_c_oflag     = termios->c_oflag;
@@ -269,13 +271,13 @@ static int jsm_tty_open(struct uart_port *port)
 static void jsm_tty_close(struct uart_port *port)
 {
        struct jsm_board *bd;
-       struct termios *ts;
+       struct ktermios *ts;
        struct jsm_channel *channel = (struct jsm_channel *)port;
 
        jsm_printk(CLOSE, INFO, &channel->ch_bd->pci_dev, "start\n");
 
        bd = channel->ch_bd;
-       ts = channel->uart_port.info->tty->termios;
+       ts = port->info->port.tty->termios;
 
        channel->ch_flags &= ~(CH_STOPI);
 
@@ -302,8 +304,8 @@ static void jsm_tty_close(struct uart_port *port)
 }
 
 static void jsm_tty_set_termios(struct uart_port *port,
-                                struct termios *termios,
-                                struct termios *old_termios)
+                                struct ktermios *termios,
+                                struct ktermios *old_termios)
 {
        unsigned long lock_flags;
        struct jsm_channel *channel = (struct jsm_channel *)port;
@@ -348,6 +350,7 @@ static struct uart_ops jsm_ops = {
        .start_tx       = jsm_tty_start_tx,
        .send_xchar     = jsm_tty_send_xchar,
        .stop_rx        = jsm_tty_stop_rx,
+       .enable_ms      = jsm_tty_enable_ms,
        .break_ctl      = jsm_tty_break,
        .startup        = jsm_tty_open,
        .shutdown       = jsm_tty_close,
@@ -364,7 +367,7 @@ static struct uart_ops jsm_ops = {
  * Init the tty subsystem.  Called once per board after board has been
  * downloaded and init'ed.
  */
-int jsm_tty_init(struct jsm_board *brd)
+int __devinit jsm_tty_init(struct jsm_board *brd)
 {
        int i;
        void __iomem *vaddr;
@@ -392,13 +395,12 @@ int jsm_tty_init(struct jsm_board *brd)
                         * Okay to malloc with GFP_KERNEL, we are not at
                         * interrupt context, and there are no locks held.
                         */
-                       brd->channels[i] = kmalloc(sizeof(struct jsm_channel), GFP_KERNEL);
+                       brd->channels[i] = kzalloc(sizeof(struct jsm_channel), GFP_KERNEL);
                        if (!brd->channels[i]) {
                                jsm_printk(CORE, ERR, &brd->pci_dev,
                                        "%s:%d Unable to allocate memory for channel struct\n",
                                                         __FILE__, __LINE__);
                        }
-                       memset(brd->channels[i], 0, sizeof(struct jsm_channel));
                }
        }
 
@@ -429,7 +431,7 @@ int jsm_tty_init(struct jsm_board *brd)
        return 0;
 }
 
-int jsm_uart_port_init(struct jsm_board *brd)
+int __devinit jsm_uart_port_init(struct jsm_board *brd)
 {
        int i;
        struct jsm_channel *ch;
@@ -452,6 +454,7 @@ int jsm_uart_port_init(struct jsm_board *brd)
                        continue;
 
                brd->channels[i]->uart_port.irq = brd->irq;
+               brd->channels[i]->uart_port.uartclk = 14745600;
                brd->channels[i]->uart_port.type = PORT_JSM;
                brd->channels[i]->uart_port.iotype = UPIO_MEM;
                brd->channels[i]->uart_port.membase = brd->re_map_membase;
@@ -503,13 +506,11 @@ void jsm_input(struct jsm_channel *ch)
 {
        struct jsm_board *bd;
        struct tty_struct *tp;
-       struct tty_ldisc *ld;
        u32 rmask;
        u16 head;
        u16 tail;
        int data_len;
        unsigned long lock_flags;
-       int flip_len = 0;
        int len = 0;
        int n = 0;
        int s = 0;
@@ -520,7 +521,7 @@ void jsm_input(struct jsm_channel *ch)
        if (!ch)
                return;
 
-       tp = ch->uart_port.info->tty;
+       tp = ch->uart_port.info->port.tty;
 
        bd = ch->ch_bd;
        if(!bd)
@@ -577,52 +578,13 @@ void jsm_input(struct jsm_channel *ch)
 
        jsm_printk(READ, INFO, &ch->ch_bd->pci_dev, "start 2\n");
 
-       /*
-        * If the rxbuf is empty and we are not throttled, put as much
-        * as we can directly into the linux TTY buffer.
-        *
-        */
-       flip_len = TTY_FLIPBUF_SIZE;
-
-       len = min(data_len, flip_len);
-       len = min(len, (N_TTY_BUF_SIZE - 1) - tp->read_cnt);
-       ld = tty_ldisc_ref(tp);
-
-       /*
-        * If the DONT_FLIP flag is on, don't flush our buffer, and act
-        * like the ld doesn't have any space to put the data right now.
-        */
-       if (test_bit(TTY_DONT_FLIP, &tp->flags))
-               len = 0;
-
-       /*
-        * If we were unable to get a reference to the ld,
-        * don't flush our buffer, and act like the ld doesn't
-        * have any space to put the data right now.
-        */
-       if (!ld) {
-               len = 0;
-       } else {
-               /*
-                * If ld doesn't have a pointer to a receive_buf function,
-                * flush the data, then act like the ld doesn't have any
-                * space to put the data right now.
-                */
-               if (!ld->receive_buf) {
-                               ch->ch_r_head = ch->ch_r_tail;
-                               len = 0;
-               }
-       }
-
-       if (len <= 0) {
+       if (data_len <= 0) {
                spin_unlock_irqrestore(&ch->ch_lock, lock_flags);
                jsm_printk(READ, INFO, &ch->ch_bd->pci_dev, "jsm_input 1\n");
-               if (ld)
-                       tty_ldisc_deref(ld);
                return;
        }
 
-       len = tty_buffer_request_room(tp, len);
+       len = tty_buffer_request_room(tp, data_len);
        n = len;
 
        /*
@@ -657,7 +619,7 @@ void jsm_input(struct jsm_channel *ch)
                                else if (*(ch->ch_equeue +tail +i) & UART_LSR_FE)
                                        tty_insert_flip_char(tp, *(ch->ch_rqueue +tail +i), TTY_FRAME);
                                else
-                               tty_insert_flip_char(tp, *(ch->ch_rqueue +tail +i), TTY_NORMAL);
+                                       tty_insert_flip_char(tp, *(ch->ch_rqueue +tail +i), TTY_NORMAL);
                        }
                } else {
                        tty_insert_flip_string(tp, ch->ch_rqueue + tail, s) ;
@@ -676,9 +638,6 @@ void jsm_input(struct jsm_channel *ch)
        /* Tell the tty layer its okay to "eat" the data now */
        tty_flip_buffer_push(tp);
 
-       if (ld)
-               tty_ldisc_deref(ld);
-
        jsm_printk(IOCTL, INFO, &ch->ch_bd->pci_dev, "finish\n");
 }