vserver 1.9.5.x5
[linux-2.6.git] / drivers / usb / serial / whiteheat.c
index e79afad..b6384a3 100644 (file)
 #include <linux/usb.h>
 #include <linux/serial_reg.h>
 #include <linux/serial.h>
-
-#ifdef CONFIG_USB_SERIAL_DEBUG
-       static int debug = 1;
-#else
-       static int debug;
-#endif
-
 #include "usb-serial.h"
 #include "whiteheat_fw.h"              /* firmware for the ConnectTech WhiteHEAT device */
 #include "whiteheat.h"                 /* WhiteHEAT specific commands */
 
+static int debug;
+
 #ifndef CMSPAR
 #define CMSPAR 0
 #endif
@@ -148,7 +143,7 @@ static int  whiteheat_attach                (struct usb_serial *serial);
 static void whiteheat_shutdown         (struct usb_serial *serial);
 static int  whiteheat_open             (struct usb_serial_port *port, struct file *filp);
 static void whiteheat_close            (struct usb_serial_port *port, struct file *filp);
-static int  whiteheat_write            (struct usb_serial_port *port, int from_user, const unsigned char *buf, int count);
+static int  whiteheat_write            (struct usb_serial_port *port, const unsigned char *buf, int count);
 static int  whiteheat_write_room       (struct usb_serial_port *port);
 static int  whiteheat_ioctl            (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg);
 static void whiteheat_set_termios      (struct usb_serial_port *port, struct termios * old);
@@ -673,8 +668,7 @@ static void whiteheat_close(struct usb_serial_port *port, struct file * filp)
 
        if (port->tty->driver->flush_buffer)
                port->tty->driver->flush_buffer(port->tty);
-       if (port->tty->ldisc.flush_buffer)
-               port->tty->ldisc.flush_buffer(port->tty);
+       tty_ldisc_flush(port->tty);
 
        firm_report_tx_done(port);
 
@@ -685,7 +679,7 @@ static void whiteheat_close(struct usb_serial_port *port, struct file * filp)
        list_for_each_safe(tmp, tmp2, &info->rx_urbs_submitted) {
                wrap = list_entry(tmp, struct whiteheat_urb_wrap, list);
                urb = wrap->urb;
-               usb_unlink_urb(urb);
+               usb_kill_urb(urb);
                list_del(tmp);
                list_add(tmp, &info->rx_urbs_free);
        }
@@ -696,7 +690,7 @@ static void whiteheat_close(struct usb_serial_port *port, struct file * filp)
        list_for_each_safe(tmp, tmp2, &info->tx_urbs_submitted) {
                wrap = list_entry(tmp, struct whiteheat_urb_wrap, list);
                urb = wrap->urb;
-               usb_unlink_urb(urb);
+               usb_kill_urb(urb);
                list_del(tmp);
                list_add(tmp, &info->tx_urbs_free);
        }
@@ -708,7 +702,7 @@ static void whiteheat_close(struct usb_serial_port *port, struct file * filp)
 }
 
 
