USB: remove unnecessary type casting of urb->context
[linux-2.6.git] / drivers / usb / serial / pl2303.c
index 9c18173..c605fb6 100644 (file)
@@ -1,14 +1,14 @@
 /*
  * Prolific PL2303 USB to serial adaptor driver
  *
- * Copyright (C) 2001-2004 Greg Kroah-Hartman (greg@kroah.com)
+ * Copyright (C) 2001-2007 Greg Kroah-Hartman (greg@kroah.com)
  * Copyright (C) 2003 IBM Corp.
  *
  * Original driver for 2.2.x by anonymous
  *
- *     This program is free software; you can redistribute it and/or modify
- *     it under the terms of the GNU General Public License as published by
- *     the Free Software Foundation; either version 2 of the License.
+ *     This program is free software; you can redistribute it and/or
+ *     modify it under the terms of the GNU General Public License version
+ *     2 as published by the Free Software Foundation.
  *
  * See Documentation/usb/usb-serial.txt for more information on using this driver
  *
@@ -55,7 +55,9 @@ static struct usb_device_id id_table [] = {
        { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_DCU11) },
        { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_RSAQ3) },
        { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_PHAROS) },
+       { USB_DEVICE(PL2303_VENDOR_ID, PL2303_PRODUCT_ID_ALDIGA) },
        { USB_DEVICE(IODATA_VENDOR_ID, IODATA_PRODUCT_ID) },
+       { USB_DEVICE(IODATA_VENDOR_ID, IODATA_PRODUCT_ID_RSAQ5) },
        { USB_DEVICE(ATEN_VENDOR_ID, ATEN_PRODUCT_ID) },
        { USB_DEVICE(ATEN_VENDOR_ID2, ATEN_PRODUCT_ID) },
        { USB_DEVICE(ELCOM_VENDOR_ID, ELCOM_PRODUCT_ID) },
@@ -64,6 +66,7 @@ static struct usb_device_id id_table [] = {
        { USB_DEVICE(ITEGNO_VENDOR_ID, ITEGNO_PRODUCT_ID_2080) },
        { USB_DEVICE(MA620_VENDOR_ID, MA620_PRODUCT_ID) },
        { USB_DEVICE(RATOC_VENDOR_ID, RATOC_PRODUCT_ID) },
+       { USB_DEVICE(RATOC_VENDOR_ID, RATOC_PRODUCT_ID_USB60F) },
        { USB_DEVICE(TRIPP_VENDOR_ID, TRIPP_PRODUCT_ID) },
        { USB_DEVICE(RADIOSHACK_VENDOR_ID, RADIOSHACK_PRODUCT_ID) },
        { USB_DEVICE(DCU10_VENDOR_ID, DCU10_PRODUCT_ID) },
@@ -73,6 +76,7 @@ static struct usb_device_id id_table [] = {
        { USB_DEVICE(SIEMENS_VENDOR_ID, SIEMENS_PRODUCT_ID_SX1) },
        { USB_DEVICE(SIEMENS_VENDOR_ID, SIEMENS_PRODUCT_ID_X65) },
        { USB_DEVICE(SIEMENS_VENDOR_ID, SIEMENS_PRODUCT_ID_X75) },
+       { USB_DEVICE(SIEMENS_VENDOR_ID, SIEMENS_PRODUCT_ID_EF81) },
        { USB_DEVICE(SYNTECH_VENDOR_ID, SYNTECH_PRODUCT_ID) },
        { USB_DEVICE(NOKIA_CA42_VENDOR_ID, NOKIA_CA42_PRODUCT_ID) },
        { USB_DEVICE(CA_42_CA42_VENDOR_ID, CA_42_CA42_PRODUCT_ID) },
@@ -82,7 +86,10 @@ static struct usb_device_id id_table [] = {
        { USB_DEVICE(DATAPILOT_U2_VENDOR_ID, DATAPILOT_U2_PRODUCT_ID) },
        { USB_DEVICE(BELKIN_VENDOR_ID, BELKIN_PRODUCT_ID) },
        { USB_DEVICE(ALCOR_VENDOR_ID, ALCOR_PRODUCT_ID) },
-       { USB_DEVICE(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_ID) },
+       { USB_DEVICE(WS002IN_VENDOR_ID, WS002IN_PRODUCT_ID) },
+       { USB_DEVICE(COREGA_VENDOR_ID, COREGA_PRODUCT_ID) },
+       { USB_DEVICE(HL340_VENDOR_ID, HL340_PRODUCT_ID) },
+       { USB_DEVICE(YCCABLE_VENDOR_ID, YCCABLE_PRODUCT_ID) },
        { }                                     /* Terminating entry */
 };
 
