vserver 1.9.5.x5
[linux-2.6.git] / drivers / bluetooth / hci_ldisc.c
index 5964684..9075bbb 100644 (file)
@@ -32,7 +32,6 @@
 #include <linux/config.h>
 #include <linux/module.h>
 
-#include <linux/config.h>
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/sched.h>
@@ -52,6 +51,7 @@
 
 #include <net/bluetooth/bluetooth.h>
 #include <net/bluetooth/hci_core.h>
+
 #include "hci_uart.h"
 
 #ifndef CONFIG_BT_HCIUART_DEBUG
@@ -61,6 +61,8 @@
 #define BT_DMP( A... )
 #endif
 
+static int reset = 0;
+
 static struct hci_uart_proto *hup[HCI_UART_MAX_PROTO];
 
 int hci_uart_register_proto(struct hci_uart_proto *p)
@@ -144,7 +146,7 @@ restart:
                int len;
        
                set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
-               len = tty->driver->write(tty, 0, skb->data, skb->len);
+               len = tty->driver->write(tty, skb->data, skb->len);
                hdev->stat.byte_tx += len;
 
                skb_pull(skb, len);
@@ -189,9 +191,7 @@ static int hci_uart_flush(struct hci_dev *hdev)
        }
 
        /* Flush any pending characters in the driver and discipline. */
-       if (tty->ldisc.flush_buffer)
-               tty->ldisc.flush_buffer(tty);
-
+       tty_ldisc_flush(tty);
        if (tty->driver->flush_buffer)
                tty->driver->flush_buffer(tty);
 
@@ -281,7 +281,9 @@ static int hci_uart_tty_open(struct tty_struct *tty)
 
        spin_lock_init(&hu->rx_lock);
 
-       /* Flush any pending characters in the driver and line discipline */
+       /* Flush any pending characters in the driver and line discipline. */
+       /* FIXME: why is this needed. Note don't use ldisc_ref here as the
+          open path is before the ldisc is referencable */
        if (tty->ldisc.flush_buffer)
                tty->ldisc.flush_buffer(tty);
 
@@ -413,7 +415,10 @@ static int hci_uart_register_dev(struct hci_uart *hu)
        hdev->destruct = hci_uart_destruct;
 
        hdev->owner = THIS_MODULE;
-       
+
+       if (reset)
+               set_bit(HCI_QUIRK_RESET_ON_INIT, &hdev->quirks);
+
        if (hci_register_dev(hdev) < 0) {
                BT_ERR("Can't register HCI device");
                hci_free_dev(hdev);
@@ -499,7 +504,7 @@ static int hci_uart_tty_ioctl(struct tty_struct *tty, struct file * file,
 /*
  * We don't provide read/write/poll interface for user space.
  */
-static ssize_t hci_uart_tty_read(struct tty_struct *tty, struct file *file, unsigned char *buf, size_t nr)
+static ssize_t hci_uart_tty_read(struct tty_struct *tty, struct file *file, unsigned char __user *buf, size_t nr)
 {
        return 0;
 }
@@ -578,7 +583,10 @@ static void __exit hci_uart_exit(void)
 module_init(hci_uart_init);
 module_exit(hci_uart_exit);
 
-MODULE_AUTHOR("Maxim Krasnyansky <maxk@qualcomm.com>");
+module_param(reset, bool, 0644);
+MODULE_PARM_DESC(reset, "Send HCI reset command on initialization");
+
+MODULE_AUTHOR("Maxim Krasnyansky <maxk@qualcomm.com>, Marcel Holtmann <marcel@holtmann.org>");
 MODULE_DESCRIPTION("Bluetooth HCI UART driver ver " VERSION);
 MODULE_VERSION(VERSION);
 MODULE_LICENSE("GPL");