fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / drivers / usb / serial / ti_usb_3410_5052.c
index 59c88de..8318900 100644 (file)
@@ -68,7 +68,6 @@
  * fi
  */
 
-#include <linux/config.h>
 #include <linux/kernel.h>
 #include <linux/errno.h>
 #include <linux/init.h>
@@ -84,8 +83,8 @@
 #include <asm/uaccess.h>
 #include <asm/semaphore.h>
 #include <linux/usb.h>
+#include <linux/usb/serial.h>
 
-#include "usb-serial.h"
 #include "ti_usb_3410_5052.h"
 #include "ti_fw_3410.h"                /* firmware image for 3410 */
 #include "ti_fw_5052.h"                /* firmware image for 5052 */
@@ -162,14 +161,14 @@ static void ti_throttle(struct usb_serial_port *port);
 static void ti_unthrottle(struct usb_serial_port *port);
 static int ti_ioctl(struct usb_serial_port *port, struct file *file, unsigned int cmd, unsigned long arg);
 static void ti_set_termios(struct usb_serial_port *port,
-       struct termios *old_termios);
+       struct ktermios *old_termios);
 static int ti_tiocmget(struct usb_serial_port *port, struct file *file);
 static int ti_tiocmset(struct usb_serial_port *port, struct file *file,
        unsigned int set, unsigned int clear);
 static void ti_break(struct usb_serial_port *port, int break_state);
-static void ti_interrupt_callback(struct urb *urb, struct pt_regs *regs);
-static void ti_bulk_in_callback(struct urb *urb, struct pt_regs *regs);
-static void ti_bulk_out_callback(struct urb *urb, struct pt_regs *regs);
+static void ti_interrupt_callback(struct urb *urb);
+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,
        unsigned char *data, int length);
