[Bluetooth] Code cleanup for the HCI UART driver
[pandora-kernel.git] / drivers / bluetooth / hci_ldisc.c
index 573ff6c..420b645 100644 (file)
@@ -23,7 +23,6 @@
  *
  */
 
-#include <linux/config.h>
 #include <linux/module.h>
 
 #include <linux/kernel.h>
@@ -192,7 +191,7 @@ static int hci_uart_flush(struct hci_dev *hdev)
 
        /* Flush any pending characters in the driver and discipline. */
        tty_ldisc_flush(tty);
-       if (tty->driver->flush_buffer)
+       if (tty->driver && tty->driver->flush_buffer)
                tty->driver->flush_buffer(tty);
 
        if (test_bit(HCI_UART_PROTO_SET, &hu->flags))
@@ -242,15 +241,11 @@ static int hci_uart_send_frame(struct sk_buff *skb)
 
 static void hci_uart_destruct(struct hci_dev *hdev)
 {
-       struct hci_uart *hu;
-
        if (!hdev)
                return;
 
        BT_DBG("%s", hdev->name);
-
-       hu = (struct hci_uart *) hdev->driver_data;
-       kfree(hu);
+       kfree(hdev->driver_data);
 }
 
 /* ------ LDISC part ------ */
@@ -273,12 +268,13 @@ static int hci_uart_tty_open(struct tty_struct *tty)
                return -EEXIST;
 
        if (!(hu = kzalloc(sizeof(struct hci_uart), GFP_KERNEL))) {
-               BT_ERR("Can't allocate controll structure");
+               BT_ERR("Can't allocate control structure");
                return -ENFILE;
        }
 
        tty->disc_data = hu;
        hu->tty = tty;
+       tty->receive_room = 65536;
 
        spin_lock_init(&hu->rx_lock);
 
@@ -290,7 +286,7 @@ static int hci_uart_tty_open(struct tty_struct *tty)
        if (tty->ldisc.flush_buffer)
                tty->ldisc.flush_buffer(tty);
 
-       if (tty->driver->flush_buffer)
+       if (tty->driver && tty->driver->flush_buffer)
                tty->driver->flush_buffer(tty);
 
        return 0;
@@ -348,20 +344,6 @@ static void hci_uart_tty_wakeup(struct tty_struct *tty)
                hci_uart_tx_wakeup(hu);
 }
 
-/* hci_uart_tty_room()
- * 
- *    Callback function from tty driver. Return the amount of 
- *    space left in the receiver's buffer to decide if remote
- *    transmitter is to be throttled.
- *
- * Arguments:        tty    pointer to associated tty instance data
- * Return Value:    number of bytes left in receive buffer
- */
-static int hci_uart_tty_room (struct tty_struct *tty)
-{
-       return 65536;
-}
-
 /* hci_uart_tty_receive()
  * 
  *     Called by tty low level driver when receive data is
@@ -374,7 +356,7 @@ static int hci_uart_tty_room (struct tty_struct *tty)
  *     
  * Return Value:    None
  */
-static void hci_uart_tty_receive(struct tty_struct *tty, const __u8 *data, char *flags, int count)
+static void hci_uart_tty_receive(struct tty_struct *tty, const u8 *data, char *flags, int count)
 {
        struct hci_uart *hu = (void *)tty->disc_data;
 
@@ -389,7 +371,8 @@ static void hci_uart_tty_receive(struct tty_struct *tty, const __u8 *data, char
        hu->hdev->stat.byte_rx += count;
        spin_unlock(&hu->rx_lock);
 
-       if (test_and_clear_bit(TTY_THROTTLED,&tty->flags) && tty->driver->unthrottle)
+       if (test_and_clear_bit(TTY_THROTTLED, &tty->flags) &&
+                                       tty->driver->unthrottle)
                tty->driver->unthrottle(tty);
 }
 
@@ -544,7 +527,6 @@ static int __init hci_uart_init(void)
        hci_uart_ldisc.write            = hci_uart_tty_write;
        hci_uart_ldisc.ioctl            = hci_uart_tty_ioctl;
        hci_uart_ldisc.poll             = hci_uart_tty_poll;
-       hci_uart_ldisc.receive_room     = hci_uart_tty_room;
        hci_uart_ldisc.receive_buf      = hci_uart_tty_receive;
        hci_uart_ldisc.write_wakeup     = hci_uart_tty_wakeup;
        hci_uart_ldisc.owner            = THIS_MODULE;