fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / drivers / usb / serial / kl5kusb105.c
index a11e829..5c4b06a 100644 (file)
@@ -45,7 +45,6 @@
  */
 
 
-#include <linux/config.h>
 #include <linux/kernel.h>
 #include <linux/errno.h>
 #include <linux/init.h>
@@ -56,7 +55,7 @@
 #include <linux/module.h>
 #include <asm/uaccess.h>
 #include <linux/usb.h>
-#include "usb-serial.h"
+#include <linux/usb/serial.h>
 #include "kl5kusb105.h"
 
 static int debug;
@@ -81,17 +80,13 @@ static void klsi_105_close           (struct usb_serial_port *port,
 static int  klsi_105_write              (struct usb_serial_port *port,
                                          const unsigned char *buf,
                                          int count);
-static void klsi_105_write_bulk_callback (struct urb *urb, struct pt_regs *regs);
+static void klsi_105_write_bulk_callback (struct urb *urb);
 static int  klsi_105_chars_in_buffer     (struct usb_serial_port *port);
 static int  klsi_105_write_room          (struct usb_serial_port *port);
 
-static void klsi_105_read_bulk_callback  (struct urb *urb, struct pt_regs *regs);
+static void klsi_105_read_bulk_callback  (struct urb *urb);
 static void klsi_105_set_termios         (struct usb_serial_port *port,
-                                         struct termios * old);
-static int  klsi_105_ioctl              (struct usb_serial_port *port,
-                                         struct file * file,
-                                         unsigned int cmd,
-                                         unsigned long arg);
+                                         struct ktermios *old);
 static void klsi_105_throttle           (struct usb_serial_port *port);
 static void klsi_105_unthrottle                 (struct usb_serial_port *port);
 /*
@@ -116,17 +111,19 @@ static struct usb_device_id id_table [] = {
 MODULE_DEVICE_TABLE (usb, id_table);
 
 static struct usb_driver kl5kusb105d_driver = {
-       .owner =        THIS_MODULE,
        .name =         "kl5kusb105d",
        .probe =        usb_serial_probe,
        .disconnect =   usb_serial_disconnect,
        .id_table =     id_table,
+       .no_dynamic_id =        1,
 };
 
-static struct usb_serial_device_type kl5kusb105d_device = {
-       .owner =             THIS_MODULE,
-       .name =              "KL5KUSB105D / PalmConnect",
-       .short_name =        "kl5kusb105d",
+static struct usb_serial_driver kl5kusb105d_device = {
+       .driver = {
+               .owner =        THIS_MODULE,
+               .name =         "kl5kusb105d",
+       },
+       .description =       "KL5KUSB105D / PalmConnect",
        .id_table =          id_table,
        .num_interrupt_in =  1,
        .num_bulk_in =       1,
@@ -139,7 +136,6 @@ static struct usb_serial_device_type kl5kusb105d_device = {
        .chars_in_buffer =   klsi_105_chars_in_buffer,
        .write_room =        klsi_105_write_room,
        .read_bulk_callback =klsi_105_read_bulk_callback,
-       .ioctl =             klsi_105_ioctl,
        .set_termios =       klsi_105_set_termios,
        /*.break_ctl =       klsi_105_break_ctl,*/
        .tiocmget =          klsi_105_tiocmget,