@@ -93,7 +100,10 @@ static struct usb_driver pl2303_driver = {
        .probe =        usb_serial_probe,
        .disconnect =   usb_serial_disconnect,
        .id_table =     id_table,
+       .suspend =      usb_serial_suspend,
+       .resume =       usb_serial_resume,
        .no_dynamic_id =        1,
+       .supports_autosuspend = 1,
 };
 
 #define SET_LINE_REQUEST_TYPE          0x21
@@ -159,7 +169,7 @@ static struct pl2303_buf *pl2303_buf_alloc(unsigned int size)
        if (size == 0)
                return NULL;
 
-       pb = (struct pl2303_buf *)kmalloc(sizeof(struct pl2303_buf), GFP_KERNEL);
+       pb = kmalloc(sizeof(struct pl2303_buf), GFP_KERNEL);
        if (pb == NULL)
                return NULL;
 
@@ -306,12 +316,39 @@ static unsigned int pl2303_buf_get(struct pl2303_buf *pb, char *buf,
        return count;
 }
 
+static int pl2303_vendor_read(__u16 value, __u16 index,
+               struct usb_serial *serial, unsigned char *buf)
+{
+       int res = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0),
+                       VENDOR_READ_REQUEST, VENDOR_READ_REQUEST_TYPE,
+                       value, index, buf, 1, 100);
+       dbg("0x%x:0x%x:0x%x:0x%x  %d - %x", VENDOR_READ_REQUEST_TYPE,
+                       VENDOR_READ_REQUEST, value, index, res, buf[0]);
+       return res;
+}
+
+static int pl2303_vendor_write(__u16 value, __u16 index,
+               struct usb_serial *serial)
+{
+       int res = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
+                       VENDOR_WRITE_REQUEST, VENDOR_WRITE_REQUEST_TYPE,
+                       value, index, NULL, 0, 100);
+       dbg("0x%x:0x%x:0x%x:0x%x  %d", VENDOR_WRITE_REQUEST_TYPE,
+                       VENDOR_WRITE_REQUEST, value, index, res);
+       return res;
+}
+
 static int pl2303_startup(struct usb_serial *serial)
 {
        struct pl2303_private *priv;
        enum pl2303_type type = type_0;
+       unsigned char *buf;
        int i;
 
+       buf = kmalloc(10, GFP_KERNEL);
+       if (buf == NULL)
+               return -ENOMEM;
+
        if (serial->dev->descriptor.bDeviceClass == 0x02)
                type = type_0;
        else if (serial->dev->descriptor.bMaxPacketSize0 == 0x40)
@@ -336,9 +373,27 @@ static int pl2303_startup(struct usb_serial *serial)
                priv->type = type;
                usb_set_serial_port_data(serial->port[i], priv);
        }
+
+       pl2303_vendor_read(0x8484, 0, serial, buf);
+       pl2303_vendor_write(0x0404, 0, serial);
+       pl2303_vendor_read(0x8484, 0, serial, buf);
+       pl2303_vendor_read(0x8383, 0, serial, buf);
+       pl2303_vendor_read(0x8484, 0, serial, buf);
+       pl2303_vendor_write(0x0404, 1, serial);
+       pl2303_vendor_read(0x8484, 0, serial, buf);
+       pl2303_vendor_read(0x8383, 0, serial, buf);
+       pl2303_vendor_write(0, 1, serial);
+       pl2303_vendor_write(1, 0, serial);
+       if (type == HX)
+               pl2303_vendor_write(2, 0x44, serial);
+       else
+               pl2303_vendor_write(2, 0x24, serial);
+
+       kfree(buf);
        return 0;
 
 cleanup:
+       kfree(buf);
        for (--i; i>=0; --i) {
                priv = usb_get_serial_port_data(serial->port[i]);
                pl2303_buf_free(priv->buf);
@@ -355,7 +410,7 @@ static int set_control_lines(struct usb_device *dev, u8 value)
        retval = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
                                 SET_CONTROL_REQUEST, SET_CONTROL_REQUEST_TYPE,
                                 value, 0, NULL, 0, 100);
-       dbg("%s - value = %d, retval = %d", __FUNCTION__, value, retval);
+       dbg("%s - value = %d, retval = %d", __func__, value, retval);
        return retval;
 }
 
