This commit was manufactured by cvs2svn to create tag
[linux-2.6.git] / drivers / usb / serial / cyberjack.c
index 3a367f5..33613b0 100644 (file)
@@ -57,7 +57,8 @@ static int cyberjack_startup (struct usb_serial *serial);
 static void cyberjack_shutdown (struct usb_serial *serial);
 static int  cyberjack_open (struct usb_serial_port *port, struct file *filp);
 static void cyberjack_close (struct usb_serial_port *port, struct file *filp);
-static int cyberjack_write (struct usb_serial_port *port, const unsigned char *buf, int count);
+static int cyberjack_write (struct usb_serial_port *port, int from_user,
+       const unsigned char *buf, int count);
 static int cyberjack_write_room( struct usb_serial_port *port );
 static void cyberjack_read_int_callback (struct urb *urb, struct pt_regs *regs);
 static void cyberjack_read_bulk_callback (struct urb *urb, struct pt_regs *regs);
@@ -148,7 +149,7 @@ static void cyberjack_shutdown (struct usb_serial *serial)
        dbg("%s", __FUNCTION__);
 
        for (i=0; i < serial->num_ports; ++i) {
-               usb_kill_urb(serial->port[i]->interrupt_in_urb);
+               usb_unlink_urb (serial->port[i]->interrupt_in_urb);
                /* My special items, the standard routines free my urbs */
                kfree(usb_get_serial_port_data(serial->port[i]));
                usb_set_serial_port_data(serial->port[i], NULL);
@@ -188,12 +189,12 @@ static void cyberjack_close (struct usb_serial_port *port, struct file *filp)
 
        if (port->serial->dev) {
                /* shutdown any bulk reads that might be going on */
-               usb_kill_urb(port->write_urb);
-               usb_kill_urb(port->read_urb);
+               usb_unlink_urb (port->write_urb);
+               usb_unlink_urb (port->read_urb);
        }
 }
 
-static int cyberjack_write (struct usb_serial_port *port, const unsigned char *buf, int count)
+static int cyberjack_write (struct usb_serial_port *port, int from_user, const unsigned char *buf, int count)
 {
        struct usb_serial *serial = port->serial;
        struct cyberjack_private *priv = usb_get_serial_port_data(port);
@@ -202,6 +203,7 @@ static int cyberjack_write (struct usb_serial_port *port, const unsigned char *b
        int wrexpected;
 
        dbg("%s - port %d", __FUNCTION__, port->number);
+       dbg("%s - from_user %d", __FUNCTION__, from_user);
 
        if (count == 0) {
                dbg("%s - write request of 0 bytes", __FUNCTION__);
@@ -223,7 +225,14 @@ static int cyberjack_write (struct usb_serial_port *port, const unsigned char *b
        }
 
        /* Copy data */
-       memcpy (priv->wrbuf+priv->wrfilled, buf, count);
+       if (from_user) {
+               if (copy_from_user(priv->wrbuf+priv->wrfilled, buf, count)) {
+                       spin_unlock_irqrestore(&priv->lock, flags);
+                       return -EFAULT;
+               }
+       } else {
+               memcpy (priv->wrbuf+priv->wrfilled, buf, count);
+       }  
 
        usb_serial_debug_data(debug, &port->dev, __FUNCTION__, count,
                priv->wrbuf+priv->wrfilled);
@@ -502,7 +511,6 @@ module_exit(cyberjack_exit);
 
 MODULE_AUTHOR( DRIVER_AUTHOR );
 MODULE_DESCRIPTION( DRIVER_DESC );
-MODULE_VERSION( DRIVER_VERSION );
 MODULE_LICENSE("GPL");
 
 module_param(debug, bool, S_IRUGO | S_IWUSR);