--- zzzz-none-000/linux-2.4.17/drivers/bluetooth/hci_vhci.c 2001-09-07 16:28:38.000000000 +0000 +++ sangam-fb-401/linux-2.4.17/drivers/bluetooth/hci_vhci.c 2005-04-05 07:07:46.000000000 +0000 @@ -25,9 +25,9 @@ /* * BlueZ HCI virtual device driver. * - * $Id: hci_vhci.c,v 1.3 2001/08/03 04:19:50 maxk Exp $ + * $Id: hci_vhci.c,v 1.3 2002/04/17 17:37:20 maxk Exp $ */ -#define VERSION "1.0" +#define VERSION "1.1" #include #include @@ -49,43 +49,56 @@ #include #include -#include #include -#include +#include "hci_vhci.h" /* HCI device part */ -int hci_vhci_open(struct hci_dev *hdev) +static int hci_vhci_open(struct hci_dev *hdev) { - hdev->flags |= HCI_RUNNING; + set_bit(HCI_RUNNING, &hdev->flags); return 0; } -int hci_vhci_flush(struct hci_dev *hdev) +static int hci_vhci_flush(struct hci_dev *hdev) { struct hci_vhci_struct *hci_vhci = (struct hci_vhci_struct *) hdev->driver_data; skb_queue_purge(&hci_vhci->readq); return 0; } -int hci_vhci_close(struct hci_dev *hdev) +static int hci_vhci_close(struct hci_dev *hdev) { - hdev->flags &= ~HCI_RUNNING; + if (!test_and_clear_bit(HCI_RUNNING, &hdev->flags)) + return 0; + hci_vhci_flush(hdev); return 0; } -int hci_vhci_send_frame(struct sk_buff *skb) +static void hci_vhci_destruct(struct hci_dev *hdev) +{ + struct hci_vhci_struct *vhci; + + if (!hdev) return; + + vhci = (struct hci_vhci_struct *) hdev->driver_data; + kfree(vhci); + + MOD_DEC_USE_COUNT; +} + +static int hci_vhci_send_frame(struct sk_buff *skb) { struct hci_dev* hdev = (struct hci_dev *) skb->dev; struct hci_vhci_struct *hci_vhci; if (!hdev) { - ERR("Frame for uknown device (hdev=NULL)"); + BT_ERR("Frame for uknown device (hdev=NULL)"); return -ENODEV; } - if (!(hdev->flags & HCI_RUNNING)) + if (!test_bit(HCI_RUNNING, &hdev->flags)) return -EBUSY; hci_vhci = (struct hci_vhci_struct *) hdev->driver_data; @@ -188,7 +201,7 @@ add_wait_queue(&hci_vhci->read_wait, &wait); while (count) { - current->state = TASK_INTERRUPTIBLE; + set_current_state(TASK_INTERRUPTIBLE); /* Read frames from device queue */ if (!(skb = skb_dequeue(&hci_vhci->readq))) { @@ -214,8 +227,7 @@ kfree_skb(skb); break; } - - current->state = TASK_RUNNING; + set_current_state(TASK_RUNNING); remove_wait_queue(&hci_vhci->read_wait, &wait); return ret; @@ -270,11 +282,13 @@ hdev->close = hci_vhci_close; hdev->flush = hci_vhci_flush; hdev->send = hci_vhci_send_frame; + hdev->destruct = hci_vhci_destruct; if (hci_register_dev(hdev) < 0) { kfree(hci_vhci); return -EBUSY; } + MOD_INC_USE_COUNT; file->private_data = hci_vhci; return 0; @@ -285,12 +299,10 @@ struct hci_vhci_struct *hci_vhci = (struct hci_vhci_struct *) file->private_data; if (hci_unregister_dev(&hci_vhci->hdev) < 0) { - ERR("Can't unregister HCI device %s", hci_vhci->hdev.name); + BT_ERR("Can't unregister HCI device %s", hci_vhci->hdev.name); } - kfree(hci_vhci); file->private_data = NULL; - return 0; } @@ -315,12 +327,12 @@ int __init hci_vhci_init(void) { - INF("BlueZ VHCI driver ver %s Copyright (C) 2000,2001 Qualcomm Inc", + BT_INFO("BlueZ VHCI driver ver %s Copyright (C) 2000,2001 Qualcomm Inc", VERSION); - INF("Written 2000,2001 by Maxim Krasnyansky "); + BT_INFO("Written 2000,2001 by Maxim Krasnyansky "); if (misc_register(&hci_vhci_miscdev)) { - ERR("Can't register misc device %d\n", VHCI_MINOR); + BT_ERR("Can't register misc device %d\n", VHCI_MINOR); return -EIO; } @@ -337,4 +349,4 @@ MODULE_AUTHOR("Maxim Krasnyansky "); MODULE_DESCRIPTION("BlueZ VHCI driver ver " VERSION); -MODULE_LICENSE("GPL"); +MODULE_LICENSE("GPL");