return;
        }
 
-       tty_insert_flip_string(tty, buffer, len);
+       tty_insert_flip_string(&cs->port, buffer, len);
        tty_flip_buffer_push(tty);
        tty_kref_put(tty);
 }
 
  * of the mapping (di,ch)<->minor, happen during the sleep? --he
  */
 int
-isdn_readbchan_tty(int di, int channel, struct tty_struct *tty, int cisco_hack)
+isdn_readbchan_tty(int di, int channel, struct tty_port *port, int cisco_hack)
 {
-       struct tty_port *port = tty->port;
        int count;
        int count_pull;
        int count_put;
                        }
                        count_put = count_pull;
                        if (count_put > 1)
-                               tty_insert_flip_string(tty, skb->data, count_put - 1);
+                               tty_insert_flip_string(port, skb->data, count_put - 1);
                        last = skb->data[count_put - 1];
                        len -= count_put;
 #ifdef CONFIG_ISDN_AUDIO
 
 extern void isdn_unexclusive_channel(int di, int ch);
 extern int isdn_getnum(char **);
 extern int isdn_readbchan(int, int, u_char *, u_char *, int, wait_queue_head_t *);
-extern int isdn_readbchan_tty(int, int, struct tty_struct *, int);
+extern int isdn_readbchan_tty(int, int, struct tty_port *, int);
 extern int isdn_get_free_channel(int, int, int, int, int, char *);
 extern int isdn_writebuf_skb_stub(int, int, int, struct sk_buff *);
 extern int register_isdn(isdn_if *i);
 
        } else {
 #endif
                if (len > 1)
-                       tty_insert_flip_string(tty, skb->data, len - 1);
+                       tty_insert_flip_string(port, skb->data, len - 1);
                last = skb->data[len - 1];
 #ifdef CONFIG_ISDN_AUDIO
        }
                        if (info->mcr & UART_MCR_RTS) {
                                /* CISCO AsyncPPP Hack */
                                if (!(info->emu.mdmreg[REG_CPPP] & BIT_CPPP))
-                                       r = isdn_readbchan_tty(info->isdn_driver, info->isdn_channel, tty, 0);
+                                       r = isdn_readbchan_tty(info->isdn_driver, info->isdn_channel, &info->port, 0);
                                else
-                                       r = isdn_readbchan_tty(info->isdn_driver, info->isdn_channel, tty, 1);
+                                       r = isdn_readbchan_tty(info->isdn_driver, info->isdn_channel, &info->port, 1);
                                if (r)
                                        tty_flip_buffer_push(tty);
                        } else
 
                                tty_kref_put(tty);
                                return -1;
                        }
-                       curr_write_len =  tty_insert_flip_string
-                               (tty, urb->transfer_buffer +
-                                serial->curr_rx_urb_offset,
-                                write_length_remaining);
+                       curr_write_len = tty_insert_flip_string(&serial->port,
+                               urb->transfer_buffer + serial->curr_rx_urb_offset,
+                               write_length_remaining);
                        serial->curr_rx_urb_offset += curr_write_len;
                        write_length_remaining -= curr_write_len;
                        tty_flip_buffer_push(tty);
 
                                        count++;
                                } else
                                        count -= 2;
-                               tty_insert_flip_string(tty, raw->inbuf, count);
+                               tty_insert_flip_string(&raw->port, raw->inbuf,
+                                               count);
                                tty_flip_buffer_push(tty);
                                break;
                        }
 
                    (strncmp((const char *) buf + count - 2, "^n", 2) &&
                     strncmp((const char *) buf + count - 2, "\252n", 2))) {
                        /* add the auto \n */
-                       tty_insert_flip_string(tty, buf, count);
+                       tty_insert_flip_string(&sclp_port, buf, count);
                        tty_insert_flip_char(&sclp_port, '\n', TTY_NORMAL);
                } else
-                       tty_insert_flip_string(tty, buf, count - 2);
+                       tty_insert_flip_string(&sclp_port, buf, count - 2);
                tty_flip_buffer_push(tty);
                break;
        }
 
                /* Send input to line discipline */
                buffer++;
                count--;
-               tty_insert_flip_string(tty, buffer, count);
+               tty_insert_flip_string(&sclp_vt220_port, buffer, count);
                tty_flip_buffer_push(tty);
                break;
        }
 
                                size -= n;
                        }
 