@@ -163,7 +159,7 @@ struct klsi_105_port_settings {
 #define URB_TRANSFER_BUFFER_SIZE       64
 struct klsi_105_private {
        struct klsi_105_port_settings   cfg;
-       struct termios                  termios;
+       struct ktermios                 termios;
        unsigned long                   line_state; /* modem line settings */
        /* write pool */
        struct urb *                    write_urb_pool[NUM_URBS];
@@ -555,7 +551,7 @@ exit:
        return bytes_sent;      /* that's how much we wrote */
 } /* klsi_105_write */
 
-static void klsi_105_write_bulk_callback ( struct urb *urb, struct pt_regs *regs)
+static void klsi_105_write_bulk_callback ( struct urb *urb)
 {
        struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
 
@@ -567,8 +563,7 @@ static void klsi_105_write_bulk_callback ( struct urb *urb, struct pt_regs *regs
                return;
        }
 
-       /* from generic_write_bulk_callback */
-       schedule_work(&port->work);
+       usb_serial_port_softint(port);
 } /* klsi_105_write_bulk_completion_callback */
 
 
@@ -616,7 +611,7 @@ static int klsi_105_write_room (struct usb_serial_port *port)
 
 
 
-static void klsi_105_read_bulk_callback (struct urb *urb, struct pt_regs *regs)
+static void klsi_105_read_bulk_callback (struct urb *urb)
 {
        struct usb_serial_port *port = (struct usb_serial_port *)urb->context;
        struct klsi_105_private *priv = usb_get_serial_port_data(port);
@@ -646,7 +641,6 @@ static void klsi_105_read_bulk_callback (struct urb *urb, struct pt_regs *regs)
                usb_serial_debug_data(debug, &port->dev, __FUNCTION__,
                                      urb->actual_length, data);
        } else {
-               int i;
                int bytes_sent = ((__u8 *) data)[0] +
                                 ((unsigned int) ((__u8 *) data)[1] << 8);
                tty = port->tty;
@@ -667,16 +661,8 @@ static void klsi_105_read_bulk_callback (struct urb *urb, struct pt_regs *regs)
                        bytes_sent = urb->actual_length - 2;
                }
 
-               for (i = 2; i < 2+bytes_sent; i++) {
-                       /* if we insert more than TTY_FLIPBUF_SIZE characters,
-                        * we drop them. */
-                       if(tty->flip.count >= TTY_FLIPBUF_SIZE) {
-                               tty_flip_buffer_push(tty);
-                       }
-                       /* this doesn't actually push the data through unless 
-                        * tty->low_latency is set */
-                       tty_insert_flip_char(tty, ((__u8*) data)[i], 0);
-               }
+               tty_buffer_request_room(tty, bytes_sent);
+               tty_insert_flip_string(tty, data + 2, bytes_sent);
                tty_flip_buffer_push(tty);
 
                /* again lockless, but debug info only */
@@ -697,7 +683,7 @@ static void klsi_105_read_bulk_callback (struct urb *urb, struct pt_regs *regs)
 
 
 static void klsi_105_set_termios (struct usb_serial_port *port,
-                                 struct termios *old_termios)
+                                 struct ktermios *old_termios)
 {
        struct klsi_105_private *priv = usb_get_serial_port_data(port);
        unsigned int iflag = port->tty->termios->c_iflag;
@@ -908,69 +894,6 @@ static int klsi_105_tiocmset (struct usb_serial_port *port, struct file *file,
 */
        return retval;
 }
-                                       
-static int klsi_105_ioctl (struct usb_serial_port *port, struct file * file,
-                          unsigned int cmd, unsigned long arg)
-{
-       struct klsi_105_private *priv = usb_get_serial_port_data(port);
-       void __user *user_arg = (void __user *)arg;
-       
-       dbg("%scmd=0x%x", __FUNCTION__, cmd);
-
-       /* Based on code from acm.c and others */
-       switch (cmd) {
-       case TIOCMIWAIT:
-               /* wait for any of the 4 modem inputs (DCD,RI,DSR,CTS)*/
-               /* TODO */
-               dbg("%s - TIOCMIWAIT not handled", __FUNCTION__);
-               return -ENOIOCTLCMD;
-       case TIOCGICOUNT:
-               /* return count of modemline transitions */
-               /* TODO */
-               dbg("%s - TIOCGICOUNT not handled", __FUNCTION__);
-               return -ENOIOCTLCMD;
-       case TCGETS:
-               /* return current info to caller */
-               dbg("%s - TCGETS data faked/incomplete", __FUNCTION__);
-
-               if (!access_ok(VERIFY_WRITE, user_arg, sizeof(struct termios)))
-                       return -EFAULT;
-
-               if (kernel_termios_to_user_termios((struct termios __user *)arg,
-                                                  &priv->termios))
-                       return -EFAULT;
-               return 0;
-       case TCSETS:
-               /* set port termios to the one given by the user */
-               dbg("%s - TCSETS not handled", __FUNCTION__);
-
-               if (!access_ok(VERIFY_READ, user_arg, sizeof(struct termios)))
-                       return -EFAULT;
-
-               if (user_termios_to_kernel_termios(&priv->termios,
-                                                  (struct termios __user *)arg))
-                       return -EFAULT;
-               klsi_105_set_termios(port, &priv->termios);
-               return 0;
-       case TCSETSW: {
-               /* set port termios and try to wait for completion of last
-                * write operation */
-               /* We guess here. If there are not too many write urbs
-                * outstanding, we lie. */
-               /* what is the right way to wait here? schedule() ? */
-               /*
-               while (klsi_105_chars_in_buffer(port) > (NUM_URBS / 4 ) * URB_TRANSFER_BUFFER_SIZE)
-                           schedule();
-                */
-               return -ENOIOCTLCMD;
-                     }
-       default:
-               dbg("%s: arg not supported - 0x%04x", __FUNCTION__,cmd);
-               return(-ENOIOCTLCMD);
-               break;
-       }
-       return 0;
-} /* klsi_105_ioctl */
 
 static void klsi_105_throttle (struct usb_serial_port *port)
 {