Merge to Fedora kernel-2.6.18-1.2239_FC5 patched with stable patch-2.6.18.2-vs2.0...
[linux-2.6.git] / drivers / usb / class / bluetty.c
index 0ae754e..5240233 100644 (file)
@@ -207,7 +207,7 @@ struct usb_bluetooth {
 /* local function prototypes */
 static int  bluetooth_open             (struct tty_struct *tty, struct file *filp);
 static void bluetooth_close            (struct tty_struct *tty, struct file *filp);
-static int  bluetooth_write            (struct tty_struct *tty, int from_user, const unsigned char *buf, int count);
+static int  bluetooth_write            (struct tty_struct *tty, const unsigned char *buf, int count);
 static int  bluetooth_write_room       (struct tty_struct *tty);
 static int  bluetooth_chars_in_buffer  (struct tty_struct *tty);
 static void bluetooth_throttle         (struct tty_struct *tty);
@@ -309,7 +309,7 @@ static int bluetooth_ctrl_msg (struct usb_bluetooth *bluetooth, int request, int
                }
        }
        if (urb->transfer_buffer_length < len) {
-               kfree (urb->transfer_buffer);
+               kfree(urb->transfer_buffer);
                urb->transfer_buffer = kmalloc (len, GFP_KERNEL);
                if (urb->transfer_buffer == NULL) {
                        err ("%s - out of memory", __FUNCTION__);
@@ -426,14 +426,14 @@ static void bluetooth_close (struct tty_struct *tty, struct file * filp)
                bluetooth->open_count = 0;
 
                /* shutdown any in-flight urbs that we know about */
-               usb_unlink_urb (bluetooth->read_urb);
-               usb_unlink_urb (bluetooth->interrupt_in_urb);
+               usb_kill_urb (bluetooth->read_urb);
+               usb_kill_urb (bluetooth->interrupt_in_urb);
        }
        up(&bluetooth->lock);
 }
 
 
-static int bluetooth_write (struct tty_struct * tty, int from_user, const unsigned char *buf, int count)
+static int bluetooth_write (struct tty_struct * tty, const unsigned char *buf, int count)
 {
        struct usb_bluetooth *bluetooth = get_usb_bluetooth ((struct usb_bluetooth *)tty->driver_data, __FUNCTION__);
        struct urb *urb = NULL;
@@ -471,21 +471,7 @@ static int bluetooth_write (struct tty_struct * tty, int from_user, const unsign
        printk ("\n");
 #endif
 
-       if (from_user) {
-               temp_buffer = kmalloc (count, GFP_KERNEL);
-               if (temp_buffer == NULL) {
-                       err ("%s - out of memory.", __FUNCTION__);
-                       retval = -ENOMEM;
-                       goto exit;
-               }
-               if (copy_from_user (temp_buffer, (void __user *)buf, count)) {
-                       retval = -EFAULT;
-                       goto exit;
-               }
-               current_buffer = temp_buffer;
-       } else {
-               current_buffer = buf;
-       }
+       current_buffer = buf;
 
        switch (*current_buffer) {
                /* First byte indicates the type of packet */
@@ -549,7 +535,7 @@ static int bluetooth_write (struct tty_struct * tty, int from_user, const unsign
        }
 
 exit:
-       kfree (temp_buffer);
+       kfree(temp_buffer);
 
        return retval;
 } 
@@ -705,7 +691,7 @@ void btusb_disable_bulk_read(struct tty_struct *tty){
        }
 
        if ((bluetooth->read_urb) && (bluetooth->read_urb->actual_length))
-               usb_unlink_urb(bluetooth->read_urb);
+               usb_kill_urb(bluetooth->read_urb);
 }
 #endif
 
@@ -988,21 +974,13 @@ static void bluetooth_write_bulk_callback (struct urb *urb, struct pt_regs *regs
 static void bluetooth_softint(void *private)
 {
        struct usb_bluetooth *bluetooth = get_usb_bluetooth ((struct usb_bluetooth *)private, __FUNCTION__);
-       struct tty_struct *tty;
 
        dbg("%s", __FUNCTION__);
 
-       if (!bluetooth) {
+       if (!bluetooth)
                return;
-       }
-
-       tty = bluetooth->tty;
-       if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) && tty->ldisc.write_wakeup) {
-               dbg("%s - write wakeup call.", __FUNCTION__);
-               (tty->ldisc.write_wakeup)(tty);
-       }
 
-       wake_up_interruptible(&tty->write_wait);
+       tty_wakeup(bluetooth->tty);
 }
 
 
