]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - drivers/tty/n_gsm.c
TTY: switch tty_flip_buffer_push
[karo-tx-linux.git] / drivers / tty / n_gsm.c
index dcc0430a49c8d082e0c10f97a7a68a02d65f3b18..d84dcfeadce392d36fe58835152d1908f950ad62 100644 (file)
@@ -573,6 +573,7 @@ static void gsm_send(struct gsm_mux *gsm, int addr, int cr, int control)
        int len;
        u8 cbuf[10];
        u8 ibuf[3];
+       unsigned long flags;
 
        switch (gsm->encoding) {
        case 0:
@@ -602,7 +603,9 @@ static void gsm_send(struct gsm_mux *gsm, int addr, int cr, int control)
                WARN_ON(1);
                return;
        }
+       spin_lock_irqsave(&gsm->tx_lock, flags);
        gsm->output(gsm, cbuf, len);
+       spin_unlock_irqrestore(&gsm->tx_lock, flags);
        gsm_print_packet("-->", addr, cr, control, NULL, 0);
 }
 
@@ -1067,9 +1070,9 @@ static void gsm_process_modem(struct tty_struct *tty, struct gsm_dlci *dlci,
                if ((mlines & TIOCM_CD) == 0 && (dlci->modem_rx & TIOCM_CD))
                        if (!(tty->termios.c_cflag & CLOCAL))
                                tty_hangup(tty);
-               if (brk & 0x01)
-                       tty_insert_flip_char(tty, 0, TTY_BREAK);
        }
+       if (brk & 0x01)
+               tty_insert_flip_char(&dlci->port, 0, TTY_BREAK);
        dlci->modem_rx = mlines;
 }
 
@@ -1137,7 +1140,7 @@ static void gsm_control_modem(struct gsm_mux *gsm, u8 *data, int clen)
 
 static void gsm_control_rls(struct gsm_mux *gsm, u8 *data, int clen)
 {
-       struct tty_struct *tty;
+       struct tty_port *port;
        unsigned int addr = 0 ;
        u8 bits;
        int len = clen;
@@ -1160,19 +1163,18 @@ static void gsm_control_rls(struct gsm_mux *gsm, u8 *data, int clen)
        bits = *dp;
        if ((bits & 1) == 0)
                return;
-       /* See if we have an uplink tty */
-       tty = tty_port_tty_get(&gsm->dlci[addr]->port);
 
-       if (tty) {
-               if (bits & 2)
-                       tty_insert_flip_char(tty, 0, TTY_OVERRUN);
-               if (bits & 4)
-                       tty_insert_flip_char(tty, 0, TTY_PARITY);
-               if (bits & 8)
-                       tty_insert_flip_char(tty, 0, TTY_FRAME);
-               tty_flip_buffer_push(tty);
-               tty_kref_put(tty);
-       }
+       port = &gsm->dlci[addr]->port;
+
+       if (bits & 2)
+               tty_insert_flip_char(port, 0, TTY_OVERRUN);
+       if (bits & 4)
+               tty_insert_flip_char(port, 0, TTY_PARITY);
+       if (bits & 8)
+               tty_insert_flip_char(port, 0, TTY_FRAME);
+
+       tty_flip_buffer_push(port);
+
        gsm_control_reply(gsm, CMD_RLS, data, clen);
 }
 
@@ -1545,36 +1547,37 @@ static void gsm_dlci_data(struct gsm_dlci *dlci, u8 *data, int clen)
 {
        /* krefs .. */
        struct tty_port *port = &dlci->port;
-       struct tty_struct *tty = tty_port_tty_get(port);
+       struct tty_struct *tty;
        unsigned int modem = 0;
        int len = clen;
 
        if (debug & 16)
-               pr_debug("%d bytes for tty %p\n", len, tty);
-       if (tty) {
-               switch (dlci->adaption)  {
-               /* Unsupported types */
-               /* Packetised interruptible data */
-               case 4:
-                       break;
-               /* Packetised uininterruptible voice/data */
-               case 3:
-                       break;
-               /* Asynchronous serial with line state in each frame */
-               case 2:
-                       while (gsm_read_ea(&modem, *data++) == 0) {
-                               len--;
-                               if (len == 0)
-                                       return;
-                       }
+               pr_debug("%d bytes for tty\n", len);
+       switch (dlci->adaption)  {
+       /* Unsupported types */
+       /* Packetised interruptible data */
+       case 4:
+               break;
+       /* Packetised uininterruptible voice/data */
+       case 3:
+               break;
+       /* Asynchronous serial with line state in each frame */
+       case 2:
+               while (gsm_read_ea(&modem, *data++) == 0) {
+                       len--;
+                       if (len == 0)
+                               return;
+               }
+               tty = tty_port_tty_get(port);
+               if (tty) {
                        gsm_process_modem(tty, dlci, modem, clen);
-               /* Line state will go via DLCI 0 controls only */
-               case 1:
-               default:
-                       tty_insert_flip_string(tty, data, len);
-                       tty_flip_buffer_push(tty);
+                       tty_kref_put(tty);
                }
-               tty_kref_put(tty);
+       /* Line state will go via DLCI 0 controls only */
+       case 1:
+       default:
+               tty_insert_flip_string(port, data, len);
+               tty_flip_buffer_push(port);
        }
 }