@@ -365,7 +420,7 @@ static void pl2303_send(struct usb_serial_port *port)
        struct pl2303_private *priv = usb_get_serial_port_data(port);
        unsigned long flags;
 
-       dbg("%s - port %d", __FUNCTION__, port->number);
+       dbg("%s - port %d", __func__, port->number);
 
        spin_lock_irqsave(&priv->lock, flags);
 
@@ -386,7 +441,7 @@ static void pl2303_send(struct usb_serial_port *port)
 
        spin_unlock_irqrestore(&priv->lock, flags);
 
-       usb_serial_debug_data(debug, &port->dev, __FUNCTION__, count,
+       usb_serial_debug_data(debug, &port->dev, __func__, count,
                              port->write_urb->transfer_buffer);
 
        port->write_urb->transfer_buffer_length = count;
@@ -394,7 +449,7 @@ static void pl2303_send(struct usb_serial_port *port)
        result = usb_submit_urb(port->write_urb, GFP_ATOMIC);
        if (result) {
                dev_err(&port->dev, "%s - failed submitting write urb,"
-                       " error %d\n", __FUNCTION__, result);
+                       " error %d\n", __func__, result);
                priv->write_urb_in_use = 0;
                // TODO: reschedule pl2303_send
        }
@@ -408,7 +463,7 @@ static int pl2303_write(struct usb_serial_port *port, const unsigned char *buf,
        struct pl2303_private *priv = usb_get_serial_port_data(port);
        unsigned long flags;
 
-       dbg("%s - port %d, %d bytes", __FUNCTION__, port->number, count);
+       dbg("%s - port %d, %d bytes", __func__, port->number, count);
 
        if (!count)
                return count;
@@ -428,13 +483,13 @@ static int pl2303_write_room(struct usb_serial_port *port)
        int room = 0;
        unsigned long flags;
 
-       dbg("%s - port %d", __FUNCTION__, port->number);
+       dbg("%s - port %d", __func__, port->number);
 
        spin_lock_irqsave(&priv->lock, flags);
        room = pl2303_buf_space_avail(priv->buf);
        spin_unlock_irqrestore(&priv->lock, flags);
 
-       dbg("%s - returns %d", __FUNCTION__, room);
+       dbg("%s - returns %d", __func__, room);
        return room;
 }
 
@@ -444,18 +499,18 @@ static int pl2303_chars_in_buffer(struct usb_serial_port *port)
        int chars = 0;
        unsigned long flags;
 
-       dbg("%s - port %d", __FUNCTION__, port->number);
+       dbg("%s - port %d", __func__, port->number);
 
        spin_lock_irqsave(&priv->lock, flags);
        chars = pl2303_buf_data_avail(priv->buf);
        spin_unlock_irqrestore(&priv->lock, flags);
 