@@ -229,6 +228,7 @@ static int product_5052_count;
 /* null entry */
 static struct usb_device_id ti_id_table_3410[1+TI_EXTRA_VID_PID_COUNT+1] = {
        { USB_DEVICE(TI_VENDOR_ID, TI_3410_PRODUCT_ID) },
+       { USB_DEVICE(TI_VENDOR_ID, TI_3410_EZ430_ID) },
 };
 
 static struct usb_device_id ti_id_table_5052[4+TI_EXTRA_VID_PID_COUNT+1] = {
@@ -240,6 +240,7 @@ static struct usb_device_id ti_id_table_5052[4+TI_EXTRA_VID_PID_COUNT+1] = {
 
 static struct usb_device_id ti_id_table_combined[] = {
        { USB_DEVICE(TI_VENDOR_ID, TI_3410_PRODUCT_ID) },
+       { USB_DEVICE(TI_VENDOR_ID, TI_3410_EZ430_ID) },
        { USB_DEVICE(TI_VENDOR_ID, TI_5052_BOOT_PRODUCT_ID) },
        { USB_DEVICE(TI_VENDOR_ID, TI_5152_BOOT_PRODUCT_ID) },
        { USB_DEVICE(TI_VENDOR_ID, TI_5052_EEPROM_PRODUCT_ID) },
@@ -248,16 +249,19 @@ static struct usb_device_id ti_id_table_combined[] = {
 };
 
 static struct usb_driver ti_usb_driver = {
-       .owner                  = THIS_MODULE,
        .name                   = "ti_usb_3410_5052",
        .probe                  = usb_serial_probe,
        .disconnect             = usb_serial_disconnect,
        .id_table               = ti_id_table_combined,
+       .no_dynamic_id =        1,
 };
 
-static struct usb_serial_device_type ti_1port_device = {
-       .owner                  = THIS_MODULE,
-       .name                   = "TI USB 3410 1 port adapter",
+static struct usb_serial_driver ti_1port_device = {
+       .driver = {
+               .owner          = THIS_MODULE,
+               .name           = "ti_usb_3410_5052_1",
+       },
+       .description            = "TI USB 3410 1 port adapter",
        .id_table               = ti_id_table_3410,
        .num_interrupt_in       = 1,
        .num_bulk_in            = 1,
@@ -282,9 +286,12 @@ static struct usb_serial_device_type ti_1port_device = {
        .write_bulk_callback    = ti_bulk_out_callback,
 };
 
-static struct usb_serial_device_type ti_2port_device = {
-       .owner                  = THIS_MODULE,
-       .name                   = "TI USB 5052 2 port adapter",
+static struct usb_serial_driver ti_2port_device = {
+       .driver = {
+               .owner          = THIS_MODULE,
+               .name           = "ti_usb_3410_5052_2",
+       },
+       .description            = "TI USB 5052 2 port adapter",
        .id_table               = ti_id_table_5052,
        .num_interrupt_in       = 1,
        .num_bulk_in            = 2,
@@ -345,17 +352,14 @@ static int __init ti_init(void)
        int i,j;
        int ret;
 
-
        /* insert extra vendor and product ids */
-       j = sizeof(ti_id_table_3410)/sizeof(struct usb_device_id)
-               - TI_EXTRA_VID_PID_COUNT - 1;
+       j = ARRAY_SIZE(ti_id_table_3410) - TI_EXTRA_VID_PID_COUNT - 1;
        for (i=0; i<min(vendor_3410_count,product_3410_count); i++,j++) {
                ti_id_table_3410[j].idVendor = vendor_3410[i];
                ti_id_table_3410[j].idProduct = product_3410[i];
                ti_id_table_3410[j].match_flags = USB_DEVICE_ID_MATCH_DEVICE;
        }
-       j = sizeof(ti_id_table_5052)/sizeof(struct usb_device_id)
-               - TI_EXTRA_VID_PID_COUNT - 1;
+       j = ARRAY_SIZE(ti_id_table_5052) - TI_EXTRA_VID_PID_COUNT - 1;
        for (i=0; i<min(vendor_5052_count,product_5052_count); i++,j++) {
                ti_id_table_5052[j].idVendor = vendor_5052[i];
                ti_id_table_5052[j].idProduct = product_5052[i];
@@ -413,12 +417,11 @@ static int ti_startup(struct usb_serial *serial)
            dev->actconfig->desc.bConfigurationValue);
 
        /* create device structure */
-       tdev = kmalloc(sizeof(struct ti_device), GFP_KERNEL);
+       tdev = kzalloc(sizeof(struct ti_device), GFP_KERNEL);
        if (tdev == NULL) {
                dev_err(&dev->dev, "%s - out of memory\n", __FUNCTION__);
                return -ENOMEM;
        }
-       memset(tdev, 0, sizeof(struct ti_device));
        sema_init(&tdev->td_open_close_sem, 1);
        tdev->td_serial = serial;
        usb_set_serial_data(serial, tdev);
@@ -458,13 +461,12 @@ static int ti_startup(struct usb_serial *serial)
 
        /* set up port structures */
        for (i = 0; i < serial->num_ports; ++i) {
-               tport = kmalloc(sizeof(struct ti_port), GFP_KERNEL);
+               tport = kzalloc(sizeof(struct ti_port), GFP_KERNEL);
                if (tport == NULL) {
                        dev_err(&dev->dev, "%s - out of memory\n", __FUNCTION__);
                        status = -ENOMEM;
                        goto free_tports;
                }
-               memset(tport, 0, sizeof(struct ti_port));
                spin_lock_init(&tport->tp_lock);
                tport->tp_uart_base_addr = (i == 0 ? TI_UART1_BASE_ADDR : TI_UART2_BASE_ADDR);
                tport->tp_flags = low_latency ? ASYNC_LOW_LATENCY : 0;
@@ -879,7 +881,7 @@ static int ti_ioctl(struct usb_serial_port *port, struct file *file,
 
 
 static void ti_set_termios(struct usb_serial_port *port,
-       struct termios *old_termios)
+       struct ktermios *old_termios)
 {
        struct ti_port *tport = usb_get_serial_port_data(port);
        struct tty_struct *tty = port->tty;
@@ -1097,7 +1099,7 @@ static void ti_break(struct usb_serial_port *port, int break_state)
 }
 
 
-static void ti_interrupt_callback(struct urb *urb, struct pt_regs *regs)
+static void ti_interrupt_callback(struct urb *urb)
 {
        struct ti_device *tdev = (struct ti_device *)urb->context;
        struct usb_serial_port *port;
@@ -1177,7 +1179,7 @@ exit:
 }
 
 
-static void ti_bulk_in_callback(struct urb *urb, struct pt_regs *regs)
+static void ti_bulk_in_callback(struct urb *urb)
 {
        struct ti_port *tport = (struct ti_port *)urb->context;
        struct usb_serial_port *port = tport->tp_port;
@@ -1240,7 +1242,7 @@ exit:
 }
 
 
-static void ti_bulk_out_callback(struct urb *urb, struct pt_regs *regs)
+static void ti_bulk_out_callback(struct urb *urb)
 {
        struct ti_port *tport = (struct ti_port *)urb->context;
        struct usb_serial_port *port = tport->tp_port;
@@ -1277,24 +1279,18 @@ static void ti_recv(struct device *dev, struct tty_struct *tty,
        int cnt;
 
        do {
-               if (tty->flip.count >= TTY_FLIPBUF_SIZE) {
-                       tty_flip_buffer_push(tty);
-                       if (tty->flip.count >= TTY_FLIPBUF_SIZE) {
-                               dev_err(dev, "%s - dropping data, %d bytes lost\n", __FUNCTION__, length);
-                               return;
-                       }
+               cnt = tty_buffer_request_room(tty, length);
+               if (cnt < length) {
+                       dev_err(dev, "%s - dropping data, %d bytes lost\n", __FUNCTION__, length - cnt);
+                       if(cnt == 0)
+                               break;
                }
-               cnt = min(length, TTY_FLIPBUF_SIZE - tty->flip.count);
-               memcpy(tty->flip.char_buf_ptr, data, cnt);
-               memset(tty->flip.flag_buf_ptr, 0, cnt);
-               tty->flip.char_buf_ptr += cnt;
-               tty->flip.flag_buf_ptr += cnt;
-               tty->flip.count += cnt;
+               tty_insert_flip_string(tty, data, cnt);
+               tty_flip_buffer_push(tty);
                data += cnt;
                length -= cnt;
        } while (length > 0);
 
-       tty_flip_buffer_push(tty);
 }
 
 
@@ -1714,7 +1710,7 @@ static struct circ_buf *ti_buf_alloc(void)
 {
        struct circ_buf *cb;
 
-       cb = (struct circ_buf *)kmalloc(sizeof(struct circ_buf), GFP_KERNEL);
+       cb = kmalloc(sizeof(struct circ_buf), GFP_KERNEL);
        if (cb == NULL)
                return NULL;