@@ -1108,7 +1086,7 @@ static int usb_bluetooth_probe (struct usb_interface *intf,
                err("No free urbs available");
                goto probe_error;
        }
-       bluetooth->bulk_in_buffer_size = buffer_size = endpoint->wMaxPacketSize;
+       bluetooth->bulk_in_buffer_size = buffer_size = le16_to_cpu(endpoint->wMaxPacketSize);
        bluetooth->bulk_in_endpointAddress = endpoint->bEndpointAddress;
        bluetooth->bulk_in_buffer = kmalloc (buffer_size, GFP_KERNEL);
        if (!bluetooth->bulk_in_buffer) {
@@ -1120,7 +1098,7 @@ static int usb_bluetooth_probe (struct usb_interface *intf,
 
        endpoint = bulk_out_endpoint[0];
        bluetooth->bulk_out_endpointAddress = endpoint->bEndpointAddress;
-       bluetooth->bulk_out_buffer_size = endpoint->wMaxPacketSize * 2;
+       bluetooth->bulk_out_buffer_size = le16_to_cpu(endpoint->wMaxPacketSize) * 2;
 
        endpoint = interrupt_in_endpoint[0];
        bluetooth->interrupt_in_urb = usb_alloc_urb(0, GFP_KERNEL);
@@ -1128,7 +1106,7 @@ static int usb_bluetooth_probe (struct usb_interface *intf,
                err("No free urbs available");
                goto probe_error;
        }
-       bluetooth->interrupt_in_buffer_size = buffer_size = endpoint->wMaxPacketSize;
+       bluetooth->interrupt_in_buffer_size = buffer_size = le16_to_cpu(endpoint->wMaxPacketSize);
        bluetooth->interrupt_in_endpointAddress = endpoint->bEndpointAddress;
        bluetooth->interrupt_in_interval = endpoint->bInterval;
        bluetooth->interrupt_in_buffer = kmalloc (buffer_size, GFP_KERNEL);
@@ -1187,14 +1165,14 @@ static void usb_bluetooth_disconnect(struct usb_interface *intf)
                bluetooth->open_count = 0;
 
                if (bluetooth->read_urb) {
-                       usb_unlink_urb (bluetooth->read_urb);
+                       usb_kill_urb (bluetooth->read_urb);
                        usb_free_urb (bluetooth->read_urb);
                }
                if (bluetooth->bulk_in_buffer)
                        kfree (bluetooth->bulk_in_buffer);
 
                if (bluetooth->interrupt_in_urb) {
-                       usb_unlink_urb (bluetooth->interrupt_in_urb);
+                       usb_kill_urb (bluetooth->interrupt_in_urb);
                        usb_free_urb (bluetooth->interrupt_in_urb);
                }
                if (bluetooth->interrupt_in_buffer)
@@ -1204,7 +1182,7 @@ static void usb_bluetooth_disconnect(struct usb_interface *intf)
 
                for (i = 0; i < NUM_CONTROL_URBS; ++i) {
                        if (bluetooth->control_urb_pool[i]) {
-                               usb_unlink_urb (bluetooth->control_urb_pool[i]);
+                               usb_kill_urb (bluetooth->control_urb_pool[i]);
                                if (bluetooth->control_urb_pool[i]->transfer_buffer)
                                        kfree (bluetooth->control_urb_pool[i]->transfer_buffer);
                                usb_free_urb (bluetooth->control_urb_pool[i]);
@@ -1234,7 +1212,7 @@ static struct tty_operations bluetooth_ops = {
        .chars_in_buffer =      bluetooth_chars_in_buffer,
 };
 
-int usb_bluetooth_init(void)
+static int usb_bluetooth_init(void)
 {
        int i;
        int result;
@@ -1283,7 +1261,7 @@ int usb_bluetooth_init(void)
 }
 
 
-void usb_bluetooth_exit(void)
+static void usb_bluetooth_exit(void)
 {
        usb_deregister(&usb_bluetooth_driver);
        tty_unregister_driver(bluetooth_tty_driver);