-       dbg("%s - returns %d", __FUNCTION__, chars);
+       dbg("%s - returns %d", __func__, chars);
        return chars;
 }
 
 static void pl2303_set_termios(struct usb_serial_port *port,
-                              struct termios *old_termios)
+                              struct ktermios *old_termios)
 {
        struct usb_serial *serial = port->serial;
        struct pl2303_private *priv = usb_get_serial_port_data(port);
@@ -466,36 +521,33 @@ static void pl2303_set_termios(struct usb_serial_port *port,
        int i;
        u8 control;
 
-       dbg("%s -  port %d", __FUNCTION__, port->number);
-
-       if ((!port->tty) || (!port->tty->termios)) {
-               dbg("%s - no tty structures", __FUNCTION__);
-               return;
-       }
+       dbg("%s -  port %d", __func__, port->number);
 
        spin_lock_irqsave(&priv->lock, flags);
        if (!priv->termios_initialized) {
                *(port->tty->termios) = tty_std_termios;
                port->tty->termios->c_cflag = B9600 | CS8 | CREAD |
                                              HUPCL | CLOCAL;
+               port->tty->termios->c_ispeed = 9600;
+               port->tty->termios->c_ospeed = 9600;
                priv->termios_initialized = 1;
        }
        spin_unlock_irqrestore(&priv->lock, flags);
 
+       /* The PL2303 is reported to lose bytes if you change
+          serial settings even to the same values as before. Thus
+          we actually need to filter in this specific case */
+
+       if (!tty_termios_hw_change(port->tty->termios, old_termios))
+               return;
+
        cflag = port->tty->termios->c_cflag;
-       /* check that they really want us to change something */
-       if (old_termios) {
-               if ((cflag == old_termios->c_cflag) &&
-                   (RELEVANT_IFLAG(port->tty->termios->c_iflag) ==
-                    RELEVANT_IFLAG(old_termios->c_iflag))) {
-                       dbg("%s - nothing to change...", __FUNCTION__);
-                       return;
-               }
-       }
 
        buf = kzalloc(7, GFP_KERNEL);
        if (!buf) {
-               dev_err(&port->dev, "%s - out of memory.\n", __FUNCTION__);
+               dev_err(&port->dev, "%s - out of memory.\n", __func__);
+               /* Report back no change occurred */
+               *port->tty->termios = *old_termios;
                return;
        }
 
@@ -513,33 +565,11 @@ static void pl2303_set_termios(struct usb_serial_port *port,
                        default:
                        case CS8:       buf[6] = 8;     break;
                }
-               dbg("%s - data bits = %d", __FUNCTION__, buf[6]);
+               dbg("%s - data bits = %d", __func__, buf[6]);
        }
 
-       baud = 0;
-       switch (cflag & CBAUD) {
-               case B0:        baud = 0;       break;
-               case B75:       baud = 75;      break;
-               case B150:      baud = 150;     break;
-               case B300:      baud = 300;     break;
-               case B600:      baud = 600;     break;
-               case B1200:     baud = 1200;    break;
-               case B1800:     baud = 1800;    break;
-               case B2400:     baud = 2400;    break;
-               case B4800:     baud = 4800;    break;
-               case B9600:     baud = 9600;    break;
-               case B19200:    baud = 19200;   break;
-               case B38400:    baud = 38400;   break;
-               case B57600:    baud = 57600;   break;
-               case B115200:   baud = 115200;  break;
-               case B230400:   baud = 230400;  break;
-               case B460800:   baud = 460800;  break;
-               default:
-                       dev_err(&port->dev, "pl2303 driver does not support"
-                               " the baudrate requested (fix it)\n");
-                       break;
-       }
-       dbg("%s - baud = %d", __FUNCTION__, baud);
+       baud = tty_get_baud_rate(port->tty);;
+       dbg("%s - baud = %d", __func__, baud);
        if (baud) {
                buf[0] = baud & 0xff;
                buf[1] = (baud >> 8) & 0xff;
@@ -552,10 +582,10 @@ static void pl2303_set_termios(struct usb_serial_port *port,
        /* For reference buf[4]=2 is 2 stop bits */
        if (cflag & CSTOPB) {
                buf[4] = 2;
-               dbg("%s - stop bits = 2", __FUNCTION__);
+               dbg("%s - stop bits = 2", __func__);
        } else {
                buf[4] = 0;
-               dbg("%s - stop bits = 1", __FUNCTION__);
+               dbg("%s - stop bits = 1", __func__);
        }
 
        if (cflag & PARENB) {
@@ -566,14 +596,14 @@ static void pl2303_set_termios(struct usb_serial_port *port,
                /* For reference buf[5]=4 is space parity */
                if (cflag & PARODD) {
                        buf[5] = 1;
-                       dbg("%s - parity = odd", __FUNCTION__);
+                       dbg("%s - parity = odd", __func__);
                } else {
                        buf[5] = 2;
-                       dbg("%s - parity = even", __FUNCTION__);
+                       dbg("%s - parity = even", __func__);
                }
        } else {
                buf[5] = 0;
-               dbg("%s - parity = none", __FUNCTION__);
+               dbg("%s - parity = none", __func__);
        }
 
        i = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
@@ -605,19 +635,18 @@ static void pl2303_set_termios(struct usb_serial_port *port,
             buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6]);
 
        if (cflag & CRTSCTS) {
-               __u16 index;
                if (priv->type == HX)
-                       index = 0x61;
+                       pl2303_vendor_write(0x0, 0x61, serial);
                else
-                       index = 0x41;
-               i = usb_control_msg(serial->dev,
-                                   usb_sndctrlpipe(serial->dev, 0),
-                                   VENDOR_WRITE_REQUEST,
-                                   VENDOR_WRITE_REQUEST_TYPE,
-                                   0x0, index, NULL, 0, 100);
-               dbg("0x40:0x1:0x0:0x%x  %d", index, i);
+                       pl2303_vendor_write(0x0, 0x41, serial);
+       } else {
+               pl2303_vendor_write(0x0, 0x0, serial);
        }
 
+       /* FIXME: Need to read back resulting baud rate */
+       if (baud)
+               tty_encode_baud_rate(port->tty, baud, baud);
+
        kfree(buf);
 }
 
@@ -630,7 +659,7 @@ static void pl2303_close(struct usb_serial_port *port, struct file *filp)
        long timeout;
        wait_queue_t wait;
 
-       dbg("%s - port %d", __FUNCTION__, port->number);
+       dbg("%s - port %d", __func__, port->number);
 
        /* wait for data to drain from the buffer */
        spin_lock_irqsave(&priv->lock, flags);
@@ -641,7 +670,7 @@ static void pl2303_close(struct usb_serial_port *port, struct file *filp)
                set_current_state(TASK_INTERRUPTIBLE);
                if (pl2303_buf_data_avail(priv->buf) == 0 ||
                    timeout == 0 || signal_pending(current) ||
-                   !usb_get_intfdata(port->serial->interface)) /* disconnect */
+                   port->serial->disconnected)
                        break;
                spin_unlock_irqrestore(&priv->lock, flags);
                timeout = schedule_timeout(timeout);
@@ -668,7 +697,7 @@ static void pl2303_close(struct usb_serial_port *port, struct file *filp)
        schedule_timeout_interruptible(timeout);
 
        /* 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);
@@ -687,56 +716,22 @@ static void pl2303_close(struct usb_serial_port *port, struct file *filp)
 
 static int pl2303_open(struct usb_serial_port *port, struct file *filp)
 {
-       struct termios tmp_termios;
+       struct ktermios tmp_termios;
        struct usb_serial *serial = port->serial;
        struct pl2303_private *priv = usb_get_serial_port_data(port);
-       unsigned char *buf;
        int result;
 
-       dbg("%s -  port %d", __FUNCTION__, port->number);
+       dbg("%s -  port %d", __func__, port->number);
 
        if (priv->type != HX) {
                usb_clear_halt(serial->dev, port->write_urb->pipe);
                usb_clear_halt(serial->dev, port->read_urb->pipe);
-       }
-
-       buf = kmalloc(10, GFP_KERNEL);
-       if (buf==NULL)
-               return -ENOMEM;
-
-#define FISH(a,b,c,d)                                                          \
-       result=usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev,0),     \
-                              b, a, c, d, buf, 1, 100);                        \
-       dbg("0x%x:0x%x:0x%x:0x%x  %d - %x",a,b,c,d,result,buf[0]);
-
-#define SOUP(a,b,c,d)                                                          \
-       result=usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev,0),     \
-                              b, a, c, d, NULL, 0, 100);                       \
-       dbg("0x%x:0x%x:0x%x:0x%x  %d",a,b,c,d,result);
-
-       FISH (VENDOR_READ_REQUEST_TYPE, VENDOR_READ_REQUEST, 0x8484, 0);
-       SOUP (VENDOR_WRITE_REQUEST_TYPE, VENDOR_WRITE_REQUEST, 0x0404, 0);
-       FISH (VENDOR_READ_REQUEST_TYPE, VENDOR_READ_REQUEST, 0x8484, 0);
-       FISH (VENDOR_READ_REQUEST_TYPE, VENDOR_READ_REQUEST, 0x8383, 0);
-       FISH (VENDOR_READ_REQUEST_TYPE, VENDOR_READ_REQUEST, 0x8484, 0);
-       SOUP (VENDOR_WRITE_REQUEST_TYPE, VENDOR_WRITE_REQUEST, 0x0404, 1);
-       FISH (VENDOR_READ_REQUEST_TYPE, VENDOR_READ_REQUEST, 0x8484, 0);
-       FISH (VENDOR_READ_REQUEST_TYPE, VENDOR_READ_REQUEST, 0x8383, 0);
-       SOUP (VENDOR_WRITE_REQUEST_TYPE, VENDOR_WRITE_REQUEST, 0, 1);
-       SOUP (VENDOR_WRITE_REQUEST_TYPE, VENDOR_WRITE_REQUEST, 1, 0);
-
-       if (priv->type == HX) {
-               /* HX chip */
-               SOUP (VENDOR_WRITE_REQUEST_TYPE, VENDOR_WRITE_REQUEST, 2, 0x44);
-               /* reset upstream data pipes */
-               SOUP (VENDOR_WRITE_REQUEST_TYPE, VENDOR_WRITE_REQUEST, 8, 0);
-               SOUP (VENDOR_WRITE_REQUEST_TYPE, VENDOR_WRITE_REQUEST, 9, 0);
        } else {
-               SOUP (VENDOR_WRITE_REQUEST_TYPE, VENDOR_WRITE_REQUEST, 2, 0x24);
+               /* reset upstream data pipes */
+               pl2303_vendor_write(8, 0, serial);
+               pl2303_vendor_write(9, 0, serial);
        }
 
