diff options
| author | Marcel Holtmann <marcel@holtmann.org> | 2004-04-05 15:36:39 +0200 |
|---|---|---|
| committer | Marcel Holtmann <marcel@holtmann.org> | 2004-04-05 15:36:39 +0200 |
| commit | d0a65087dbddf4be565b693c8f156b98151a38d0 (patch) | |
| tree | b464af91e2fcb3e56b44165876fc6bdd70f815c1 /drivers | |
| parent | 7b00dc76e18522fecc6c133fd9b46bbf2a5a065f (diff) | |
[Bluetooth] Allocate hdev before device configuration
The hdev structure must be allocated before the device is configured and
before any interrupt is started.
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/bluetooth/bluecard_cs.c | 48 | ||||
| -rw-r--r-- | drivers/bluetooth/bt3c_cs.c | 38 | ||||
| -rw-r--r-- | drivers/bluetooth/btuart_cs.c | 46 | ||||
| -rw-r--r-- | drivers/bluetooth/dtl1_cs.c | 46 |
4 files changed, 89 insertions, 89 deletions
diff --git a/drivers/bluetooth/bluecard_cs.c b/drivers/bluetooth/bluecard_cs.c index 9261f0d9ab72..e26b62ebfb09 100644 --- a/drivers/bluetooth/bluecard_cs.c +++ b/drivers/bluetooth/bluecard_cs.c @@ -505,13 +505,13 @@ static irqreturn_t bluecard_interrupt(int irq, void *dev_inst, struct pt_regs *r unsigned int iobase; unsigned char reg; - if (!info) { + if (!info || !info->hdev) { BT_ERR("Call of irq %d for unknown device", irq); return IRQ_NONE; } if (!test_bit(CARD_READY, &(info->hw_state))) - return IRQ_NONE; + return IRQ_HANDLED; iobase = info->link.io.BasePort1; @@ -725,6 +725,27 @@ int bluecard_open(bluecard_info_t *info) info->rx_count = 0; info->rx_skb = NULL; + /* Initialize HCI device */ + hdev = hci_alloc_dev(); + if (!hdev) { + BT_ERR("Can't allocate HCI device"); + return -ENOMEM; + } + + info->hdev = hdev; + + hdev->type = HCI_PCCARD; + hdev->driver_data = info; + + hdev->open = bluecard_hci_open; + hdev->close = bluecard_hci_close; + hdev->flush = bluecard_hci_flush; + hdev->send = bluecard_hci_send_frame; + hdev->destruct = bluecard_hci_destruct; + hdev->ioctl = bluecard_hci_ioctl; + + hdev->owner = THIS_MODULE; + id = inb(iobase + 0x30); if ((id & 0x0f) == 0x02) @@ -776,28 +797,7 @@ int bluecard_open(bluecard_info_t *info) set_current_state(TASK_INTERRUPTIBLE); schedule_timeout((HZ * 5) / 4); // or set it to 3/2 - - /* Initialize and register HCI device */ - hdev = hci_alloc_dev(); - if (!hdev) { - BT_ERR("Can't allocate HCI device"); - return -ENOMEM; - } - - info->hdev = hdev; - - hdev->type = HCI_PCCARD; - hdev->driver_data = info; - - hdev->open = bluecard_hci_open; - hdev->close = bluecard_hci_close; - hdev->flush = bluecard_hci_flush; - hdev->send = bluecard_hci_send_frame; - hdev->destruct = bluecard_hci_destruct; - hdev->ioctl = bluecard_hci_ioctl; - - hdev->owner = THIS_MODULE; - + /* Register HCI device */ if (hci_register_dev(hdev) < 0) { BT_ERR("Can't register HCI device"); hci_free_dev(hdev); diff --git a/drivers/bluetooth/bt3c_cs.c b/drivers/bluetooth/bt3c_cs.c index 5cd700f50248..d3da402003bf 100644 --- a/drivers/bluetooth/bt3c_cs.c +++ b/drivers/bluetooth/bt3c_cs.c @@ -361,7 +361,7 @@ static irqreturn_t bt3c_interrupt(int irq, void *dev_inst, struct pt_regs *regs) unsigned int iobase; int iir; - if (!info) { + if (!info || !info->hdev) { BT_ERR("Call of irq %d for unknown device", irq); return IRQ_NONE; } @@ -522,18 +522,7 @@ int bt3c_open(bt3c_info_t *info) info->rx_count = 0; info->rx_skb = NULL; - /* Load firmware */ - - if ((err = bt3c_firmware_load(info)) < 0) - return err; - - /* Timeout before it is safe to send the first HCI packet */ - - set_current_state(TASK_INTERRUPTIBLE); - schedule_timeout(HZ); - - - /* Initialize and register HCI device */ + /* Initialize HCI device */ hdev = hci_alloc_dev(); if (!hdev) { BT_ERR("Can't allocate HCI device"); @@ -545,15 +534,26 @@ int bt3c_open(bt3c_info_t *info) hdev->type = HCI_PCCARD; hdev->driver_data = info; - hdev->open = bt3c_hci_open; - hdev->close = bt3c_hci_close; - hdev->flush = bt3c_hci_flush; - hdev->send = bt3c_hci_send_frame; + hdev->open = bt3c_hci_open; + hdev->close = bt3c_hci_close; + hdev->flush = bt3c_hci_flush; + hdev->send = bt3c_hci_send_frame; hdev->destruct = bt3c_hci_destruct; - hdev->ioctl = bt3c_hci_ioctl; + hdev->ioctl = bt3c_hci_ioctl; hdev->owner = THIS_MODULE; - + + /* Load firmware */ + + if ((err = bt3c_firmware_load(info)) < 0) + return err; + + /* Timeout before it is safe to send the first HCI packet */ + + set_current_state(TASK_INTERRUPTIBLE); + schedule_timeout(HZ); + + /* Register HCI device */ if (hci_register_dev(hdev) < 0) { BT_ERR("Can't register HCI device"); hci_free_dev(hdev); diff --git a/drivers/bluetooth/btuart_cs.c b/drivers/bluetooth/btuart_cs.c index ceb6b3612873..62f3ceb6565d 100644 --- a/drivers/bluetooth/btuart_cs.c +++ b/drivers/bluetooth/btuart_cs.c @@ -308,7 +308,7 @@ static irqreturn_t btuart_interrupt(int irq, void *dev_inst, struct pt_regs *reg int boguscount = 0; int iir, lsr; - if (!info) { + if (!info || !info->hdev) { BT_ERR("Call of irq %d for unknown device", irq); return IRQ_NONE; } @@ -504,6 +504,27 @@ int btuart_open(btuart_info_t *info) info->rx_count = 0; info->rx_skb = NULL; + /* Initialize HCI device */ + hdev = hci_alloc_dev(); + if (!hdev) { + BT_ERR("Can't allocate HCI device"); + return -ENOMEM; + } + + info->hdev = hdev; + + hdev->type = HCI_PCCARD; + hdev->driver_data = info; + + hdev->open = btuart_hci_open; + hdev->close = btuart_hci_close; + hdev->flush = btuart_hci_flush; + hdev->send = btuart_hci_send_frame; + hdev->destruct = btuart_hci_destruct; + hdev->ioctl = btuart_hci_ioctl; + + hdev->owner = THIS_MODULE; + spin_lock_irqsave(&(info->lock), flags); /* Reset UART */ @@ -527,28 +548,7 @@ int btuart_open(btuart_info_t *info) set_current_state(TASK_INTERRUPTIBLE); schedule_timeout(HZ); - - /* Initialize and register HCI device */ - hdev = hci_alloc_dev(); - if (!hdev) { - BT_ERR("Can't allocate HCI device"); - return -ENOMEM; - } - - info->hdev = hdev; - - hdev->type = HCI_PCCARD; - hdev->driver_data = info; - - hdev->open = btuart_hci_open; - hdev->close = btuart_hci_close; - hdev->flush = btuart_hci_flush; - hdev->send = btuart_hci_send_frame; - hdev->destruct = btuart_hci_destruct; - hdev->ioctl = btuart_hci_ioctl; - - hdev->owner = THIS_MODULE; - + /* Register HCI device */ if (hci_register_dev(hdev) < 0) { BT_ERR("Can't register HCI device"); hci_free_dev(hdev); diff --git a/drivers/bluetooth/dtl1_cs.c b/drivers/bluetooth/dtl1_cs.c index 040c5304b04b..b037369cfdc5 100644 --- a/drivers/bluetooth/dtl1_cs.c +++ b/drivers/bluetooth/dtl1_cs.c @@ -312,7 +312,7 @@ static irqreturn_t dtl1_interrupt(int irq, void *dev_inst, struct pt_regs *regs) int boguscount = 0; int iir, lsr; - if (!info) { + if (!info || !info->hdev) { BT_ERR("Call of irq %d for unknown device", irq); return IRQ_NONE; } @@ -483,6 +483,27 @@ int dtl1_open(dtl1_info_t *info) set_bit(XMIT_WAITING, &(info->tx_state)); + /* Initialize HCI device */ + hdev = hci_alloc_dev(); + if (!hdev) { + BT_ERR("Can't allocate HCI device"); + return -ENOMEM; + } + + info->hdev = hdev; + + hdev->type = HCI_PCCARD; + hdev->driver_data = info; + + hdev->open = dtl1_hci_open; + hdev->close = dtl1_hci_close; + hdev->flush = dtl1_hci_flush; + hdev->send = dtl1_hci_send_frame; + hdev->destruct = dtl1_hci_destruct; + hdev->ioctl = dtl1_hci_ioctl; + + hdev->owner = THIS_MODULE; + spin_lock_irqsave(&(info->lock), flags); /* Reset UART */ @@ -506,28 +527,7 @@ int dtl1_open(dtl1_info_t *info) set_current_state(TASK_INTERRUPTIBLE); schedule_timeout(HZ * 2); - - /* Initialize and register HCI device */ - hdev = hci_alloc_dev(); - if (!hdev) { - BT_ERR("Can't allocate HCI device"); - return -ENOMEM; - } - - info->hdev = hdev; - - hdev->type = HCI_PCCARD; - hdev->driver_data = info; - - hdev->open = dtl1_hci_open; - hdev->close = dtl1_hci_close; - hdev->flush = dtl1_hci_flush; - hdev->send = dtl1_hci_send_frame; - hdev->destruct = dtl1_hci_destruct; - hdev->ioctl = dtl1_hci_ioctl; - - hdev->owner = THIS_MODULE; - + /* Register HCI device */ if (hci_register_dev(hdev) < 0) { BT_ERR("Can't register HCI device"); hci_free_dev(hdev); |
