]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/usb/serial/iuu_phoenix.c
tty: usb-serial krefs
[linux-2.6-omap-h63xx.git] / drivers / usb / serial / iuu_phoenix.c
index 7fee53441c24f14ff00e3968a8118fa05208a843..53710aa7eadd96d7c6f1e535d513465815a7bceb 100644 (file)
@@ -98,10 +98,10 @@ static int iuu_alloc_buf(struct iuu_private *priv)
        priv->writebuf = kzalloc(256, GFP_KERNEL);
        if (!priv->buf || !priv->dbgbuf || !priv->writebuf) {
                iuu_free_buf(priv);
-               dbg("%s problem allocation buffer", __FUNCTION__);
+               dbg("%s problem allocation buffer", __func__);
                return -ENOMEM;
        }
-       dbg("%s - Privates buffers allocation success", __FUNCTION__);
+       dbg("%s - Privates buffers allocation success", __func__);
        return 0;
 }
 
@@ -109,7 +109,7 @@ static int iuu_startup(struct usb_serial *serial)
 {
        struct iuu_private *priv;
        priv = kzalloc(sizeof(struct iuu_private), GFP_KERNEL);
-       dbg("%s- priv allocation success", __FUNCTION__);
+       dbg("%s- priv allocation success", __func__);
        if (!priv)
                return -ENOMEM;
        if (iuu_alloc_buf(priv)) {
@@ -130,28 +130,29 @@ static void iuu_shutdown(struct usb_serial *serial)
        if (!port)
                return;
 
-       dbg("%s", __FUNCTION__);
+       dbg("%s", __func__);
 
        if (priv) {
                iuu_free_buf(priv);
-               dbg("%s - I will free all", __FUNCTION__);
+               dbg("%s - I will free all", __func__);
                usb_set_serial_port_data(port, NULL);
 
-               dbg("%s - priv is not anymore in port structure", __FUNCTION__);
+               dbg("%s - priv is not anymore in port structure", __func__);
                kfree(priv);
 
-               dbg("%s priv is now kfree", __FUNCTION__);
+               dbg("%s priv is now kfree", __func__);
        }
 }
 
-static int iuu_tiocmset(struct usb_serial_port *port, struct file *file,
+static int iuu_tiocmset(struct tty_struct *tty, struct file *file,
                        unsigned int set, unsigned int clear)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct iuu_private *priv = usb_get_serial_port_data(port);
        unsigned long flags;
 
        /* FIXME: locking on tiomstatus */
-       dbg("%s (%d) msg : SET = 0x%04x, CLEAR = 0x%04x ", __FUNCTION__,
+       dbg("%s (%d) msg : SET = 0x%04x, CLEAR = 0x%04x ", __func__,
            port->number, set, clear);
 
        spin_lock_irqsave(&priv->lock, flags);
@@ -159,7 +160,7 @@ static int iuu_tiocmset(struct usb_serial_port *port, struct file *file,
                priv->tiostatus = TIOCM_RTS;
 
        if (!(set & TIOCM_RTS) && priv->tiostatus == TIOCM_RTS) {
-               dbg("%s TIOCMSET RESET called !!!", __FUNCTION__);
+               dbg("%s TIOCMSET RESET called !!!", __func__);
                priv->reset = 1;
        }
        spin_unlock_irqrestore(&priv->lock, flags);
@@ -171,8 +172,9 @@ static int iuu_tiocmset(struct usb_serial_port *port, struct file *file,
  * When no card , the reader respond with TIOCM_CD
  * This is known as CD autodetect mechanism
  */
-static int iuu_tiocmget(struct usb_serial_port *port, struct file *file)
+static int iuu_tiocmget(struct tty_struct *tty, struct file *file)
 {
+       struct usb_serial_port *port = tty->driver_data;
        struct iuu_private *priv = usb_get_serial_port_data(port);
        unsigned long flags;
        int rc;
@@ -186,12 +188,12 @@ static int iuu_tiocmget(struct usb_serial_port *port, struct file *file)
 
 static void iuu_rxcmd(struct urb *urb)
 {
-       struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
+       struct usb_serial_port *port = urb->context;
        int result;
-       dbg("%s - enter", __FUNCTION__);
+       dbg("%s - enter", __func__);
 
        if (urb->status) {
-               dbg("%s - urb->status = %d", __FUNCTION__, urb->status);
+               dbg("%s - urb->status = %d", __func__, urb->status);
                /* error stop all */
                return;
        }
@@ -211,7 +213,7 @@ static int iuu_reset(struct usb_serial_port *port, u8 wt)
        struct iuu_private *priv = usb_get_serial_port_data(port);
        int result;
        char *buf_ptr = port->write_urb->transfer_buffer;
-       dbg("%s - enter", __FUNCTION__);
+       dbg("%s - enter", __func__);
 
        /* Prepare the reset sequence */
 
@@ -240,19 +242,19 @@ static int iuu_reset(struct usb_serial_port *port, u8 wt)
  */
 static void iuu_update_status_callback(struct urb *urb)
 {
-       struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
+       struct usb_serial_port *port = urb->context;
        struct iuu_private *priv = usb_get_serial_port_data(port);
        u8 *st;
-       dbg("%s - enter", __FUNCTION__);
+       dbg("%s - enter", __func__);
 
        if (urb->status) {
-               dbg("%s - urb->status = %d", __FUNCTION__, urb->status);
+               dbg("%s - urb->status = %d", __func__, urb->status);
                /* error stop all */
                return;
        }
 
        st = urb->transfer_buffer;
-       dbg("%s - enter", __FUNCTION__);
+       dbg("%s - enter", __func__);
        if (urb->actual_length == 1) {
                switch (st[0]) {
                case 0x1:
@@ -270,11 +272,11 @@ static void iuu_update_status_callback(struct urb *urb)
 
 static void iuu_status_callback(struct urb *urb)
 {
-       struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
+       struct usb_serial_port *port = urb->context;
        int result;
-       dbg("%s - enter", __FUNCTION__);
+       dbg("%s - enter", __func__);
 
-       dbg("%s - urb->status = %d", __FUNCTION__, urb->status);
+       dbg("%s - urb->status = %d", __func__, urb->status);
        usb_fill_bulk_urb(port->read_urb, port->serial->dev,
                          usb_rcvbulkpipe(port->serial->dev,
                                          port->bulk_in_endpointAddress),
@@ -287,7 +289,7 @@ static int iuu_status(struct usb_serial_port *port)
 {
        int result;
 
-       dbg("%s - enter", __FUNCTION__);
+       dbg("%s - enter", __func__);
 
        memset(port->write_urb->transfer_buffer, IUU_GET_STATE_REGISTER, 1);
        usb_fill_bulk_urb(port->write_urb, port->serial->dev,
@@ -306,7 +308,7 @@ static int bulk_immediate(struct usb_serial_port *port, u8 *buf, u8 count)
        struct usb_serial *serial = port->serial;
        int actual = 0;
 
-       dbg("%s - enter", __FUNCTION__);
+       dbg("%s - enter", __func__);
 
        /* send the data out the bulk port */
 
@@ -316,11 +318,10 @@ static int bulk_immediate(struct usb_serial_port *port, u8 *buf, u8 count)
                                         port->bulk_out_endpointAddress), buf,
                         count, &actual, HZ * 1);
 
-       if (status != IUU_OPERATION_OK) {
-               dbg("%s - error = %2x", __FUNCTION__, status);
-       } else {
-               dbg("%s - write OK !", __FUNCTION__);
-       }
+       if (status != IUU_OPERATION_OK)
+               dbg("%s - error = %2x", __func__, status);
+       else
+               dbg("%s - write OK !", __func__);
        return status;
 }
 
@@ -330,7 +331,7 @@ static int read_immediate(struct usb_serial_port *port, u8 *buf, u8 count)
        struct usb_serial *serial = port->serial;
        int actual = 0;
 
-       dbg("%s - enter", __FUNCTION__);
+       dbg("%s - enter", __func__);
 
        /* send the data out the bulk port */
 
@@ -340,12 +341,10 @@ static int read_immediate(struct usb_serial_port *port, u8 *buf, u8 count)
                                         port->bulk_in_endpointAddress), buf,
                         count, &actual, HZ * 1);
 
-       if (status != IUU_OPERATION_OK) {
-               dbg("%s - error = %2x", __FUNCTION__, status);
-       } else {
-               dbg("%s - read OK !", __FUNCTION__);
-       }
-
+       if (status != IUU_OPERATION_OK)
+               dbg("%s - error = %2x", __func__, status);
+       else
+               dbg("%s - read OK !", __func__);
        return status;
 }
 
@@ -358,7 +357,7 @@ static int iuu_led(struct usb_serial_port *port, unsigned int R,
        if (!buf)
                return -ENOMEM;
 
-       dbg("%s - enter", __FUNCTION__);
+       dbg("%s - enter", __func__);
 
        buf[0] = IUU_SET_LED;
        buf[1] = R & 0xFF;
@@ -371,9 +370,9 @@ static int iuu_led(struct usb_serial_port *port, unsigned int R,
        status = bulk_immediate(port, buf, 8);
        kfree(buf);
        if (status != IUU_OPERATION_OK)
-               dbg("%s - led error status = %2x", __FUNCTION__, status);
+               dbg("%s - led error status = %2x", __func__, status);
        else
-               dbg("%s - led OK !", __FUNCTION__);
+               dbg("%s - led OK !", __func__);
        return IUU_OPERATION_OK;
 }
 
@@ -392,7 +391,7 @@ static void iuu_rgbf_fill_buffer(u8 *buf, u8 r1, u8 r2, u8 g1, u8 g2, u8 b1,
 
 static void iuu_led_activity_on(struct urb *urb)
 {
-       struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
+       struct usb_serial_port *port = urb->context;
        int result;
        char *buf_ptr = port->write_urb->transfer_buffer;
        *buf_ptr++ = IUU_SET_LED;
@@ -413,7 +412,7 @@ static void iuu_led_activity_on(struct urb *urb)
 
 static void iuu_led_activity_off(struct urb *urb)
 {
-       struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
+       struct usb_serial_port *port = urb->context;
        int result;
        char *buf_ptr = port->write_urb->transfer_buffer;
        if (xmas == 1) {
@@ -451,7 +450,7 @@ static int iuu_clk(struct usb_serial_port *port, int dwFrq)
        unsigned int P2 = 0;
        int frq = (int)dwFrq;
 
-       dbg("%s - enter", __FUNCTION__);
+       dbg("%s - enter", __func__);
 
        if (frq == 0) {
                priv->buf[Count++] = IUU_UART_WRITE_I2C;
@@ -461,7 +460,7 @@ static int iuu_clk(struct usb_serial_port *port, int dwFrq)
 
                status = bulk_immediate(port, (u8 *) priv->buf, Count);
                if (status != 0) {
-                       dbg("%s - write error ", __FUNCTION__);
+                       dbg("%s - write error ", __func__);
                        return status;
                }
        } else if (frq == 3579000) {
@@ -570,7 +569,7 @@ static int iuu_clk(struct usb_serial_port *port, int dwFrq)
 
        status = bulk_immediate(port, (u8 *) priv->buf, Count);
        if (status != IUU_OPERATION_OK)
-               dbg("%s - write error ", __FUNCTION__);
+               dbg("%s - write error ", __func__);
        return status;
 }
 
@@ -581,7 +580,7 @@ static int iuu_uart_flush(struct usb_serial_port *port)
        u8 rxcmd = IUU_UART_RX;
        struct iuu_private *priv = usb_get_serial_port_data(port);
 
-       dbg("%s - enter", __FUNCTION__);
+       dbg("%s - enter", __func__);
 
        if (iuu_led(port, 0xF000, 0, 0, 0xFF) < 0)
                return -EIO;
@@ -589,65 +588,66 @@ static int iuu_uart_flush(struct usb_serial_port *port)
        for (i = 0; i < 2; i++) {
                status = bulk_immediate(port, &rxcmd, 1);
                if (status != IUU_OPERATION_OK) {
-                       dbg("%s - uart_flush_write error", __FUNCTION__);
+                       dbg("%s - uart_flush_write error", __func__);
                        return status;
                }
 
                status = read_immediate(port, &priv->len, 1);
                if (status != IUU_OPERATION_OK) {
-                       dbg("%s - uart_flush_read error", __FUNCTION__);
+                       dbg("%s - uart_flush_read error", __func__);
                        return status;
                }
 
                if (priv->len > 0) {
-                       dbg("%s - uart_flush datalen is : %i ", __FUNCTION__,
+                       dbg("%s - uart_flush datalen is : %i ", __func__,
                            priv->len);
                        status = read_immediate(port, priv->buf, priv->len);
                        if (status != IUU_OPERATION_OK) {
-                               dbg("%s - uart_flush_read error", __FUNCTION__);
+                               dbg("%s - uart_flush_read error", __func__);
                                return status;
                        }
                }
        }
-       dbg("%s - uart_flush_read OK!", __FUNCTION__);
+       dbg("%s - uart_flush_read OK!", __func__);
        iuu_led(port, 0, 0xF000, 0, 0xFF);
        return status;
 }
 
 static void read_buf_callback(struct urb *urb)
 {
-       struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
+       struct usb_serial_port *port = urb->context;
        unsigned char *data = urb->transfer_buffer;
        struct tty_struct *tty;
-       dbg("%s - urb->status = %d", __FUNCTION__, urb->status);
+       dbg("%s - urb->status = %d", __func__, urb->status);
 
        if (urb->status) {
-               dbg("%s - urb->status = %d", __FUNCTION__, urb->status);
+               dbg("%s - urb->status = %d", __func__, urb->status);
                if (urb->status == -EPROTO) {
                        /* reschedule needed */
                }
                return;
        }
 
-       dbg("%s - %i chars to write", __FUNCTION__, urb->actual_length);
-       tty = port->tty;
+       dbg("%s - %i chars to write", __func__, urb->actual_length);
+       tty = tty_port_tty_get(&port->port);
        if (data == NULL)
-               dbg("%s - data is NULL !!!", __FUNCTION__);
+               dbg("%s - data is NULL !!!", __func__);
        if (tty && urb->actual_length && data) {
                tty_insert_flip_string(tty, data, urb->actual_length);
                tty_flip_buffer_push(tty);
        }
+       tty_kref_put(tty);
        iuu_led_activity_on(urb);
 }
 
 static int iuu_bulk_write(struct usb_serial_port *port)
 {
        struct iuu_private *priv = usb_get_serial_port_data(port);
-       unsigned int flags;
+       unsigned long flags;
        int result;
        int i;
        char *buf_ptr = port->write_urb->transfer_buffer;
-       dbg("%s - enter", __FUNCTION__);
+       dbg("%s - enter", __func__);
 
        *buf_ptr++ = IUU_UART_ESC;
        *buf_ptr++ = IUU_UART_TX;
@@ -660,7 +660,7 @@ static int iuu_bulk_write(struct usb_serial_port *port)
                        sprintf(priv->dbgbuf + i*2 ,
                                "%02X", priv->writebuf[i]);
                priv->dbgbuf[priv->writelen+i*2] = 0;
-               dbg("%s - writing %i chars : %s", __FUNCTION__,
+               dbg("%s - writing %i chars : %s", __func__,
                    priv->writelen, priv->dbgbuf);
        }
        usb_fill_bulk_urb(port->write_urb, port->serial->dev,
@@ -679,7 +679,7 @@ static int iuu_bulk_write(struct usb_serial_port *port)
 static int iuu_read_buf(struct usb_serial_port *port, int len)
 {
        int result;
-       dbg("%s - enter", __FUNCTION__);
+       dbg("%s - enter", __func__);
 
        usb_fill_bulk_urb(port->read_urb, port->serial->dev,
                          usb_rcvbulkpipe(port->serial->dev,
@@ -692,30 +692,30 @@ static int iuu_read_buf(struct usb_serial_port *port, int len)
 
 static void iuu_uart_read_callback(struct urb *urb)
 {
-       struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
+       struct usb_serial_port *port = urb->context;
        struct iuu_private *priv = usb_get_serial_port_data(port);
-       unsigned int flags;
+       unsigned long flags;
        int status;
        int error = 0;
        int len = 0;
        unsigned char *data = urb->transfer_buffer;
        priv->poll++;
 
-       dbg("%s - enter", __FUNCTION__);
+       dbg("%s - enter", __func__);
 
        if (urb->status) {
-               dbg("%s - urb->status = %d", __FUNCTION__, urb->status);
+               dbg("%s - urb->status = %d", __func__, urb->status);
                /* error stop all */
                return;
        }
        if (data == NULL)
-               dbg("%s - data is NULL !!!", __FUNCTION__);
+               dbg("%s - data is NULL !!!", __func__);
 
        if (urb->actual_length == 1  && data != NULL)
                len = (int) data[0];
 
        if (urb->actual_length > 1) {
-               dbg("%s - urb->actual_length = %i", __FUNCTION__,
+               dbg("%s - urb->actual_length = %i", __func__,
                    urb->actual_length);
                error = 1;
                return;
@@ -724,7 +724,7 @@ static void iuu_uart_read_callback(struct urb *urb)
 
        if (len > 0 && error == 0) {
                dbg("%s - call read buf - len to read is %i ",
-                       __FUNCTION__, len);
+                       __func__, len);
                status = iuu_read_buf(port, len);
                return;
        }
@@ -750,17 +750,16 @@ static void iuu_uart_read_callback(struct urb *urb)
        }
        spin_unlock_irqrestore(&priv->lock, flags);
        /* if nothing to write call again rxcmd */
-       dbg("%s - rxcmd recall", __FUNCTION__);
+       dbg("%s - rxcmd recall", __func__);
        iuu_led_activity_off(urb);
-       return;
 }
 
-static int iuu_uart_write(struct usb_serial_port *port, const u8 *buf,
-                         int count)
+static int iuu_uart_write(struct tty_struct *tty, struct usb_serial_port *port,
+                         const u8 *buf, int count)
 {
        struct iuu_private *priv = usb_get_serial_port_data(port);
-       unsigned int flags;
-       dbg("%s - enter", __FUNCTION__);
+       unsigned long flags;
+       dbg("%s - enter", __func__);
 
        if (count > 256)
                return -ENOMEM;
@@ -769,26 +768,26 @@ static int iuu_uart_write(struct usb_serial_port *port, const u8 *buf,
        if (priv->writelen > 0) {
                /* buffer already filled but not commited */
                spin_unlock_irqrestore(&priv->lock, flags);
-               return (0);
+               return 0;
        }
        /* fill the buffer */
        memcpy(priv->writebuf, buf, count);
        priv->writelen = count;
        spin_unlock_irqrestore(&priv->lock, flags);
 
-       return (count);
+       return count;
 }
 
 static void read_rxcmd_callback(struct urb *urb)
 {
-       struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
+       struct usb_serial_port *port = urb->context;
        int result;
-       dbg("%s - enter", __FUNCTION__);
+       dbg("%s - enter", __func__);
 
-       dbg("%s - urb->status = %d", __FUNCTION__, urb->status);
+       dbg("%s - urb->status = %d", __func__, urb->status);
 
        if (urb->status) {
-               dbg("%s - urb->status = %d", __FUNCTION__, urb->status);
+               dbg("%s - urb->status = %d", __func__, urb->status);
                /* error stop all */
                return;
        }
@@ -799,7 +798,7 @@ static void read_rxcmd_callback(struct urb *urb)
                          port->read_urb->transfer_buffer, 256,
                          iuu_uart_read_callback, port);
        result = usb_submit_urb(port->read_urb, GFP_ATOMIC);
-       dbg("%s - submit result = %d", __FUNCTION__, result);
+       dbg("%s - submit result = %d", __func__, result);
        return;
 }
 
@@ -820,13 +819,13 @@ static int iuu_uart_on(struct usb_serial_port *port)
 
        status = bulk_immediate(port, buf, 4);
        if (status != IUU_OPERATION_OK) {
-               dbg("%s - uart_on error", __FUNCTION__);
+               dbg("%s - uart_on error", __func__);
                goto uart_enable_failed;
        }
        /*  iuu_reset() the card after iuu_uart_on() */
        status = iuu_uart_flush(port);
        if (status != IUU_OPERATION_OK)
-               dbg("%s - uart_flush error", __FUNCTION__);
+               dbg("%s - uart_flush error", __func__);
 uart_enable_failed:
        kfree(buf);
        return status;
@@ -844,7 +843,7 @@ static int iuu_uart_off(struct usb_serial_port *port)
 
        status = bulk_immediate(port, buf, 1);
        if (status != IUU_OPERATION_OK)
-               dbg("%s - uart_off error", __FUNCTION__);
+               dbg("%s - uart_off error", __func__);
 
        kfree(buf);
        return status;
@@ -938,7 +937,7 @@ static int iuu_uart_baud(struct usb_serial_port *port, u32 baud,
 
        status = bulk_immediate(port, dataout, DataCount);
        if (status != IUU_OPERATION_OK)
-               dbg("%s - uart_off error", __FUNCTION__);
+               dbg("%s - uart_off error", __func__);
        kfree(dataout);
        return status;
 }
@@ -948,7 +947,8 @@ static int set_control_lines(struct usb_device *dev, u8 value)
        return 0;
 }
 
-static void iuu_close(struct usb_serial_port *port, struct file *filp)
+static void iuu_close(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp)
 {
        /* iuu_led (port,255,0,0,0); */
        struct usb_serial *serial;
@@ -960,12 +960,12 @@ static void iuu_close(struct usb_serial_port *port, struct file *filp)
        if (!serial)
                return;
 
-       dbg("%s - port %d", __FUNCTION__, port->number);
+       dbg("%s - port %d", __func__, port->number);
 
        iuu_uart_off(port);
        if (serial->dev) {
-               if (port->tty) {
-                       c_cflag = port->tty->termios->c_cflag;
+               if (tty) {
+                       c_cflag = tty->termios->c_cflag;
                        if (c_cflag & HUPCL) {
                                /* drop DTR and RTS */
                                priv = usb_get_serial_port_data(port);
@@ -977,7 +977,7 @@ static void iuu_close(struct usb_serial_port *port, struct file *filp)
                }
                /* free writebuf */
                /* shutdown our urbs */
-               dbg("%s - shutting down urbs", __FUNCTION__);
+               dbg("%s - shutting down urbs", __func__);
                usb_kill_urb(port->write_urb);
                usb_kill_urb(port->read_urb);
                usb_kill_urb(port->interrupt_in_urb);
@@ -989,7 +989,8 @@ static void iuu_close(struct usb_serial_port *port, struct file *filp)
        }
 }
 
-static int iuu_open(struct usb_serial_port *port, struct file *filp)
+static int iuu_open(struct tty_struct *tty,
+                       struct usb_serial_port *port, struct file *filp)
 {
        struct usb_serial *serial = port->serial;
        u8 *buf;
@@ -998,7 +999,7 @@ static int iuu_open(struct usb_serial_port *port, struct file *filp)
        unsigned long flags;
        struct iuu_private *priv = usb_get_serial_port_data(port);
 
-       dbg("%s -  port %d", __FUNCTION__, port->number);
+       dbg("%s -  port %d", __func__, port->number);
        usb_clear_halt(serial->dev, port->write_urb->pipe);
        usb_clear_halt(serial->dev, port->read_urb->pipe);
 
@@ -1036,15 +1037,17 @@ static int iuu_open(struct usb_serial_port *port, struct file *filp)
 
        /* set the termios structure */
        spin_lock_irqsave(&priv->lock, flags);
-       if (!priv->termios_initialized) {
-               *(port->tty->termios) = tty_std_termios;
-               port->tty->termios->c_cflag = CLOCAL | CREAD | CS8 | B9600
-                                               | TIOCM_CTS | CSTOPB | PARENB;
-               port->tty->termios->c_lflag = 0;
-               port->tty->termios->c_oflag = 0;
-               port->tty->termios->c_iflag = 0;
+       if (tty && !priv->termios_initialized) {
+               *(tty->termios) = tty_std_termios;
+               tty->termios->c_cflag = CLOCAL | CREAD | CS8 | B9600
+                                       | TIOCM_CTS | CSTOPB | PARENB;
+               tty->termios->c_ispeed = 9600;
+               tty->termios->c_ospeed = 9600;
+               tty->termios->c_lflag = 0;
+               tty->termios->c_oflag = 0;
+               tty->termios->c_iflag = 0;
                priv->termios_initialized = 1;
-               port->tty->low_latency = 1;
+               tty->low_latency = 1;
                priv->poll = 0;
         }
        spin_unlock_irqrestore(&priv->lock, flags);
@@ -1135,7 +1138,7 @@ static int iuu_open(struct usb_serial_port *port, struct file *filp)
 
        iuu_uart_flush(port);
 
-       dbg("%s - initialization done", __FUNCTION__);
+       dbg("%s - initialization done", __func__);
 
        memset(port->write_urb->transfer_buffer, IUU_UART_RX, 1);
        usb_fill_bulk_urb(port->write_urb, port->serial->dev,
@@ -1147,11 +1150,11 @@ static int iuu_open(struct usb_serial_port *port, struct file *filp)
 
        if (result) {
                dev_err(&port->dev, "%s - failed submitting read urb,"
-                       " error %d\n", __FUNCTION__, result);
-               iuu_close(port, NULL);
+                       " error %d\n", __func__, result);
+               iuu_close(tty, port, NULL);
                return -EPROTO;
        } else {
-               dbg("%s - rxcmd OK", __FUNCTION__);
+               dbg("%s - rxcmd OK", __func__);
        }
        return result;
 }