-       kfree(buf);
-
        /* Setup termios */
        if (port->tty) {
                pl2303_set_termios(port, &tmp_termios);
@@ -744,22 +739,22 @@ static int pl2303_open(struct usb_serial_port *port, struct file *filp)
 
        //FIXME: need to assert RTS and DTR if CRTSCTS off
 
-       dbg("%s - submitting read urb", __FUNCTION__);
+       dbg("%s - submitting read urb", __func__);
        port->read_urb->dev = serial->dev;
        result = usb_submit_urb(port->read_urb, GFP_KERNEL);
        if (result) {
                dev_err(&port->dev, "%s - failed submitting read urb,"
-                       " error %d\n", __FUNCTION__, result);
+                       " error %d\n", __func__, result);
                pl2303_close(port, NULL);
                return -EPROTO;
        }
 
-       dbg("%s - submitting interrupt urb", __FUNCTION__);
+       dbg("%s - submitting interrupt urb", __func__);
        port->interrupt_in_urb->dev = serial->dev;
        result = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
        if (result) {
                dev_err(&port->dev, "%s - failed submitting interrupt urb,"
-                       " error %d\n", __FUNCTION__, result);
+                       " error %d\n", __func__, result);
                pl2303_close(port, NULL);
                return -EPROTO;
        }
