VServer 1.9.2 (patch-2.6.8.1-vs1.9.2.diff)
[linux-2.6.git] / drivers / bluetooth / bt3c_cs.c
index 5aa5cd3..d67d038 100644 (file)
 #include <linux/module.h>
 
 #include <linux/kernel.h>
-#include <linux/kmod.h>
 #include <linux/init.h>
 #include <linux/slab.h>
-#include <linux/delay.h>
 #include <linux/types.h>
 #include <linux/sched.h>
+#include <linux/delay.h>
 #include <linux/errno.h>
 #include <linux/ptrace.h>
 #include <linux/ioport.h>
@@ -194,10 +193,8 @@ static int bt3c_write(unsigned int iobase, int fifo_size, __u8 *buf, int len)
 }
 
 
-static void bt3c_write_wakeup(bt3c_info_t *info, int from)
+static void bt3c_write_wakeup(bt3c_info_t *info)
 {
-       unsigned long flags;
-
        if (!info) {
                BT_ERR("Unknown device");
                return;
@@ -206,8 +203,6 @@ static void bt3c_write_wakeup(bt3c_info_t *info, int from)
        if (test_and_set_bit(XMIT_SENDING, &(info->tx_state)))
                return;
 
-       spin_lock_irqsave(&(info->lock), flags);
-
        do {
                register unsigned int iobase = info->link.io.BasePort1;
                register struct sk_buff *skb;
@@ -234,8 +229,6 @@ static void bt3c_write_wakeup(bt3c_info_t *info, int from)
                info->hdev->stat.byte_tx += len;
 
        } while (0);
-
-       spin_unlock_irqrestore(&(info->lock), flags);
 }
 
 
@@ -391,7 +384,7 @@ static irqreturn_t bt3c_interrupt(int irq, void *dev_inst, struct pt_regs *regs)
                        if (stat & 0x0002) {
                                //BT_ERR("Ack (stat=0x%04x)", stat);
                                clear_bit(XMIT_SENDING, &(info->tx_state));
-                               bt3c_write_wakeup(info, 1);
+                               bt3c_write_wakeup(info);
                        }
 
                        bt3c_io_write(iobase, 0x7001, 0x0000);
@@ -444,6 +437,7 @@ static int bt3c_hci_send_frame(struct sk_buff *skb)
 {
        bt3c_info_t *info;
        struct hci_dev *hdev = (struct hci_dev *)(skb->dev);
+       unsigned long flags;
 
        if (!hdev) {
                BT_ERR("Frame for unknown HCI device (hdev=NULL)");
@@ -468,7 +462,11 @@ static int bt3c_hci_send_frame(struct sk_buff *skb)
        memcpy(skb_push(skb, 1), &(skb->pkt_type), 1);
        skb_queue_tail(&(info->txq), skb);
 
-       bt3c_write_wakeup(info, 0);
+       spin_lock_irqsave(&(info->lock), flags);
+
+       bt3c_write_wakeup(info);
+
+       spin_unlock_irqrestore(&(info->lock), flags);
 
        return 0;
 }
@@ -489,12 +487,19 @@ static int bt3c_hci_ioctl(struct hci_dev *hdev, unsigned int cmd, unsigned long
 /* ======================== Card services HCI interaction ======================== */
 
 
-static struct device bt3c_device = {
-       .bus_id = "pcmcia",
-       .kobj = {
-               .k_name = "bt3c"
-       }
-};
+static struct device *bt3c_device(void)
+{
+       static char *kobj_name = "bt3c";
+
+       static struct device dev = {
+               .bus_id = "pcmcia",
+       };
+       dev.kobj.k_name = kmalloc(strlen(kobj_name) + 1, GFP_KERNEL);
+       strcpy(dev.kobj.k_name, kobj_name);
+       kobject_init(&dev.kobj);
+
+       return &dev;
+}
 
 
 static int bt3c_load_firmware(bt3c_info_t *info, unsigned char *firmware, int count)
@@ -617,7 +622,7 @@ int bt3c_open(bt3c_info_t *info)
        hdev->owner = THIS_MODULE;
 
        /* Load firmware */
-       err = request_firmware(&firmware, "BT3CPCC.bin", &bt3c_device);
+       err = request_firmware(&firmware, "BT3CPCC.bin", bt3c_device());
        if (err < 0) {
                BT_ERR("Firmware request failed");
                goto error;
@@ -633,8 +638,7 @@ int bt3c_open(bt3c_info_t *info)
        }
 
        /* Timeout before it is safe to send the first HCI packet */
-       set_current_state(TASK_INTERRUPTIBLE);
-       schedule_timeout(HZ);
+       msleep(1000);
 
        /* Register HCI device */
        err = hci_register_dev(hdev);