-static int whiteheat_write(struct usb_serial_port *port, int from_user, const unsigned char *buf, int count)
+static int whiteheat_write(struct usb_serial_port *port, const unsigned char *buf, int count)
 {
        struct usb_serial *serial = port->serial;
        struct whiteheat_private *info = usb_get_serial_port_data(port);
@@ -740,14 +734,9 @@ static int whiteheat_write(struct usb_serial_port *port, int from_user, const un
                wrap = list_entry(tmp, struct whiteheat_urb_wrap, list);
                urb = wrap->urb;
                bytes = (count > port->bulk_out_size) ? port->bulk_out_size : count;
-               if (from_user) {
-                       if (copy_from_user(urb->transfer_buffer, buf + sent, bytes))
-                               return -EFAULT;
-               } else {
-                       memcpy (urb->transfer_buffer, buf + sent, bytes);
-               }
+               memcpy (urb->transfer_buffer, buf + sent, bytes);
 
-               usb_serial_debug_data (__FILE__, __FUNCTION__, bytes, urb->transfer_buffer);
+               usb_serial_debug_data(debug, &port->dev, __FUNCTION__, bytes, urb->transfer_buffer);
 
                urb->dev = serial->dev;
                urb->transfer_buffer_length = bytes;
@@ -835,6 +824,7 @@ static int whiteheat_tiocmset (struct usb_serial_port *port, struct file *file,
 static int whiteheat_ioctl (struct usb_serial_port *port, struct file * file, unsigned int cmd, unsigned long arg)
 {
        struct serial_struct serstruct;
+       void __user *user_arg = (void __user *)arg;
 
        dbg("%s - port %d, cmd 0x%.4x", __FUNCTION__, port->number, cmd);
 
@@ -851,13 +841,13 @@ static int whiteheat_ioctl (struct usb_serial_port *port, struct file * file, un
                        serstruct.close_delay = CLOSING_DELAY;
                        serstruct.closing_wait = CLOSING_DELAY;
 
-                       if (copy_to_user((void *)arg, &serstruct, sizeof(serstruct)))
+                       if (copy_to_user(user_arg, &serstruct, sizeof(serstruct)))
                                return -EFAULT;
 
                        break;
 
                case TIOCSSERIAL:
-                       if (copy_from_user(&serstruct, (void *)arg, sizeof(serstruct)))
+                       if (copy_from_user(&serstruct, user_arg, sizeof(serstruct)))
                                return -EFAULT;
 
                        /*
@@ -974,10 +964,6 @@ static void command_port_write_callback (struct urb *urb, struct pt_regs *regs)
                dbg ("nonzero urb status: %d", urb->status);
                return;
        }
-
-       usb_serial_debug_data (__FILE__, __FUNCTION__, urb->actual_length, urb->transfer_buffer);
-
-       return;
 }
 
 
@@ -996,7 +982,7 @@ static void command_port_read_callback (struct urb *urb, struct pt_regs *regs)
                return;
        }
 
-       usb_serial_debug_data (__FILE__, __FUNCTION__, urb->actual_length, data);
+       usb_serial_debug_data(debug, &command_port->dev, __FUNCTION__, urb->actual_length, data);
 
        command_info = usb_get_serial_port_data(command_port);
        if (!command_info) {
@@ -1058,7 +1044,7 @@ static void whiteheat_read_callback(struct urb *urb, struct pt_regs *regs)
                return;
        }
 
-       usb_serial_debug_data (__FILE__, __FUNCTION__, urb->actual_length, data);
+       usb_serial_debug_data(debug, &port->dev, __FUNCTION__, urb->actual_length, data);
 
        spin_lock(&info->lock);
        list_add_tail(&wrap->list, &info->rx_urb_q);
@@ -1128,11 +1114,11 @@ static int firm_send_command (struct usb_serial_port *port, __u8 command, __u8 *
        command_port->write_urb->transfer_buffer_length = datasize + 1;
        command_port->write_urb->dev = port->serial->dev;
        retval = usb_submit_urb (command_port->write_urb, GFP_KERNEL);
-       spin_unlock_irqrestore(&command_info->lock, flags);
        if (retval) {
                dbg("%s - submit urb failed", __FUNCTION__);
                goto exit;
        }
+       spin_unlock_irqrestore(&command_info->lock, flags);
 
        /* wait for the command to complete */
        wait_event_interruptible_timeout(command_info->wait_command, 
@@ -1352,7 +1338,7 @@ static void stop_command_port(struct usb_serial *serial)
        spin_lock_irqsave(&command_info->lock, flags);
        command_info->port_running--;
        if (!command_info->port_running)
-               usb_unlink_urb(command_port->read_urb);
+               usb_kill_urb(command_port->read_urb);
        spin_unlock_irqrestore(&command_info->lock, flags);
 }
 
@@ -1380,7 +1366,7 @@ static int start_port_read(struct usb_serial_port *port)
                        list_for_each_safe(tmp, tmp2, &info->rx_urbs_submitted) {
                                wrap = list_entry(tmp, struct whiteheat_urb_wrap, list);
                                urb = wrap->urb;
-                               usb_unlink_urb(urb);
+                               usb_kill_urb(urb);
                                list_del(tmp);
                                list_add(tmp, &info->rx_urbs_free);
                        }
@@ -1518,8 +1504,8 @@ MODULE_AUTHOR( DRIVER_AUTHOR );
 MODULE_DESCRIPTION( DRIVER_DESC );
 MODULE_LICENSE("GPL");
 
-MODULE_PARM(urb_pool_size, "i");
+module_param(urb_pool_size, int, 0);
 MODULE_PARM_DESC(urb_pool_size, "Number of urbs to use for buffering");
 
-MODULE_PARM(debug, "i");
+module_param(debug, bool, S_IRUGO | S_IWUSR);
 MODULE_PARM_DESC(debug, "Debug enabled or not");