@@ -799,7 +794,7 @@ static int pl2303_tiocmget(struct usb_serial_port *port, struct file *file)
        unsigned int status;
        unsigned int result;
 
-       dbg("%s (%d)", __FUNCTION__, port->number);
+       dbg("%s (%d)", __func__, port->number);
 
        if (!usb_get_intfdata(port->serial->interface))
                return -ENODEV;
@@ -816,7 +811,7 @@ static int pl2303_tiocmget(struct usb_serial_port *port, struct file *file)
                  | ((status & UART_RING)       ? TIOCM_RI  : 0)
                  | ((status & UART_DCD)        ? TIOCM_CD  : 0);
 
-       dbg("%s - result = %x", __FUNCTION__, result);
+       dbg("%s - result = %x", __func__, result);
 
        return result;
 }
@@ -860,15 +855,15 @@ static int wait_modem_info(struct usb_serial_port *port, unsigned int arg)
 static int pl2303_ioctl(struct usb_serial_port *port, struct file *file,
                        unsigned int cmd, unsigned long arg)
 {
-       dbg("%s (%d) cmd = 0x%04x", __FUNCTION__, port->number, cmd);
+       dbg("%s (%d) cmd = 0x%04x", __func__, port->number, cmd);
 
        switch (cmd) {
                case TIOCMIWAIT:
-                       dbg("%s (%d) TIOCMIWAIT", __FUNCTION__,  port->number);
+                       dbg("%s (%d) TIOCMIWAIT", __func__,  port->number);
                        return wait_modem_info(port, arg);
 
                default:
-                       dbg("%s not supported = 0x%04x", __FUNCTION__, cmd);
+                       dbg("%s not supported = 0x%04x", __func__, cmd);
                        break;
        }
 
@@ -881,19 +876,19 @@ static void pl2303_break_ctl(struct usb_serial_port *port, int break_state)
        u16 state;
        int result;
 
-       dbg("%s - port %d", __FUNCTION__, port->number);
+       dbg("%s - port %d", __func__, port->number);
 
        if (break_state == 0)
                state = BREAK_OFF;
        else
                state = BREAK_ON;
-       dbg("%s - turning break %s", __FUNCTION__, state==BREAK_OFF ? "off" : "on");
+       dbg("%s - turning break %s", __func__, state==BREAK_OFF ? "off" : "on");
 
        result = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
                                 BREAK_REQUEST, BREAK_REQUEST_TYPE, state,
                                 0, NULL, 0, 100);
        if (result)
-               dbg("%s - error sending break = %d", __FUNCTION__, result);
+               dbg("%s - error sending break = %d", __func__, result);
 }
 
 static void pl2303_shutdown(struct usb_serial *serial)