-                       count = tty_insert_flip_string(tty, packet, size);
+                       count = tty_insert_flip_string(&port->port, packet, size);
                        if (count)
                                do_push = true;
                        if (count != size) {
 
                                        size_t num_chars = (4 <= inbound_len ? 4 : inbound_len);
                                        pr_debug("  incoming data: 0x%08x (pushing %zu)\n", emudat, num_chars);
                                        inbound_len -= num_chars;
-                                       tty_insert_flip_string(tty, (unsigned char *)&emudat, num_chars);
+                                       tty_insert_flip_string(&port, (unsigned char *)&emudat, num_chars);
                                        tty_flip_buffer_push(tty);
                                }
                        }
 
                 */
 
                /* Pass the received data to the tty layer. */
-               ret = tty_insert_flip_string(ttys, buffer, len);
+               ret = tty_insert_flip_string(&bc->port, buffer, len);
 
                /* 'ret' is the number of bytes that the TTY layer accepted.
                 * If it's not equal to 'len', then it means the buffer is
 
                got = hvc_get_chars(unit_address,
                                &buf[0],
                                HVCS_BUFF_LEN);
-               tty_insert_flip_string(tty, buf, got);
+               tty_insert_flip_string(&hvcsd->port, buf, got);
        }
 
        /* Give the TTY time to process the data we just sent. */
 
        }
        mutex_unlock(&tty->ipw_tty_mutex);
 
-       work = tty_insert_flip_string(linux_tty, data, length);
+       work = tty_insert_flip_string(&tty->port, data, length);
 
        if (work != length)
                printk(KERN_DEBUG IPWIRELESS_PCCARD_NAME
 
                /* Line state will go via DLCI 0 controls only */
                case 1:
                default:
-                       tty_insert_flip_string(tty, data, len);
+                       tty_insert_flip_string(port, data, len);
                        tty_flip_buffer_push(tty);
                }
                tty_kref_put(tty);
 
        struct tty_struct *tty = tty_port_tty_get(&port->port);
        int i, ret;
 
-       if (unlikely(!tty)) {
-               DBG1("tty not open for port: %d?", index);
-               return 1;
-       }
-
        read_mem32((u32 *) &size, addr, 4);
        /*  DBG1( "%d bytes port: %d", size, index); */
 
