X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fbluetooth%2Fbt3c_cs.c;h=d67d0385f20bdf2caddc7025be270ad6af618c86;hb=9bf4aaab3e101692164d49b7ca357651eb691cb6;hp=5aa5cd3a2e25a5fb2268806942399e270b10cd49;hpb=db216c3d5e4c040e557a50f8f5d35d5c415e8c1c;p=linux-2.6.git diff --git a/drivers/bluetooth/bt3c_cs.c b/drivers/bluetooth/bt3c_cs.c index 5aa5cd3a2..d67d0385f 100644 --- a/drivers/bluetooth/bt3c_cs.c +++ b/drivers/bluetooth/bt3c_cs.c @@ -25,12 +25,11 @@ #include #include -#include #include #include -#include #include #include +#include #include #include #include @@ -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);