Merge branch 'intx' of master.kernel.org:/pub/scm/linux/kernel/git/jgarzik/misc-2.6
[pandora-kernel.git] / drivers / usb / serial / mos7840.c
index 95bf571..5432c63 100644 (file)
@@ -421,7 +421,7 @@ static int mos7840_handle_new_lsr(struct moschip_port *port, __u8 new_lsr)
 /************************************************************************/
 /************************************************************************/
 
-static void mos7840_control_callback(struct urb *urb, struct pt_regs *regs)
+static void mos7840_control_callback(struct urb *urb)
 {
        unsigned char *data;
        struct moschip_port *mos7840_port;
@@ -497,7 +497,7 @@ static int mos7840_get_reg(struct moschip_port *mcs, __u16 Wval, __u16 reg,
  *     interrupt endpoint.
  *****************************************************************************/
 
-static void mos7840_interrupt_callback(struct urb *urb, struct pt_regs *regs)
+static void mos7840_interrupt_callback(struct urb *urb)
 {
        int result;
        int length;
@@ -647,7 +647,7 @@ static struct usb_serial *mos7840_get_usb_serial(struct usb_serial_port *port,
  *     bulk in endpoint.
  *****************************************************************************/
 
-static void mos7840_bulk_in_callback(struct urb *urb, struct pt_regs *regs)
+static void mos7840_bulk_in_callback(struct urb *urb)
 {
        int status;
        unsigned char *data;
@@ -726,8 +726,7 @@ static void mos7840_bulk_in_callback(struct urb *urb, struct pt_regs *regs)
  *     on the bulk out endpoint.
  *****************************************************************************/
 
-static void mos7840_bulk_out_data_callback(struct urb *urb,
-                                          struct pt_regs *regs)
+static void mos7840_bulk_out_data_callback(struct urb *urb)
 {
        struct moschip_port *mos7840_port;
        struct tty_struct *tty;
@@ -827,7 +826,7 @@ static int mos7840_open(struct usb_serial_port *port, struct file *filp)
 
        /* Initialising the write urb pool */
        for (j = 0; j < NUM_URBS; ++j) {
-               urb = usb_alloc_urb(0, SLAB_ATOMIC);
+               urb = usb_alloc_urb(0, GFP_ATOMIC);
                mos7840_port->write_urb_pool[j] = urb;
 
                if (urb == NULL) {
@@ -1088,7 +1087,7 @@ static int mos7840_open(struct usb_serial_port *port, struct file *filp)
        mos7840_port->icount.tx = 0;
        mos7840_port->icount.rx = 0;
 
-       dbg("\n\nusb_serial serial:%x       mos7840_port:%x\n      usb_serial_port port:%x\n\n", (unsigned int)serial, (unsigned int)mos7840_port, (unsigned int)port);
+       dbg("\n\nusb_serial serial:%p       mos7840_port:%p\n      usb_serial_port port:%p\n\n", serial, mos7840_port, port);
 
        return 0;
 
@@ -1421,7 +1420,6 @@ static int mos7840_write(struct usb_serial_port *port,
        int i;
        int bytes_sent = 0;
        int transfer_size;
-       int from_user = 0;
 
        struct moschip_port *mos7840_port;
        struct usb_serial *serial;
@@ -1512,15 +1510,7 @@ static int mos7840_write(struct usb_serial_port *port,
        }
        transfer_size = min(count, URB_TRANSFER_BUFFER_SIZE);
 
-       if (from_user) {
-               if (copy_from_user
-                   (urb->transfer_buffer, current_position, transfer_size)) {
-                       bytes_sent = -EFAULT;
-                       goto exit;
-               }
-       } else {
-               memcpy(urb->transfer_buffer, current_position, transfer_size);
-       }
+       memcpy(urb->transfer_buffer, current_position, transfer_size);
 
        /* fill urb with data and submit  */
        usb_fill_bulk_urb(urb,
@@ -2226,7 +2216,7 @@ static void mos7840_set_termios(struct usb_serial_port *port,
  *****************************************************************************/
 
 static int mos7840_get_lsr_info(struct moschip_port *mos7840_port,
-                               unsigned int *value)
+                               unsigned int __user *value)
 {
        int count;
        unsigned int result = 0;
@@ -2249,7 +2239,7 @@ static int mos7840_get_lsr_info(struct moschip_port *mos7840_port,
  *****************************************************************************/
 
 static int mos7840_get_bytes_avail(struct moschip_port *mos7840_port,
-                                  unsigned int *value)
+                                  unsigned int __user *value)
 {
        unsigned int result = 0;
        struct tty_struct *tty = mos7840_port->port->tty;
@@ -2272,7 +2262,7 @@ static int mos7840_get_bytes_avail(struct moschip_port *mos7840_port,
  *****************************************************************************/
 
 static int mos7840_set_modem_info(struct moschip_port *mos7840_port,
-                                 unsigned int cmd, unsigned int *value)
+                                 unsigned int cmd, unsigned int __user *value)
 {
        unsigned int mcr;
        unsigned int arg;
@@ -2342,7 +2332,7 @@ static int mos7840_set_modem_info(struct moschip_port *mos7840_port,
  *****************************************************************************/
 
 static int mos7840_get_modem_info(struct moschip_port *mos7840_port,
-                                 unsigned int *value)
+                                 unsigned int __user *value)
 {
        unsigned int result = 0;
        __u16 msr;
@@ -2371,7 +2361,7 @@ static int mos7840_get_modem_info(struct moschip_port *mos7840_port,
  *****************************************************************************/
 
 static int mos7840_get_serial_info(struct moschip_port *mos7840_port,
-                                  struct serial_struct *retinfo)
+                                  struct serial_struct __user *retinfo)
 {
        struct serial_struct tmp;
 
@@ -2406,6 +2396,7 @@ static int mos7840_get_serial_info(struct moschip_port *mos7840_port,
 static int mos7840_ioctl(struct usb_serial_port *port, struct file *file,
                         unsigned int cmd, unsigned long arg)
 {
+       void __user *argp = (void __user *)arg;
        struct moschip_port *mos7840_port;
        struct tty_struct *tty;
 
@@ -2422,11 +2413,12 @@ static int mos7840_ioctl(struct usb_serial_port *port, struct file *file,
        }
 
        mos7840_port = mos7840_get_port_private(port);
-       tty = mos7840_port->port->tty;
 
        if (mos7840_port == NULL)
                return -1;
 
+       tty = mos7840_port->port->tty;
+
        dbg("%s - port %d, cmd = 0x%x", __FUNCTION__, port->number, cmd);
 
        switch (cmd) {
@@ -2434,16 +2426,13 @@ static int mos7840_ioctl(struct usb_serial_port *port, struct file *file,
 
        case TIOCINQ:
                dbg("%s (%d) TIOCINQ", __FUNCTION__, port->number);
-               return mos7840_get_bytes_avail(mos7840_port,
-                                              (unsigned int *)arg);
-               break;
+               return mos7840_get_bytes_avail(mos7840_port, argp);
 
        case TIOCOUTQ:
                dbg("%s (%d) TIOCOUTQ", __FUNCTION__, port->number);
                return put_user(tty->driver->chars_in_buffer ?
                                tty->driver->chars_in_buffer(tty) : 0,
                                (int __user *)arg);
-               break;
 
        case TCFLSH:
                retval = tty_check_change(tty);
@@ -2473,13 +2462,13 @@ static int mos7840_ioctl(struct usb_serial_port *port, struct file *file,
 
        case TCGETS:
                if (kernel_termios_to_user_termios
-                   ((struct termios __user *)arg, tty->termios))
+                   ((struct termios __user *)argp, tty->termios))
                        return -EFAULT;
                return 0;
 
        case TIOCSERGETLSR:
                dbg("%s (%d) TIOCSERGETLSR", __FUNCTION__, port->number);
-               return mos7840_get_lsr_info(mos7840_port, (unsigned int *)arg);
+               return mos7840_get_lsr_info(mos7840_port, argp);
                return 0;
 
        case TIOCMBIS:
@@ -2488,19 +2477,16 @@ static int mos7840_ioctl(struct usb_serial_port *port, struct file *file,
                dbg("%s (%d) TIOCMSET/TIOCMBIC/TIOCMSET", __FUNCTION__,
                    port->number);
                mosret =
-                   mos7840_set_modem_info(mos7840_port, cmd,
-                                          (unsigned int *)arg);
+                   mos7840_set_modem_info(mos7840_port, cmd, argp);
                return mosret;
 
        case TIOCMGET:
                dbg("%s (%d) TIOCMGET", __FUNCTION__, port->number);
-               return mos7840_get_modem_info(mos7840_port,
-                                             (unsigned int *)arg);
+               return mos7840_get_modem_info(mos7840_port, argp);
 
        case TIOCGSERIAL:
                dbg("%s (%d) TIOCGSERIAL", __FUNCTION__, port->number);
-               return mos7840_get_serial_info(mos7840_port,
-                                              (struct serial_struct *)arg);
+               return mos7840_get_serial_info(mos7840_port, argp);
 
        case TIOCSSERIAL:
                dbg("%s (%d) TIOCSSERIAL", __FUNCTION__, port->number);
@@ -2550,7 +2536,7 @@ static int mos7840_ioctl(struct usb_serial_port *port, struct file *file,
 
                dbg("%s (%d) TIOCGICOUNT RX=%d, TX=%d", __FUNCTION__,
                    port->number, icount.rx, icount.tx);
-               if (copy_to_user((void *)arg, &icount, sizeof(icount)))
+               if (copy_to_user(argp, &icount, sizeof(icount)))
                        return -EFAULT;
                return 0;
 
@@ -2610,12 +2596,11 @@ static int mos7840_startup(struct usb_serial *serial)
 
        /* set up port private structures */
        for (i = 0; i < serial->num_ports; ++i) {
-               mos7840_port = kmalloc(sizeof(struct moschip_port), GFP_KERNEL);
+               mos7840_port = kzalloc(sizeof(struct moschip_port), GFP_KERNEL);
                if (mos7840_port == NULL) {
                        err("%s - Out of memory", __FUNCTION__);
                        return -ENOMEM;
                }
-               memset(mos7840_port, 0, sizeof(struct moschip_port));
 
                /* Initialize all port interrupt end point to port 0 int endpoint *
                 * Our device has only one interrupt end point comman to all port */
@@ -2801,7 +2786,7 @@ static int mos7840_startup(struct usb_serial *serial)
                                    i + 1, status);
 
                }
-               mos7840_port->control_urb = usb_alloc_urb(0, SLAB_ATOMIC);
+               mos7840_port->control_urb = usb_alloc_urb(0, GFP_ATOMIC);
                mos7840_port->ctrl_buf = kmalloc(16, GFP_KERNEL);
 
        }
@@ -2818,7 +2803,7 @@ static int mos7840_startup(struct usb_serial *serial)
 
        /* setting configuration feature to one */
        usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0),
-                       (__u8) 0x03, 0x00, 0x01, 0x00, 0x00, 0x00, 5 * HZ);
+                       (__u8) 0x03, 0x00, 0x01, 0x00, NULL, 0x00, 5 * HZ);
        return 0;
 }