-       if (test_bit(TTY_THROTTLED, &tty->flags)) {
+       if (tty && test_bit(TTY_THROTTLED, &tty->flags)) {
                DBG1("No room in tty, don't read data, don't ack interrupt, "
                        "disable interrupt");
 
                        tty_insert_flip_char(&port->port, buf[0], TTY_NORMAL);
                        size = 0;
                } else if (size < RECEIVE_BUF_MAX) {
-                       size -= tty_insert_flip_string(tty, (char *) buf, size);
+                       size -= tty_insert_flip_string(&port->port,
+                                       (char *)buf, size);
                } else {
-                       i = tty_insert_flip_string(tty, \
-                                               (char *) buf, RECEIVE_BUF_MAX);
+                       i = tty_insert_flip_string(&port->port,
+                                       (char *)buf, RECEIVE_BUF_MAX);
                        size -= i;
                        offset += i;
                }
 
 
        if (c > 0) {
                /* Stuff the data into the input queue of the other end */
-               c = tty_insert_flip_string(to, buf, c);
+               c = tty_insert_flip_string(to->port, buf, c);
                /* And shovel */
                if (c) {
                        tty_flip_buffer_push(to);
 
                               u32 pending, bool use_buf_b,
                               bool readfifo)
 {
-       struct tty_struct *tty = uap->port.state->port.tty;
+       struct tty_port *port = &uap->port.state->port;
+       struct tty_struct *tty = port->tty;
        struct pl011_sgbuf *sgbuf = use_buf_b ?
                &uap->dmarx.sgbuf_b : &uap->dmarx.sgbuf_a;
        struct device *dev = uap->dmarx.chan->device->dev;
                 * Note that tty_insert_flip_buf() tries to take as many chars
                 * as it can.
                 */
-               dma_count = tty_insert_flip_string(uap->port.state->port.tty,
-                                                  sgbuf->buf, pending);
+               dma_count = tty_insert_flip_string(port, sgbuf->buf, pending);
 
                /* Return buffer to device */
                dma_sync_sg_for_device(dev, &sgbuf->sg, 1, DMA_FROM_DEVICE);
 
 static void atmel_rx_from_dma(struct uart_port *port)
 {
        struct atmel_uart_port *atmel_port = to_atmel_uart_port(port);
-       struct tty_struct *tty = port->state->port.tty;
+       struct tty_port *tport = &port->state->port;
+       struct tty_struct *tty = tport->tty;
        struct atmel_dma_buffer *pdc;
        int rx_idx = atmel_port->pdc_rx_idx;
        unsigned int head;
                         */
                        count = head - tail;
 
-                       tty_insert_flip_string(tty, pdc->buf + pdc->ofs, count);
+                       tty_insert_flip_string(tport, pdc->buf + pdc->ofs,
+                                               count);
 
                        dma_sync_single_for_device(port->dev, pdc->dma_addr,
                                        pdc->dma_size, DMA_FROM_DEVICE);
 
        while ((buffer = info->first_recv_buffer) != NULL) {
                unsigned int count = buffer->length;
 
-               tty_insert_flip_string(tty, buffer->buffer, count);
+               tty_insert_flip_string(&info->port, buffer->buffer, count);
                info->recv_cnt -= count;
 
                if (count == buffer->length) {
 
                /* Block copy all but the last byte as this may have status */
                if (count > 0) {
                        first = icom_port->recv_buf[offset];
-                       tty_insert_flip_string(tty, icom_port->recv_buf + offset, count - 1);
+                       tty_insert_flip_string(port, icom_port->recv_buf + offset, count - 1);
                }
 
                icount = &icom_port->uart_port.icount;
 
        struct tty_struct *tty = tty_port_tty_get(&ifx_dev->tty_port);
        if (!tty)
                return;
-       tty_insert_flip_string(tty, chars, size);
+       tty_insert_flip_string(&ifx_dev->tty_port, chars, size);
        tty_flip_buffer_push(tty);
        tty_kref_put(tty);
 }
 
        read_count = do_read(the_port, ch, MAX_CHARS);
        if (read_count > 0) {
                flip = 1;
-               read_room = tty_insert_flip_string(tty, ch, read_count);
+               read_room = tty_insert_flip_string(&state->port, ch,
+                               read_count);
                the_port->icount.rx += read_count;
        }
        spin_unlock_irqrestore(&the_port->lock, pflags);
 
                icount = &the_port->icount;
                read_count = do_read(the_port, ch, request_count);
                if (read_count > 0) {
-                       tty_insert_flip_string(tty, ch, read_count);
+                       tty_insert_flip_string(&state->port, ch, read_count);
                        icount->rx += read_count;
                }
        }
 
                                        tty_insert_flip_char(port, *(ch->ch_rqueue +tail +i), TTY_NORMAL);
                        }
                } else {
-                       tty_insert_flip_string(tp, ch->ch_rqueue + tail, s) ;
+                       tty_insert_flip_string(port, ch->ch_rqueue + tail, s);
                }
                tail += s;
                n -= s;
 
        struct hsu_dma_buffer *dbuf = &up->rxbuf;
        struct hsu_dma_chan *chan = up->rxc;
        struct uart_port *port = &up->port;
-       struct tty_struct *tty = port->state->port.tty;
+       struct tty_port *tport = &port->state->port;
+       struct tty_struct *tty = tport->tty;
        int count;
 
        if (!tty)
         * explicitly set tail to 0. So head will
         * always be greater than tail.
         */
-       tty_insert_flip_string(tty, dbuf->buf, count);
+       tty_insert_flip_string(tport, dbuf->buf, count);
        port->icount.rx += count;
 
        dma_sync_single_for_device(up->port.dev, dbuf->dma_addr,
 
        for (r = 0; w; r += usable, w -= usable) {
                usable = tty_buffer_request_room(tport, w);
                if (usable) {
-                       tty_insert_flip_string(tty, buf + r, usable);
+                       tty_insert_flip_string(tport, buf + r, usable);
                        port->icount.rx += usable;
                }
        }
 
                        port->icount.frame++;
 
                /* TODO: handle sysrq */
-               tty_insert_flip_string(tty, (char *) &c,
+               tty_insert_flip_string(tport, (char *)&c,
                                       (count > 4) ? 4 : count);
                count -= 4;
        }
 
        rx_count = msm_hs_read(uport, UARTDM_RX_TOTAL_SNAP_ADDR);
 
        if (0 != (uport->read_status_mask & CREAD)) {
-               retval = tty_insert_flip_string(tty, msm_uport->rx.buffer,
+               retval = tty_insert_flip_string(port, msm_uport->rx.buffer,
                                                rx_count);
                BUG_ON(retval != rx_count);
        }
 
 static void dma_rx_callback(void *arg)
 {
        struct mxs_auart_port *s = (struct mxs_auart_port *) arg;
-       struct tty_struct *tty = s->port.state->port.tty;
+       struct tty_port *port = &s->port.state->port;
+       struct tty_struct *tty = port->tty;
        int count;
        u32 stat;
 
                        AUART_STAT_PERR | AUART_STAT_FERR);
 
        count = stat & AUART_STAT_RXCOUNT_MASK;
-       tty_insert_flip_string(tty, s->rx_dma_buf, count);
+       tty_insert_flip_string(port, s->rx_dma_buf, count);
 
        writel(stat, s->port.membase + AUART_STAT);
        tty_flip_buffer_push(tty);
 
 static int push_rx(struct eg20t_port *priv, const unsigned char *buf,
                   int size)
 {
-       struct uart_port *port;
+       struct uart_port *port = &priv->port;
+       struct tty_port *tport = &port->state->port;
        struct tty_struct *tty;
 
-       port = &priv->port;
-       tty = tty_port_tty_get(&port->state->port);
+       tty = tty_port_tty_get(tport);
        if (!tty) {
                dev_dbg(priv->port.dev, "%s:tty is busy now", __func__);
                return -EBUSY;
        }
 
-       tty_insert_flip_string(tty, buf, size);
+       tty_insert_flip_string(tport, buf, size);
        tty_flip_buffer_push(tty);
        tty_kref_put(tty);
 
        if (!room)
                return room;
 
-       tty_insert_flip_string(tty, sg_virt(&priv->sg_rx), size);
+       tty_insert_flip_string(tport, sg_virt(&priv->sg_rx), size);
 
        port->icount.rx += room;
        tty_kref_put(tty);
 
        }
 }
 
-static int receive_chars_getchar(struct uart_port *port, struct tty_struct *tty)
+static int receive_chars_getchar(struct uart_port *port)
 {
        int saw_console_brk = 0;
        int limit = 10000;
        return saw_console_brk;
 }
 
-static int receive_chars_read(struct uart_port *port, struct tty_struct *tty)
+static int receive_chars_read(struct uart_port *port)
 {
        int saw_console_brk = 0;
        int limit = 10000;
                for (i = 0; i < bytes_read; i++)
                        uart_handle_sysrq_char(port, con_read_page[i]);
 
-               if (tty == NULL)
+               if (port->state == NULL)
                        continue;
 
                port->icount.rx += bytes_read;
 
-               tty_insert_flip_string(tty, con_read_page, bytes_read);
+               tty_insert_flip_string(&port->state->port, con_read_page,
+                               bytes_read);
        }
 
        return saw_console_brk;
 
 struct sunhv_ops {
        void (*transmit_chars)(struct uart_port *port, struct circ_buf *xmit);
-       int (*receive_chars)(struct uart_port *port, struct tty_struct *tty);
+       int (*receive_chars)(struct uart_port *port);
 };
 
 static struct sunhv_ops bychar_ops = {
        if (port->state != NULL)                /* Unopened serial console */
                tty = port->state->port.tty;
 
-       if (sunhv_ops->receive_chars(port, tty))
+       if (sunhv_ops->receive_chars(port))
                sun_do_break();
 
        return tty;
 
        if (!tty)
                return;
 
-       tty_insert_flip_string(tty, urb->transfer_buffer, urb->actual_length);
+       tty_insert_flip_string(&acm->port, urb->transfer_buffer,
+                       urb->actual_length);
        tty_flip_buffer_push(tty);
 
        tty_kref_put(tty);
 
 
                req = list_first_entry(queue, struct usb_request, list);
 
-               /* discard data if tty was closed */
-               if (!tty)
-                       goto recycle;
-
                /* leave data queued if tty was rx throttled */
-               if (test_bit(TTY_THROTTLED, &tty->flags))
+               if (tty && test_bit(TTY_THROTTLED, &tty->flags))
                        break;
 
                switch (req->status) {
                                size -= n;
                        }
 
-                       count = tty_insert_flip_string(tty, packet, size);
+                       count = tty_insert_flip_string(&port->port, packet,
+                                       size);
                        if (count)
                                do_push = true;
                        if (count != size) {
                        }
                        port->n_read = 0;
                }
-recycle:
+
                list_move(&req->list, &port->read_pool);
                port->read_started--;
        }
 
        return 0;
 }
 
-static int aircable_process_packet(struct tty_struct *tty,
-                       struct usb_serial_port *port, int has_headers,
-                       char *packet, int len)
+static int aircable_process_packet(struct usb_serial_port *port,
+               int has_headers, char *packet, int len)
 {
        if (has_headers) {
                len -= HCI_HEADER_LENGTH;
                return 0;
        }
 
-       tty_insert_flip_string(tty, packet, len);
+       tty_insert_flip_string(&port->port, packet, len);
 
        return len;
 }
        count = 0;
        for (i = 0; i < urb->actual_length; i += HCI_COMPLETE_FRAME) {
                len = min_t(int, urb->actual_length - i, HCI_COMPLETE_FRAME);
-               count += aircable_process_packet(tty, port, has_headers,
+               count += aircable_process_packet(port, has_headers,
                                                                &data[i], len);
        }
 
 
                return;
        }
        if (urb->actual_length) {
-               tty_insert_flip_string(tty, data, urb->actual_length);
+               tty_insert_flip_string(&port->port, data, urb->actual_length);
                tty_flip_buffer_push(tty);
        }
        tty_kref_put(tty);
 
 
        if (tty && actual_length) {
                usb_serial_debug_data(&port->dev, __func__, actual_length, data);
-               tty_insert_flip_string(tty, data, actual_length);
+               tty_insert_flip_string(&port->port, data, actual_length);
                tty_flip_buffer_push(tty);
        }
        tty_kref_put(tty);
 
           stuff like 3G modems, so shortcircuit it in the 99.9999999% of cases
           where the USB serial is not a console anyway */
        if (!port->port.console || !port->sysrq)
-               tty_insert_flip_string(tty, ch, urb->actual_length);
+               tty_insert_flip_string(&port->port, ch, urb->actual_length);
        else {
                for (i = 0; i < urb->actual_length; i++, ch++) {
                        if (!usb_serial_handle_sysrq_char(port, *ch))
 
                                unsigned char *buffer, __u16 bufferLength);
 static void process_rcvd_status(struct edgeport_serial *edge_serial,
                                __u8 byte2, __u8 byte3);
-static void edge_tty_recv(struct device *dev, struct tty_struct *tty,
+static void edge_tty_recv(struct usb_serial_port *port, struct tty_struct *tty,
                                unsigned char *data, int length);
 static void handle_new_msr(struct edgeport_port *edge_port, __u8 newMsr);
 static void handle_new_lsr(struct edgeport_port *edge_port, __u8 lsrData,
                                        if (tty) {
                                                dev_dbg(dev, "%s - Sending %d bytes to TTY for port %d\n",
                                                        __func__, rxLen, edge_serial->rxPort);
-                                               edge_tty_recv(&edge_serial->serial->dev->dev, tty, buffer, rxLen);
+                                               edge_tty_recv(edge_port->port, tty, buffer, rxLen);
                                                tty_kref_put(tty);
                                        }
                                        edge_port->icount.rx += rxLen;
  * edge_tty_recv
  *     this function passes data on to the tty flip buffer
  *****************************************************************************/
-static void edge_tty_recv(struct device *dev, struct tty_struct *tty,
+static void edge_tty_recv(struct usb_serial_port *port, struct tty_struct *tty,
                                        unsigned char *data, int length)
 {
        int cnt;
 
-       cnt = tty_insert_flip_string(tty, data, length);
+       cnt = tty_insert_flip_string(&port->port, data, length);
        if (cnt < length) {
-               dev_err(dev, "%s - dropping data, %d bytes lost\n",
+               dev_err(&port->dev, "%s - dropping data, %d bytes lost\n",
                                __func__, length - cnt);
        }
        data += cnt;
                struct tty_struct *tty =
                                tty_port_tty_get(&edge_port->port->port);
                if (tty) {
-                       edge_tty_recv(&edge_port->port->dev, tty, &data, 1);
+                       edge_tty_recv(edge_port->port, tty, &data, 1);
                        tty_kref_put(tty);
                }
        }
 
 static bool ignore_cpu_rev;
 static int default_uart_mode;          /* RS232 */
 
-static void edge_tty_recv(struct device *dev, struct tty_struct *tty,
+static void edge_tty_recv(struct usb_serial_port *port, struct tty_struct *tty,
                          unsigned char *data, int length);
 
 static void stop_read(struct edgeport_port *edge_port);
        if (lsr_data) {
                tty = tty_port_tty_get(&edge_port->port->port);
                if (tty) {
-                       edge_tty_recv(&edge_port->port->dev, tty, &data, 1);
+                       edge_tty_recv(edge_port->port, tty, &data, 1);
                        tty_kref_put(tty);
                }
        }
                        dev_dbg(dev, "%s - close pending, dropping data on the floor\n",
                                                                __func__);
                else
-                       edge_tty_recv(dev, tty, data, urb->actual_length);
+                       edge_tty_recv(edge_port->port, tty, data,
+                                       urb->actual_length);
                edge_port->icount.rx += urb->actual_length;
        }
        tty_kref_put(tty);
                dev_err(dev, "%s - usb_submit_urb failed with result %d\n", __func__, retval);
 }
 
-static void edge_tty_recv(struct device *dev, struct tty_struct *tty,
+static void edge_tty_recv(struct usb_serial_port *port, struct tty_struct *tty,
                                        unsigned char *data, int length)
 {
        int queued;
 
-       queued = tty_insert_flip_string(tty, data, length);
+       queued = tty_insert_flip_string(&port->port, data, length);
        if (queued < length)
-               dev_err(dev, "%s - dropping data, %d bytes lost\n",
+               dev_err(&port->dev, "%s - dropping data, %d bytes lost\n",
                        __func__, length - queued);
        tty_flip_buffer_push(tty);
 }
 
        tty = tty_port_tty_get(&port->port);
        if (!tty)
                return;
-       tty_insert_flip_string(tty, data + 1, urb->actual_length - 1);
+       tty_insert_flip_string(&port->port, data + 1, urb->actual_length - 1);
        tty_flip_buffer_push(tty);
        tty_kref_put(tty);
 }
 
        if (data == NULL)
                dev_dbg(&port->dev, "%s - data is NULL !!!\n", __func__);
        if (tty && urb->actual_length && data) {
-               tty_insert_flip_string(tty, data, urb->actual_length);
+               tty_insert_flip_string(&port->port, data, urb->actual_length);
                tty_flip_buffer_push(tty);
        }
        tty_kref_put(tty);
 
 
                tty = tty_port_tty_get(&port->port);
                if (tty && urb->actual_length) {
-                       tty_insert_flip_string(tty, data, urb->actual_length);
+                       tty_insert_flip_string(&port->port, data,
+                                       urb->actual_length);
                        tty_flip_buffer_push(tty);
                }
                tty_kref_put(tty);
                /* 0x80 bit is error flag */
                if ((data[0] & 0x80) == 0) {
                        /* no error on any byte */
-                       tty_insert_flip_string(tty, data + 1,
+                       tty_insert_flip_string(&port->port, data + 1,
                                                urb->actual_length - 1);
                } else {
                        /* some bytes had errors, every byte has status */
                   otherwise looks like usa26 data format */
 
                if (p_priv->baud > 57600)
-                       tty_insert_flip_string(tty, data, urb->actual_length);
+                       tty_insert_flip_string(&port->port, data,
+                                       urb->actual_length);
                else {
                        /* 0x80 bit is error flag */
                        if ((data[0] & 0x80) == 0) {
 
                tty = tty_port_tty_get(&port->port);
                 /* rest of message is rx data */
                if (tty && urb->actual_length) {
-                       tty_insert_flip_string(tty, data + 1,
+                       tty_insert_flip_string(&port->port, data + 1,
                                                urb->actual_length - 1);
                        tty_flip_buffer_push(tty);
                }
 
                len = urb->actual_length - KLSI_HDR_LEN;
        }
 
-       tty_insert_flip_string(tty, data + KLSI_HDR_LEN, len);
+       tty_insert_flip_string(&port->port, data + KLSI_HDR_LEN, len);
        tty_flip_buffer_push(tty);
        tty_kref_put(tty);
 }
 
                */
                /* END DEBUG */
 
-               tty_insert_flip_string(tty, data, urb->actual_length);
+               tty_insert_flip_string(&port->port, data, urb->actual_length);
                tty_flip_buffer_push(tty);
        }
        tty_kref_put(tty);
 
                if (urb->actual_length) {
                        tty = tty_port_tty_get(&port->port);
                        if (tty) {
-                               tty_insert_flip_string(tty, data,
+                               tty_insert_flip_string(&port->port, data,
                                                urb->actual_length);
                                tty_flip_buffer_push(tty);
                        }
 
        tty = tty_port_tty_get(&port->port);
        if (tty && urb->actual_length) {
                /* Loop through the data copying each byte to the tty layer. */
-               tty_insert_flip_string(tty, data, urb->actual_length);
+               tty_insert_flip_string(&port->port, data, urb->actual_length);
 
                /* Force the data to the tty layer. */
                tty_flip_buffer_push(tty);
 
 
        tty = tty_port_tty_get(&port->port);
        if (tty && urb->actual_length) {
-               tty_insert_flip_string(tty, data, urb->actual_length);
+               tty_insert_flip_string(&port->port, data, urb->actual_length);
                tty_flip_buffer_push(tty);
        }
        tty_kref_put(tty);
 
        usb_serial_debug_data(&port->dev, __func__, urb->actual_length, data);
 
        if (urb->actual_length) {
-               tty = tty_port_tty_get(&mos7840_port->port->port);
+               struct tty_port *tport = &mos7840_port->port->port;
+               tty = tty_port_tty_get(tport);
                if (tty) {
-                       tty_insert_flip_string(tty, data, urb->actual_length);
+                       tty_insert_flip_string(tport, data, urb->actual_length);
                        tty_flip_buffer_push(tty);
                        tty_kref_put(tty);
                }
 
 
        tty = tty_port_tty_get(&port->port);
        if (tty && urb->actual_length) {
-               tty_insert_flip_string(tty, data, urb->actual_length);
+               tty_insert_flip_string(&port->port, data, urb->actual_length);
                tty_flip_buffer_push(tty);
        }
        tty_kref_put(tty);
 
        if (urb->actual_length && header->oh_len) {
                struct tty_struct *tty = tty_port_tty_get(&port->port);
                if (tty) {
-                       tty_insert_flip_string(tty, data + OMNINET_DATAOFFSET,
-                                                       header->oh_len);
+                       tty_insert_flip_string(&port->port,
+                                       data + OMNINET_DATAOFFSET,
+                                       header->oh_len);
                        tty_flip_buffer_push(tty);
                        tty_kref_put(tty);
                }
 
        if (!tty)
                return;
 
-       tty_insert_flip_string(tty, buf, len);
+       tty_insert_flip_string(&port->port, buf, len);
        tty_flip_buffer_push(tty);
        tty_kref_put(tty);
 }
 
 
        tty = tty_port_tty_get(&port->port);
        if (tty != NULL && urb->actual_length > 0) {
-               tty_insert_flip_string(tty, data, urb->actual_length);
+               tty_insert_flip_string(&port->port, data, urb->actual_length);
                tty_flip_buffer_push(tty);
        }
        tty_kref_put(tty);
 
                                break;
                        case QT2_CONTROL_ESCAPE:
                                tty_buffer_request_room(&port->port, 2);
-                               tty_insert_flip_string(tty, ch, 2);
+                               tty_insert_flip_string(&port->port, ch, 2);
                                i += 2;
                                escapeflag = true;
                                break;
                                continue;
                }
 
-               if (tty) {
-                       tty_buffer_request_room(&port->port, 1);
-                       tty_insert_flip_string(tty, ch, 1);
-               }
+               tty_buffer_request_room(&port->port, 1);
+               tty_insert_flip_string(&port->port, ch, 1);
        }
 
        if (tty) {
 
        dev_info(&urb->dev->dev, "%s - actual: %d\n", __func__, actual_length);
        length = actual_length;
 out:
-       tty_insert_flip_string(tty, data, length);
+       tty_insert_flip_string(&port->port, data, length);
        tty_flip_buffer_push(tty);
 err:
        tty_kref_put(tty);
 
                if (urb->actual_length) {
                        tty = tty_port_tty_get(&port->port);
                        if (tty) {
-                               tty_insert_flip_string(tty, data,
+                               tty_insert_flip_string(&port->port, data,
                                        urb->actual_length);
                                tty_flip_buffer_push(tty);
 
 
                 */
                tty = tty_port_tty_get(&port->port);
                if (tty) {
-                       tty_insert_flip_string(tty, &data[1], data_length);
+                       tty_insert_flip_string(&port->port, &data[1],
+                                       data_length);
                        tty_flip_buffer_push(tty);
                        tty_kref_put(tty);
                }
 
 static void ti_bulk_in_callback(struct urb *urb);
 static void ti_bulk_out_callback(struct urb *urb);
 
-static void ti_recv(struct device *dev, struct tty_struct *tty,
+static void ti_recv(struct usb_serial_port *port, struct tty_struct *tty,
        unsigned char *data, int length);
 static void ti_send(struct ti_port *tport);
 static int ti_set_mcr(struct ti_port *tport, unsigned int mcr);
                                dev_dbg(dev, "%s - port closed, dropping data\n",
                                        __func__);
                        else
-                               ti_recv(&urb->dev->dev, tty,
-                                               urb->transfer_buffer,
+                               ti_recv(port, tty, urb->transfer_buffer,
                                                urb->actual_length);
                        spin_lock(&tport->tp_lock);
                        tport->tp_icount.rx += urb->actual_length;
 }
 
 
-static void ti_recv(struct device *dev, struct tty_struct *tty,
+static void ti_recv(struct usb_serial_port *port, struct tty_struct *tty,
        unsigned char *data, int length)
 {
        int cnt;
 
        do {
-               cnt = tty_insert_flip_string(tty, data, length);
+               cnt = tty_insert_flip_string(&port->port, data, length);
                if (cnt < length) {
-                       dev_err(dev, "%s - dropping data, %d bytes lost\n",
+                       dev_err(&port->dev, "%s - dropping data, %d bytes lost\n",
                                                __func__, length - cnt);
                        if (cnt == 0)
                                break;
 
                tty = tty_port_tty_get(&port->port);
                if (tty) {
                        if (urb->actual_length) {
-                               tty_insert_flip_string(tty, data,
+                               tty_insert_flip_string(&port->port, data,
                                                urb->actual_length);
                                tty_flip_buffer_push(tty);
                        } else
 
        return tty_insert_flip_string_flags(port, &ch, &flag, 1);
 }
 
-static inline int tty_insert_flip_string(struct tty_struct *tty, const unsigned char *chars, size_t size)
+static inline int tty_insert_flip_string(struct tty_port *port,
+               const unsigned char *chars, size_t size)
 {
-       return tty_insert_flip_string_fixed_flag(tty->port, chars, TTY_NORMAL, size);
+       return tty_insert_flip_string_fixed_flag(port, chars, TTY_NORMAL, size);
 }
 
 #endif /* _LINUX_TTY_FLIP_H */
 
 
        BT_DBG("dlc %p tty %p len %d", dlc, tty, skb->len);
 
-       tty_insert_flip_string(tty, skb->data, skb->len);
+       tty_insert_flip_string(&dev->port, skb->data, skb->len);
        tty_flip_buffer_push(tty);
 
        kfree_skb(skb);
        rfcomm_dlc_lock(dev->dlc);
 
        while ((skb = skb_dequeue(&dev->pending))) {
-               inserted += tty_insert_flip_string(tty, skb->data, skb->len);
+               inserted += tty_insert_flip_string(&dev->port, skb->data,
+                               skb->len);
                kfree_skb(skb);
        }
 
 
         * Use flip buffer functions since the code may be called from interrupt
         * context
         */
-       tty_insert_flip_string(tty, skb->data, skb->len);
+       tty_insert_flip_string(&self->port, skb->data, skb->len);
        tty_flip_buffer_push(tty);
        tty_kref_put(tty);