@@ -901,7 +896,7 @@ static void pl2303_shutdown(struct usb_serial *serial)
        int i;
        struct pl2303_private *priv;
 
-       dbg("%s", __FUNCTION__);
+       dbg("%s", __func__);
 
        for (i = 0; i < serial->num_ports; ++i) {
                priv = usb_get_serial_port_data(serial->port[i]);
@@ -948,16 +943,17 @@ static void pl2303_update_line_status(struct usb_serial_port *port,
        wake_up_interruptible(&priv->delta_msr_wait);
 }
 
-static void pl2303_read_int_callback(struct urb *urb, struct pt_regs *regs)
+static void pl2303_read_int_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;
        unsigned int actual_length = urb->actual_length;
-       int status;
+       int status = urb->status;
+       int retval;
 
-       dbg("%s (%d)", __FUNCTION__, port->number);
+       dbg("%s (%d)", __func__, port->number);
 
-       switch (urb->status) {
+       switch (status) {
        case 0:
                /* success */
                break;
@@ -965,93 +961,93 @@ static void pl2303_read_int_callback(struct urb *urb, struct pt_regs *regs)
        case -ENOENT:
        case -ESHUTDOWN:
                /* this urb is terminated, clean up */
-               dbg("%s - urb shutting down with status: %d", __FUNCTION__,
-                   urb->status);
+               dbg("%s - urb shutting down with status: %d", __func__,
+                   status);
                return;
        default:
-               dbg("%s - nonzero urb status received: %d", __FUNCTION__,
-                   urb->status);
+               dbg("%s - nonzero urb status received: %d", __func__,
+                   status);
                goto exit;
        }
 
-       usb_serial_debug_data(debug, &port->dev, __FUNCTION__,
+       usb_serial_debug_data(debug, &port->dev, __func__,
                              urb->actual_length, urb->transfer_buffer);
 
        pl2303_update_line_status(port, data, actual_length);
 
 exit:
-       status = usb_submit_urb(urb, GFP_ATOMIC);
-       if (status)
+       retval = usb_submit_urb(urb, GFP_ATOMIC);
+       if (retval)
                dev_err(&urb->dev->dev,
                        "%s - usb_submit_urb failed with result %d\n",
-                       __FUNCTION__, status);
+                       __func__, retval);
 }
 
-static void pl2303_read_bulk_callback(struct urb *urb, struct pt_regs *regs)
+static void pl2303_read_bulk_callback(struct urb *urb)
 {
-       struct usb_serial_port *port = (struct usb_serial_port *) urb->context;
+       struct usb_serial_port *port =  urb->context;
        struct pl2303_private *priv = usb_get_serial_port_data(port);
        struct tty_struct *tty;
        unsigned char *data = urb->transfer_buffer;
        unsigned long flags;
        int i;
        int result;
-       u8 status;
+       int status = urb->status;
+       u8 line_status;
        char tty_flag;
 
-       dbg("%s - port %d", __FUNCTION__, port->number);
+       dbg("%s - port %d", __func__, port->number);
 
-       if (urb->status) {
-               dbg("%s - urb->status = %d", __FUNCTION__, urb->status);
+       if (status) {
+               dbg("%s - urb status = %d", __func__, status);
                if (!port->open_count) {
-                       dbg("%s - port is closed, exiting.", __FUNCTION__);
+                       dbg("%s - port is closed, exiting.", __func__);
                        return;
                }
-               if (urb->status == -EPROTO) {
+               if (status == -EPROTO) {
                        /* PL2303 mysteriously fails with -EPROTO reschedule
                         * the read */
                        dbg("%s - caught -EPROTO, resubmitting the urb",
-                           __FUNCTION__);
-                       urb->status = 0;
+                           __func__);
                        urb->dev = port->serial->dev;
                        result = usb_submit_urb(urb, GFP_ATOMIC);
                        if (result)
                                dev_err(&urb->dev->dev, "%s - failed"
                                        " resubmitting read urb, error %d\n",
-                                       __FUNCTION__, result);
+                                       __func__, result);
                        return;
                }
-               dbg("%s - unable to handle the error, exiting.", __FUNCTION__);
+               dbg("%s - unable to handle the error, exiting.", __func__);
                return;
        }
 
-       usb_serial_debug_data(debug, &port->dev, __FUNCTION__,
+       usb_serial_debug_data(debug, &port->dev, __func__,
                              urb->actual_length, data);
 
        /* get tty_flag from status */
        tty_flag = TTY_NORMAL;
 
        spin_lock_irqsave(&priv->lock, flags);
-       status = priv->line_status;
+       line_status = priv->line_status;
        priv->line_status &= ~UART_STATE_TRANSIENT_MASK;
        spin_unlock_irqrestore(&priv->lock, flags);
        wake_up_interruptible(&priv->delta_msr_wait);
 
        /* break takes precedence over parity, */
        /* which takes precedence over framing errors */
-       if (status & UART_BREAK_ERROR )
+       if (line_status & UART_BREAK_ERROR )
                tty_flag = TTY_BREAK;
-       else if (status & UART_PARITY_ERROR)
+       else if (line_status & UART_PARITY_ERROR)
                tty_flag = TTY_PARITY;
-       else if (status & UART_FRAME_ERROR)
+       else if (line_status & UART_FRAME_ERROR)
                tty_flag = TTY_FRAME;
-       dbg("%s - tty_flag = %d", __FUNCTION__, tty_flag);
+       dbg("%s - tty_flag = %d", __func__, tty_flag);
 
        tty = port->tty;
        if (tty && urb->actual_length) {
                tty_buffer_request_room(tty, urb->actual_length + 1);
                /* overrun is special, not associated with a char */
-               if (status & UART_OVERRUN_ERROR)
+               if (line_status & UART_OVERRUN_ERROR)
                        tty_insert_flip_char(tty, 0, TTY_OVERRUN);
                for (i = 0; i < urb->actual_length; ++i)
                        tty_insert_flip_char(tty, data[i], tty_flag);
@@ -1064,21 +1060,22 @@ static void pl2303_read_bulk_callback(struct urb *urb, struct pt_regs *regs)
                result = usb_submit_urb(urb, GFP_ATOMIC);
                if (result)
                        dev_err(&urb->dev->dev, "%s - failed resubmitting"
-                               " read urb, error %d\n", __FUNCTION__, result);
+                               " read urb, error %d\n", __func__, result);
        }
 
        return;
 }
 
-static void pl2303_write_bulk_callback(struct urb *urb, struct pt_regs *regs)
+static void pl2303_write_bulk_callback(struct urb *urb)
 {
-       struct usb_serial_port *port = (struct usb_serial_port *) urb->context;
+       struct usb_serial_port *port =  urb->context;
        struct pl2303_private *priv = usb_get_serial_port_data(port);
        int result;
+       int status = urb->status;
 
-       dbg("%s - port %d", __FUNCTION__, port->number);
+       dbg("%s - port %d", __func__, port->number);
 
-       switch (urb->status) {
+       switch (status) {
        case 0:
                /* success */
                break;
@@ -1086,21 +1083,21 @@ static void pl2303_write_bulk_callback(struct urb *urb, struct pt_regs *regs)
        case -ENOENT:
        case -ESHUTDOWN:
                /* this urb is terminated, clean up */
-               dbg("%s - urb shutting down with status: %d", __FUNCTION__,
-                   urb->status);
+               dbg("%s - urb shutting down with status: %d", __func__,
+                   status);
                priv->write_urb_in_use = 0;
                return;
        default:
                /* error in the urb, so we have to resubmit it */
-               dbg("%s - Overflow in write", __FUNCTION__);
-               dbg("%s - nonzero write bulk status received: %d", __FUNCTION__,
-                   urb->status);
+               dbg("%s - Overflow in write", __func__);
+               dbg("%s - nonzero write bulk status received: %d", __func__,
+                   status);
                port->write_urb->transfer_buffer_length = 1;
                port->write_urb->dev = port->serial->dev;
                result = usb_submit_urb(port->write_urb, GFP_ATOMIC);
                if (result)
                        dev_err(&urb->dev->dev, "%s - failed resubmitting write"
-                               " urb, error %d\n", __FUNCTION__, result);
+                               " urb, error %d\n", __func__, result);
                else
                        return;
        }
@@ -1118,9 +1115,7 @@ static struct usb_serial_driver pl2303_device = {
                .name =         "pl2303",
        },
        .id_table =             id_table,
-       .num_interrupt_in =     NUM_DONT_CARE,
-       .num_bulk_in =          1,
-       .num_bulk_out =         1,
+       .usb_driver =           &pl2303_driver,
        .num_ports =            1,
        .open =                 pl2303_open,
        .close =                pl2303_close,