static int hci_uart_register_dev(struct hci_uart *hu) { struct hci_dev *hdev; BT_DBG(""); /* Initialize and register HCI device */ hdev = hci_alloc_dev(); if (!hdev) { BT_ERR("Can't allocate HCI device"); return -ENOMEM; } hu->hdev = hdev; hdev->type = HCI_UART; hdev->driver_data = hu; hdev->open = hci_uart_open; hdev->close = hci_uart_close; hdev->flush = hci_uart_flush; hdev->send = hci_uart_send_frame; hdev->destruct = hci_uart_destruct; hdev->owner = THIS_MODULE; if (hci_register_dev(hdev) < 0) { BT_ERR("Can't register HCI device"); hci_free_dev(hdev); return -ENODEV; } return 0; }
static int hci_h4p_register_hdev(struct hci_h4p_info *info) { struct hci_dev *hdev; /* Initialize and register HCI device */ hdev = hci_alloc_dev(); if (!hdev) { dev_err(info->dev, "Can't allocate memory for device\n"); return -ENOMEM; } info->hdev = hdev; hdev->type = HCI_UART; hdev->driver_data = info; hdev->open = hci_h4p_hci_open; hdev->close = hci_h4p_hci_close; hdev->flush = hci_h4p_hci_flush; hdev->send = hci_h4p_hci_send_frame; hdev->destruct = hci_h4p_hci_destruct; hdev->ioctl = hci_h4p_hci_ioctl; set_bit(HCI_QUIRK_NO_RESET, &hdev->quirks); hdev->owner = THIS_MODULE; if (hci_register_dev(hdev) < 0) { dev_err(info->dev, "hci_register failed %s.\n", hdev->name); return -ENODEV; } return 0; }
static int brf6150_register_hdev(struct brf6150_info *info) { struct hci_dev *hdev; /* Initialize and register HCI device */ hdev = hci_alloc_dev(); if (!hdev) { printk(KERN_WARNING "brf6150: Can't allocate memory for device\n"); return -ENOMEM; } info->hdev = hdev; hdev->type = HCI_UART; hdev->driver_data = info; hdev->open = brf6150_hci_open; hdev->close = brf6150_hci_close; hdev->destruct = brf6150_hci_destruct; hdev->flush = brf6150_hci_flush; hdev->send = brf6150_hci_send_frame; hdev->destruct = brf6150_hci_destruct; hdev->ioctl = brf6150_hci_ioctl; hdev->owner = THIS_MODULE; if (hci_register_dev(hdev) < 0) { printk(KERN_WARNING "brf6150: Can't register HCI device %s.\n", hdev->name); return -ENODEV; } return 0; }
static int hci_uart_register_dev(struct hci_uart *hu) { struct hci_dev *hdev; BT_DBG(""); /* Initialize and register HCI device */ hdev = hci_alloc_dev(); if (!hdev) { BT_ERR("Can't allocate HCI device"); return -ENOMEM; } hu->hdev = hdev; hdev->bus = HCI_UART; hci_set_drvdata(hdev, hu); /* Only when vendor specific setup callback is provided, consider * the manufacturer information valid. This avoids filling in the * value for Ericsson when nothing is specified. */ if (hu->proto->setup) hdev->manufacturer = hu->proto->manufacturer; hdev->open = hci_uart_open; hdev->close = hci_uart_close; hdev->flush = hci_uart_flush; hdev->send = hci_uart_send_frame; hdev->setup = hci_uart_setup; SET_HCIDEV_DEV(hdev, hu->tty->dev); if (test_bit(HCI_UART_RAW_DEVICE, &hu->hdev_flags)) set_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks); if (test_bit(HCI_UART_EXT_CONFIG, &hu->hdev_flags)) set_bit(HCI_QUIRK_EXTERNAL_CONFIG, &hdev->quirks); if (!test_bit(HCI_UART_RESET_ON_INIT, &hu->hdev_flags)) set_bit(HCI_QUIRK_RESET_ON_CLOSE, &hdev->quirks); if (test_bit(HCI_UART_CREATE_AMP, &hu->hdev_flags)) hdev->dev_type = HCI_AMP; else hdev->dev_type = HCI_PRIMARY; if (test_bit(HCI_UART_INIT_PENDING, &hu->hdev_flags)) return 0; if (hci_register_dev(hdev) < 0) { BT_ERR("Can't register HCI device"); hu->hdev = NULL; hci_free_dev(hdev); return -ENODEV; } set_bit(HCI_UART_REGISTERED, &hu->flags); return 0; }
static int hci_smd_register_dev(struct hci_smd_data *hsmd) { static struct hci_dev *hdev; int rc; /* Initialize and register HCI device */ hdev = hci_alloc_dev(); if (!hdev) { BT_ERR("Can't allocate HCI device"); return -ENOMEM; } hsmd->hdev = hdev; hdev->bus = HCI_SMD; hdev->driver_data = NULL; hdev->open = hci_smd_open; hdev->close = hci_smd_close; hdev->send = hci_smd_send_frame; hdev->destruct = hci_smd_destruct; hdev->owner = THIS_MODULE; tasklet_init(&hsmd->rx_task, hci_smd_rx, (unsigned long) hsmd); /* * Setup the timer to monitor whether the Rx queue is empty, * to control the wake lock release */ setup_timer(&hsmd->rx_q_timer, schedule_timer, (unsigned long) hsmd->hdev); /* Open the SMD Channel and device and register the callback function */ rc = smd_named_open_on_edge(EVENT_CHANNEL, SMD_APPS_WCNSS, &hsmd->event_channel, hdev, hci_smd_notify_event); if (rc < 0) { BT_ERR("Cannot open the command channel"); hci_free_dev(hdev); hdev = NULL; return -ENODEV; } rc = smd_named_open_on_edge(DATA_CHANNEL, SMD_APPS_WCNSS, &hsmd->data_channel, hdev, hci_smd_notify_data); if (rc < 0) { BT_ERR("Failed to open the Data channel"); hci_free_dev(hdev); hdev = NULL; return -ENODEV; } /* Disable the read interrupts on the channel */ smd_disable_read_intr(hsmd->event_channel); smd_disable_read_intr(hsmd->data_channel); if (hci_register_dev(hdev) < 0) { BT_ERR("Can't register HCI device"); hci_free_dev(hdev); return -ENODEV; } return 0; }
int rtbt_hps_iface_init( IN int if_type, IN void *if_dev, IN struct rtbt_os_ctrl *os_ctrl) { struct hci_dev *hdev; printk("--->%s(): if_type=%d\n", __FUNCTION__, if_type); /* Initialize HCI device */ hdev = hci_alloc_dev(); if (!hdev) { printk("Can't allocate HCI device\n"); return -1; } switch (if_type) { case RAL_INF_PCI: { struct pci_dev *pcidev = (struct pci_dev *)if_dev; #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34) hdev->bus = HCI_PCI; hdev->dev_type = HCI_BREDR; #else hdev->type = HCI_PCI; #endif pci_set_drvdata(pcidev, hdev); SET_HCIDEV_DEV(hdev, &pcidev->dev); } break; default: printk("invalid if_type(%d)!\n", if_type); hci_free_dev(hdev); return -1; } g_hdev=hdev; os_ctrl->bt_dev = hdev; os_ctrl->if_dev = if_dev; os_ctrl->hps_ops->recv = rtbt_hci_dev_receive; hci_set_drvdata(hdev, os_ctrl); hdev->open = rtbt_hci_dev_open; hdev->close = rtbt_hci_dev_close; hdev->flush = rtbt_hci_dev_flush; hdev->send = rtbt_hci_dev_send; // hdev->destruct = rtbt_hci_dev_destruct; //hdev->ioctl = rtbt_hci_dev_ioctl; // hdev->owner = THIS_MODULE; printk("<--%s():alloc hdev(0x%lx) done\n", __FUNCTION__, (ULONG)hdev); return 0; }
static int bpa10x_probe(struct usb_interface *intf, const struct usb_device_id *id) { struct bpa10x_data *data; struct hci_dev *hdev; int err; BT_DBG("intf %p id %p", intf, id); if (intf->cur_altsetting->desc.bInterfaceNumber != 0) return -ENODEV; data = kzalloc(sizeof(*data), GFP_KERNEL); if (!data) return -ENOMEM; data->udev = interface_to_usbdev(intf); init_usb_anchor(&data->tx_anchor); init_usb_anchor(&data->rx_anchor); hdev = hci_alloc_dev(); if (!hdev) { kfree(data); return -ENOMEM; } hdev->bus = HCI_USB; hdev->driver_data = data; data->hdev = hdev; SET_HCIDEV_DEV(hdev, &intf->dev); hdev->open = bpa10x_open; hdev->close = bpa10x_close; hdev->flush = bpa10x_flush; hdev->send = bpa10x_send_frame; hdev->destruct = bpa10x_destruct; hdev->owner = THIS_MODULE; set_bit(HCI_QUIRK_NO_RESET, &hdev->quirks); err = hci_register_dev(hdev); if (err < 0) { hci_free_dev(hdev); kfree(data); return err; } usb_set_intfdata(intf, data); return 0; }
static int hci_uart_register_dev(struct hci_uart *hu) { struct hci_dev *hdev; BT_DBG(""); /* Initialize and register HCI device */ hdev = hci_alloc_dev(); if (!hdev) { BT_ERR("Can't allocate HCI device"); return -ENOMEM; } hu->hdev = hdev; hdev->bus = HCI_UART; hci_set_drvdata(hdev, hu); hdev->open = hci_uart_open; hdev->close = hci_uart_close; hdev->flush = hci_uart_flush; hdev->send = hci_uart_send_frame; hdev->setup = hci_uart_setup; SET_HCIDEV_DEV(hdev, hu->tty->dev); if (test_bit(HCI_UART_RAW_DEVICE, &hu->hdev_flags)) set_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks); if (test_bit(HCI_UART_EXT_CONFIG, &hu->hdev_flags)) set_bit(HCI_QUIRK_EXTERNAL_CONFIG, &hdev->quirks); if (!test_bit(HCI_UART_RESET_ON_INIT, &hu->hdev_flags)) set_bit(HCI_QUIRK_RESET_ON_CLOSE, &hdev->quirks); if (test_bit(HCI_UART_CREATE_AMP, &hu->hdev_flags)) hdev->dev_type = HCI_AMP; else hdev->dev_type = HCI_BREDR; if (test_bit(HCI_UART_INIT_PENDING, &hu->hdev_flags)) return 0; if (hci_register_dev(hdev) < 0) { BT_ERR("Can't register HCI device"); hci_free_dev(hdev); return -ENODEV; } set_bit(HCI_UART_REGISTERED, &hu->flags); return 0; }
static int hci_smd_register_smd(struct hci_smd_data *hsmd) { struct hci_dev *hdev; int rc; hdev = hci_alloc_dev(); if (!hdev) { BT_ERR("Can't allocate HCI device"); return -ENOMEM; } hsmd->hdev = hdev; hdev->bus = HCI_SMD; hdev->driver_data = NULL; hdev->open = hci_smd_open; hdev->close = hci_smd_close; hdev->send = hci_smd_send_frame; hdev->destruct = hci_smd_destruct; hdev->owner = THIS_MODULE; tasklet_init(&hsmd->rx_task, hci_smd_rx, (unsigned long) hsmd); setup_timer(&hsmd->rx_q_timer, schedule_timer, (unsigned long) hsmd->hdev); rc = smd_named_open_on_edge(EVENT_CHANNEL, SMD_APPS_WCNSS, &hsmd->event_channel, hdev, hci_smd_notify_event); if (rc < 0) { BT_ERR("Cannot open the command channel"); hci_free_dev(hdev); hsmd->hdev = NULL; return -ENODEV; } rc = smd_named_open_on_edge(DATA_CHANNEL, SMD_APPS_WCNSS, &hsmd->data_channel, hdev, hci_smd_notify_data); if (rc < 0) { BT_ERR("Failed to open the Data channel"); hci_free_dev(hdev); hsmd->hdev = NULL; return -ENODEV; } smd_disable_read_intr(hsmd->event_channel); smd_disable_read_intr(hsmd->data_channel); return 0; }
int btmrvl_register_hdev(struct btmrvl_private *priv) { struct hci_dev *hdev = NULL; int ret; hdev = hci_alloc_dev(); if (!hdev) { BT_ERR("Can not allocate HCI device"); goto err_hdev; } priv->btmrvl_dev.hcidev = hdev; hci_set_drvdata(hdev, priv); hdev->bus = HCI_SDIO; hdev->open = btmrvl_open; hdev->close = btmrvl_close; hdev->flush = btmrvl_flush; hdev->send = btmrvl_send_frame; hdev->ioctl = btmrvl_ioctl; btmrvl_send_module_cfg_cmd(priv, MODULE_BRINGUP_REQ); hdev->dev_type = priv->btmrvl_dev.dev_type; ret = hci_register_dev(hdev); if (ret < 0) { BT_ERR("Can not register HCI device"); goto err_hci_register_dev; } #ifdef CONFIG_DEBUG_FS btmrvl_debugfs_init(hdev); #endif return 0; err_hci_register_dev: hci_free_dev(hdev); err_hdev: /* Stop the thread servicing the interrupts */ kthread_stop(priv->main_thread.task); btmrvl_free_adapter(priv); kfree(priv); return -ENOMEM; }
static int hci_uart_register_dev(struct hci_uart *hu) { struct hci_dev *hdev; BT_DBG(""); /* Initialize and register HCI device */ hdev = hci_alloc_dev(); if (!hdev) { BT_ERR("Can't allocate HCI device"); return -ENOMEM; } hu->hdev = hdev; hdev->bus = HCI_UART; hdev->driver_data = hu; hdev->open = hci_uart_open; hdev->close = hci_uart_close; hdev->flush = hci_uart_flush; hdev->send = hci_uart_send_frame; hdev->destruct = hci_uart_destruct; hdev->parent = hu->tty->dev; hdev->owner = THIS_MODULE; if (!reset) set_bit(HCI_QUIRK_NO_RESET, &hdev->quirks); if (test_bit(HCI_UART_RAW_DEVICE, &hu->hdev_flags)) set_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks); if (hci_register_dev(hdev) < 0) { BT_ERR("Can't register HCI device"); hci_free_dev(hdev); return -ENODEV; } // Adam patch - we already have a BT rfkill, We don't need another... if (hdev->rfkill) { rfkill_unregister(hdev->rfkill); rfkill_destroy(hdev->rfkill); hdev->rfkill = NULL; } return 0; }
static int hci_uart_register_dev(struct hci_uart *hu) { struct hci_dev *hdev; BT_DBG(""); /* Initialize and register HCI device */ hdev = hci_alloc_dev(); if (!hdev) { BT_ERR("Can't allocate HCI device"); return -ENOMEM; } hu->hdev = hdev; hdev->bus = HCI_UART; hci_set_drvdata(hdev, hu); hdev->open = hci_uart_open; hdev->close = hci_uart_close; hdev->flush = hci_uart_flush; hdev->send = hci_uart_send_frame; #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,36)) SET_HCIDEV_DEV(hdev, hu->tty->dev); #endif if (test_bit(HCI_UART_RAW_DEVICE, &hu->hdev_flags)) set_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks); if (!test_bit(HCI_UART_RESET_ON_INIT, &hu->hdev_flags)) set_bit(HCI_QUIRK_NO_RESET, &hdev->quirks); if (test_bit(HCI_UART_CREATE_AMP, &hu->hdev_flags)) hdev->dev_type = HCI_AMP; else hdev->dev_type = HCI_BREDR; if (hci_register_dev(hdev) < 0) { BT_ERR("Can't register HCI device"); hci_free_dev(hdev); return -ENODEV; } return 0; }
static int vhci_open(struct inode *inode, struct file *file) { struct vhci_data *data; struct hci_dev *hdev; data = kzalloc(sizeof(struct vhci_data), GFP_KERNEL); if (!data) return -ENOMEM; skb_queue_head_init(&data->readq); init_waitqueue_head(&data->read_wait); lock_kernel(); hdev = hci_alloc_dev(); if (!hdev) { kfree(data); unlock_kernel(); return -ENOMEM; } data->hdev = hdev; hdev->type = HCI_VIRTUAL; hdev->driver_data = data; hdev->open = vhci_open_dev; hdev->close = vhci_close_dev; hdev->flush = vhci_flush; hdev->send = vhci_send_frame; hdev->destruct = vhci_destruct; hdev->owner = THIS_MODULE; if (hci_register_dev(hdev) < 0) { BT_ERR("Can't register HCI device"); kfree(data); hci_free_dev(hdev); unlock_kernel(); return -EBUSY; } file->private_data = data; unlock_kernel(); return nonseekable_open(inode, file); }
static int vhci_create_device(struct vhci_data *data, __u8 dev_type) { struct hci_dev *hdev; struct sk_buff *skb; skb = bt_skb_alloc(4, GFP_KERNEL); if (!skb) return -ENOMEM; hdev = hci_alloc_dev(); if (!hdev) { kfree_skb(skb); return -ENOMEM; } data->hdev = hdev; hdev->bus = HCI_VIRTUAL; hdev->dev_type = dev_type; hci_set_drvdata(hdev, data); hdev->open = vhci_open_dev; hdev->close = vhci_close_dev; hdev->flush = vhci_flush; hdev->send = vhci_send_frame; if (hci_register_dev(hdev) < 0) { BT_ERR("Can't register HCI device"); hci_free_dev(hdev); data->hdev = NULL; kfree_skb(skb); return -EBUSY; } bt_cb(skb)->pkt_type = HCI_VENDOR_PKT; *skb_put(skb, 1) = 0xff; *skb_put(skb, 1) = dev_type; put_unaligned_le16(hdev->id, skb_put(skb, 2)); skb_queue_tail(&data->readq, skb); wake_up_interruptible(&data->read_wait); return 0; }
static int vhci_open(struct inode *inode, struct file *file) { struct vhci_data *data; struct hci_dev *hdev; data = kzalloc(sizeof(struct vhci_data), GFP_KERNEL); if (!data) return -ENOMEM; skb_queue_head_init(&data->readq); init_waitqueue_head(&data->read_wait); hdev = hci_alloc_dev(); if (!hdev) { kfree(data); return -ENOMEM; } data->hdev = hdev; hdev->bus = HCI_VIRTUAL; hci_set_drvdata(hdev, data); if (amp) hdev->dev_type = HCI_AMP; hdev->open = vhci_open_dev; hdev->close = vhci_close_dev; hdev->flush = vhci_flush; hdev->send = vhci_send_frame; if (hci_register_dev(hdev) < 0) { BT_ERR("Can't register HCI device"); kfree(data); hci_free_dev(hdev); return -EBUSY; } file->private_data = data; nonseekable_open(inode, file); return 0; }
/** * registers with the bluetooth-hci(BlueZ) interface * * @adapter - pointer to bluetooth asset's adapter * @return - 0 on success */ int bluez_init(PONEBOX_ADAPTER adapter) { int err; struct hci_dev *hdev; ONEBOX_DEBUG(ONEBOX_ZONE_INIT, (TEXT("%s: registering with `hci'\n"),__func__)); hdev = hci_alloc_dev(); if (!hdev) return -ENOMEM; hdev->bus = HCI_DEV_BUS; set_hci_drvdata(hdev, adapter); hdev->dev_type = HCI_BREDR; adapter->hdev = hdev; hdev->open = onebox_hdev_open; hdev->close = onebox_hdev_close; hdev->flush = onebox_hdev_flush; hdev->send = onebox_hdev_send_frame; #if LINUX_VERSION_CODE <= KERNEL_VERSION(3, 3, 8) hdev->destruct = onebox_hdev_destruct; hdev->owner = THIS_MODULE; #endif err = hci_register_dev(hdev); if (err < 0) { ONEBOX_DEBUG(ONEBOX_ZONE_ERROR, (TEXT("%s: hci registration failed\n"), __func__)); hci_free_dev(hdev); adapter->hdev = NULL; return err; } ONEBOX_DEBUG(ONEBOX_ZONE_INFO, (TEXT("%s: done registering `%s'\n"), __func__, hdev->name)); return ONEBOX_STATUS_SUCCESS; }
static int bt_ti_probe(struct platform_device *pdev) { static struct ti_st *hst; struct hci_dev *hdev; int err; hst = kzalloc(sizeof(struct ti_st), GFP_KERNEL); if (!hst) return -ENOMEM; /* Expose "hciX" device to user space */ hdev = hci_alloc_dev(); if (!hdev) { kfree(hst); return -ENOMEM; } BT_DBG("hdev %p", hdev); hst->hdev = hdev; hdev->bus = HCI_UART; hdev->driver_data = hst; hdev->open = ti_st_open; hdev->close = ti_st_close; hdev->flush = NULL; hdev->send = ti_st_send_frame; hdev->destruct = ti_st_destruct; hdev->owner = THIS_MODULE; err = hci_register_dev(hdev); if (err < 0) { BT_ERR("Can't register HCI device error %d", err); kfree(hst); hci_free_dev(hdev); return err; } BT_DBG("HCI device registered (hdev %p)", hdev); dev_set_drvdata(&pdev->dev, hst); return err; }
static int hci_vhci_chr_open(struct inode *inode, struct file * file) { struct hci_vhci_struct *hci_vhci = NULL; struct hci_dev *hdev; if (!(hci_vhci = kmalloc(sizeof(struct hci_vhci_struct), GFP_KERNEL))) return -ENOMEM; memset(hci_vhci, 0, sizeof(struct hci_vhci_struct)); skb_queue_head_init(&hci_vhci->readq); init_waitqueue_head(&hci_vhci->read_wait); /* Initialize and register HCI device */ hdev = hci_alloc_dev(); if (!hdev) { kfree(hci_vhci); return -ENOMEM; } hci_vhci->hdev = hdev; hdev->type = HCI_VHCI; hdev->driver_data = hci_vhci; hdev->open = hci_vhci_open; hdev->close = hci_vhci_close; hdev->flush = hci_vhci_flush; hdev->send = hci_vhci_send_frame; hdev->destruct = hci_vhci_destruct; hdev->owner = THIS_MODULE; if (hci_register_dev(hdev) < 0) { kfree(hci_vhci); hci_free_dev(hdev); return -EBUSY; } file->private_data = hci_vhci; return nonseekable_open(inode, file); }
static int btqcomsmd_probe(struct qcom_smd_device *sdev) { struct qcom_smd_channel *acl; struct btqcomsmd *btq; struct hci_dev *hdev; int ret; acl = qcom_smd_open_channel(sdev, "APPS_RIVA_BT_ACL", btqcomsmd_acl_callback); if (IS_ERR(acl)) return PTR_ERR(acl); btq = devm_kzalloc(&sdev->dev, sizeof(*btq), GFP_KERNEL); if (!btq) return -ENOMEM; btq->acl_channel = acl; btq->cmd_channel = sdev->channel; hdev = hci_alloc_dev(); if (!hdev) return -ENOMEM; hdev->bus = HCI_SMD; hdev->open = btqcomsmd_open; hdev->close = btqcomsmd_close; hdev->send = btqcomsmd_send; hdev->set_bdaddr = btqcomsmd_set_bdaddr; ret = hci_register_dev(hdev); if (ret < 0) { hci_free_dev(hdev); return ret; } hci_set_drvdata(hdev, btq); dev_set_drvdata(&sdev->dev, hdev); return 0; }
static int hci_uart_register_dev(struct hci_uart *hu) { struct hci_dev *hdev; BT_DBG(""); /* Initialize and register HCI device */ hdev = hci_alloc_dev(); if (!hdev) { BT_ERR("Can't allocate HCI device"); return -ENOMEM; } hu->hdev = hdev; hdev->bus = HCI_UART; hdev->driver_data = hu; hdev->open = hci_uart_open; hdev->close = hci_uart_close; hdev->flush = hci_uart_flush; hdev->send = hci_uart_send_frame; hdev->destruct = hci_uart_destruct; hdev->owner = THIS_MODULE; if (!reset) set_bit(HCI_QUIRK_NO_RESET, &hdev->quirks); if (test_bit(HCI_UART_RAW_DEVICE, &hu->hdev_flags)) set_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks); if (hci_register_dev(hdev) < 0) { BT_ERR("Can't register HCI device"); hci_free_dev(hdev); return -ENODEV; } return 0; }
/* Creates new HCI device */ static int hci_st_register_dev(struct hci_st *hst) { struct hci_dev *hdev; BTDRV_API_START(); /* Initialize and register HCI device */ hdev = hci_alloc_dev(); if (!hdev) { BT_DRV_ERR("Can't allocate HCI device"); BTDRV_API_EXIT(-ENOMEM); return -ENOMEM; } BT_DRV_DBG(" HCI device allocated. hdev= %p", hdev); hst->hdev = hdev; hdev->bus = HCI_UART; hdev->driver_data = hst; hdev->open = hci_st_open; hdev->close = hci_st_close; hdev->flush = NULL; hdev->send = hci_st_send_frame; hdev->destruct = hci_st_destruct; hdev->owner = THIS_MODULE; if (reset) set_bit(HCI_QUIRK_NO_RESET, &hdev->quirks); if (hci_register_dev(hdev) < 0) { BT_DRV_ERR("Can't register HCI device"); hci_free_dev(hdev); BTDRV_API_EXIT(-ENODEV); return -ENODEV; } BT_DRV_DBG(" HCI device registered. hdev= %p", hdev); BTDRV_API_EXIT(0); return 0; }
static int hci_smd_register_dev(struct hci_smd_data *hs) { struct hci_dev *hdev; /* Initialize and register HCI device */ hdev = hci_alloc_dev(); if (!hdev) { BT_ERR("Can't allocate HCI device"); return -ENOMEM; } hs->hdev = hdev; hdev->bus = HCI_SMD; hdev->driver_data = hs; hdev->open = hci_smd_open; hdev->close = hci_smd_close; hdev->flush = hci_smd_flush; hdev->send = hci_smd_send_frame; hdev->destruct = hci_smd_destruct; hdev->owner = THIS_MODULE; if (hci_register_dev(hdev) < 0) { BT_ERR("Can't register HCI device"); hci_free_dev(hdev); return -ENODEV; } /* Open the SMD Channel and device and register the callback function*/ smd_named_open_on_edge("APPS_RIVA_BT_CMD", SMD_APPS_WCNSS, &cmd_channel, &hs, hci_smd_notify_cmd); smd_named_open_on_edge("APPS_RIVA_BT_ACL", SMD_APPS_WCNSS, &data_channel, &hs, hci_smd_notify_data); return 0; }
static int bluecard_open(struct bluecard_info *info) { unsigned int iobase = info->p_dev->resource[0]->start; struct hci_dev *hdev; unsigned char id; spin_lock_init(&(info->lock)); init_timer(&(info->timer)); info->timer.function = &bluecard_activity_led_timeout; info->timer.data = (u_long)info; skb_queue_head_init(&(info->txq)); info->rx_state = RECV_WAIT_PACKET_TYPE; 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->bus = HCI_PCCARD; hci_set_drvdata(hdev, info); SET_HCIDEV_DEV(hdev, &info->p_dev->dev); hdev->open = bluecard_hci_open; hdev->close = bluecard_hci_close; hdev->flush = bluecard_hci_flush; hdev->send = bluecard_hci_send_frame; id = inb(iobase + 0x30); if ((id & 0x0f) == 0x02) set_bit(CARD_HAS_PCCARD_ID, &(info->hw_state)); if (id & 0x10) set_bit(CARD_HAS_POWER_LED, &(info->hw_state)); if (id & 0x20) set_bit(CARD_HAS_ACTIVITY_LED, &(info->hw_state)); /* Reset card */ info->ctrl_reg = REG_CONTROL_BT_RESET | REG_CONTROL_CARD_RESET; outb(info->ctrl_reg, iobase + REG_CONTROL); /* Turn FPGA off */ outb(0x80, iobase + 0x30); /* Wait some time */ msleep(10); /* Turn FPGA on */ outb(0x00, iobase + 0x30); /* Activate card */ info->ctrl_reg = REG_CONTROL_BT_ON | REG_CONTROL_BT_RES_PU; outb(info->ctrl_reg, iobase + REG_CONTROL); /* Enable interrupt */ outb(0xff, iobase + REG_INTERRUPT); info->ctrl_reg |= REG_CONTROL_INTERRUPT; outb(info->ctrl_reg, iobase + REG_CONTROL); if ((id & 0x0f) == 0x03) { /* Disable RTS */ info->ctrl_reg |= REG_CONTROL_RTS; outb(info->ctrl_reg, iobase + REG_CONTROL); /* Set baud rate */ info->ctrl_reg |= 0x03; outb(info->ctrl_reg, iobase + REG_CONTROL); /* Enable RTS */ info->ctrl_reg &= ~REG_CONTROL_RTS; outb(info->ctrl_reg, iobase + REG_CONTROL); set_bit(XMIT_BUF_ONE_READY, &(info->tx_state)); set_bit(XMIT_BUF_TWO_READY, &(info->tx_state)); set_bit(XMIT_SENDING_READY, &(info->tx_state)); } /* Start the RX buffers */ outb(REG_COMMAND_RX_BUF_ONE, iobase + REG_COMMAND); outb(REG_COMMAND_RX_BUF_TWO, iobase + REG_COMMAND); /* Signal that the hardware is ready */ set_bit(CARD_READY, &(info->hw_state)); /* Drop TX queue */ skb_queue_purge(&(info->txq)); /* Control the point at which RTS is enabled */ outb((0x0f << RTS_LEVEL_SHIFT_BITS) | 1, iobase + REG_RX_CONTROL); /* Timeout before it is safe to send the first HCI packet */ msleep(1250); /* Register HCI device */ if (hci_register_dev(hdev) < 0) { BT_ERR("Can't register HCI device"); info->hdev = NULL; hci_free_dev(hdev); return -ENODEV; } return 0; }
static int btusb_probe(struct usb_interface *intf, const struct usb_device_id *id) { struct usb_endpoint_descriptor *ep_desc; struct btusb_data *data; struct hci_dev *hdev; int i, err; BT_DBG("intf %p id %p", intf, id); /* interface numbers are hardcoded in the spec */ if (intf->cur_altsetting->desc.bInterfaceNumber != 0) return -ENODEV; if (!id->driver_info) { const struct usb_device_id *match; match = usb_match_id(intf, blacklist_table); if (match) id = match; } if (id->driver_info == BTUSB_IGNORE) return -ENODEV; if (ignore_dga && id->driver_info & BTUSB_DIGIANSWER) return -ENODEV; if (ignore_csr && id->driver_info & BTUSB_CSR) return -ENODEV; if (ignore_sniffer && id->driver_info & BTUSB_SNIFFER) return -ENODEV; if (id->driver_info & BTUSB_ATH3012) { struct usb_device *udev = interface_to_usbdev(intf); /* Old firmware would otherwise let ath3k driver load * patch and sysconfig files */ if (le16_to_cpu(udev->descriptor.bcdDevice) <= 0x0001) return -ENODEV; } data = kzalloc(sizeof(*data), GFP_KERNEL); if (!data) return -ENOMEM; for (i = 0; i < intf->cur_altsetting->desc.bNumEndpoints; i++) { ep_desc = &intf->cur_altsetting->endpoint[i].desc; if (!data->intr_ep && usb_endpoint_is_int_in(ep_desc)) { data->intr_ep = ep_desc; continue; } if (!data->bulk_tx_ep && usb_endpoint_is_bulk_out(ep_desc)) { data->bulk_tx_ep = ep_desc; continue; } if (!data->bulk_rx_ep && usb_endpoint_is_bulk_in(ep_desc)) { data->bulk_rx_ep = ep_desc; continue; } } if (!data->intr_ep || !data->bulk_tx_ep || !data->bulk_rx_ep) { kfree(data); return -ENODEV; } data->cmdreq_type = USB_TYPE_CLASS; data->udev = interface_to_usbdev(intf); data->intf = intf; spin_lock_init(&data->lock); INIT_WORK(&data->work, btusb_work); INIT_WORK(&data->waker, btusb_waker); spin_lock_init(&data->txlock); init_usb_anchor(&data->tx_anchor); init_usb_anchor(&data->intr_anchor); init_usb_anchor(&data->bulk_anchor); init_usb_anchor(&data->isoc_anchor); init_usb_anchor(&data->deferred); hdev = hci_alloc_dev(); if (!hdev) { kfree(data); return -ENOMEM; } hdev->bus = HCI_USB; hdev->driver_data = data; data->hdev = hdev; SET_HCIDEV_DEV(hdev, &intf->dev); hdev->open = btusb_open; hdev->close = btusb_close; hdev->flush = btusb_flush; hdev->send = btusb_send_frame; hdev->destruct = btusb_destruct; hdev->notify = btusb_notify; hdev->owner = THIS_MODULE; /* Interface numbers are hardcoded in the specification */ data->isoc = usb_ifnum_to_if(data->udev, 1); if (!reset) set_bit(HCI_QUIRK_NO_RESET, &hdev->quirks); if (force_scofix || id->driver_info & BTUSB_WRONG_SCO_MTU) { if (!disable_scofix) set_bit(HCI_QUIRK_FIXUP_BUFFER_SIZE, &hdev->quirks); } if (id->driver_info & BTUSB_BROKEN_ISOC) data->isoc = NULL; if (id->driver_info & BTUSB_DIGIANSWER) { data->cmdreq_type = USB_TYPE_VENDOR; set_bit(HCI_QUIRK_NO_RESET, &hdev->quirks); } if (id->driver_info & BTUSB_CSR) { struct usb_device *udev = data->udev; /* Old firmware would otherwise execute USB reset */ if (le16_to_cpu(udev->descriptor.bcdDevice) < 0x117) set_bit(HCI_QUIRK_NO_RESET, &hdev->quirks); } if (id->driver_info & BTUSB_SNIFFER) { struct usb_device *udev = data->udev; /* New sniffer firmware has crippled HCI interface */ if (le16_to_cpu(udev->descriptor.bcdDevice) > 0x997) set_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks); data->isoc = NULL; } if (id->driver_info & BTUSB_BCM92035) { unsigned char cmd[] = { 0x3b, 0xfc, 0x01, 0x00 }; struct sk_buff *skb; skb = bt_skb_alloc(sizeof(cmd), GFP_KERNEL); if (skb) { memcpy(skb_put(skb, sizeof(cmd)), cmd, sizeof(cmd)); skb_queue_tail(&hdev->driver_init, skb); } } if (data->isoc) { err = usb_driver_claim_interface(&btusb_driver, data->isoc, data); if (err < 0) { hci_free_dev(hdev); kfree(data); return err; } } err = hci_register_dev(hdev); if (err < 0) { hci_free_dev(hdev); kfree(data); return err; } usb_set_intfdata(intf, data); return 0; }
static int hci_uart_register_dev(struct hci_uart *hu) { struct hci_dev *hdev; BT_INFO("hci_uart_register_dev"); /* Initialize and register HCI device */ hdev = hci_alloc_dev(); if (!hdev) { BT_ERR("Can't allocate HCI device"); return -ENOMEM; } hu->hdev = hdev; #if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 33) hdev->bus = HCI_UART; #else hdev->type = HCI_UART; #endif #if LINUX_VERSION_CODE > KERNEL_VERSION(3, 4, 0) hci_set_drvdata(hdev, hu); #else hdev->driver_data = hu; #endif hdev->open = hci_uart_open; hdev->close = hci_uart_close; hdev->flush = hci_uart_flush; hdev->send = hci_uart_send_frame; #if ( (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 38)) && (LINUX_VERSION_CODE < KERNEL_VERSION(3, 5, 0)) ) hdev->parent = hu->tty->dev; #endif #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 4, 0) hdev->destruct = hci_uart_destruct; hdev->owner = THIS_MODULE; #endif #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 4, 0) if (!reset) set_bit(HCI_QUIRK_NO_RESET, &hdev->quirks); if (test_bit(HCI_UART_RAW_DEVICE, &hu->hdev_flags)) set_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks); #else if (test_bit(HCI_UART_RAW_DEVICE, &hu->hdev_flags)) set_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks); #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 6, 0) if (!test_bit(HCI_UART_RESET_ON_INIT, &hu->hdev_flags)) set_bit(HCI_QUIRK_NO_RESET, &hdev->quirks); #endif if (test_bit(HCI_UART_CREATE_AMP, &hu->hdev_flags)) hdev->dev_type = HCI_AMP; else hdev->dev_type = HCI_BREDR; #endif if (hci_register_dev(hdev) < 0) { BT_ERR("Can't register HCI device"); hci_free_dev(hdev); return -ENODEV; } #ifdef BTCOEX rtk_btcoex_probe(hdev); #endif return 0; }
static int btusb_probe(struct usb_interface *intf, const struct usb_device_id *id) { struct usb_endpoint_descriptor *ep_desc; struct btusb_data *data; struct hci_dev *hdev; int i, version, err; BT_DBG("intf %p id %p", intf, id); /* interface numbers are hardcoded in the spec */ if (intf->cur_altsetting->desc.bInterfaceNumber != 0) return -ENODEV; if (!id->driver_info) { const struct usb_device_id *match; match = usb_match_id(intf, blacklist_table); if (match) id = match; } if (id->driver_info == BTUSB_IGNORE) return -ENODEV; if (ignore_dga && id->driver_info & BTUSB_DIGIANSWER) return -ENODEV; if (ignore_csr && id->driver_info & BTUSB_CSR) return -ENODEV; if (ignore_sniffer && id->driver_info & BTUSB_SNIFFER) return -ENODEV; if (id->driver_info & BTUSB_ATH3012) { struct usb_device *udev = interface_to_usbdev(intf); version = get_rome_version(udev); BT_INFO("Rome Version: 0x%x", version); /* Old firmware would otherwise let ath3k driver load * patch and sysconfig files */ if (version) rome_download(udev); else if (le16_to_cpu(udev->descriptor.bcdDevice) <= 0x0001) { BT_INFO("FW for ar3k is yet to be downloaded"); return -ENODEV; } } data = devm_kzalloc(&intf->dev, sizeof(*data), GFP_KERNEL); if (!data) return -ENOMEM; for (i = 0; i < intf->cur_altsetting->desc.bNumEndpoints; i++) { ep_desc = &intf->cur_altsetting->endpoint[i].desc; if (!data->intr_ep && usb_endpoint_is_int_in(ep_desc)) { data->intr_ep = ep_desc; continue; } if (!data->bulk_tx_ep && usb_endpoint_is_bulk_out(ep_desc)) { data->bulk_tx_ep = ep_desc; continue; } if (!data->bulk_rx_ep && usb_endpoint_is_bulk_in(ep_desc)) { data->bulk_rx_ep = ep_desc; continue; } } if (!data->intr_ep || !data->bulk_tx_ep || !data->bulk_rx_ep) return -ENODEV; data->cmdreq_type = USB_TYPE_CLASS; data->udev = interface_to_usbdev(intf); data->intf = intf; spin_lock_init(&data->lock); INIT_WORK(&data->work, btusb_work); INIT_WORK(&data->waker, btusb_waker); spin_lock_init(&data->txlock); init_usb_anchor(&data->tx_anchor); init_usb_anchor(&data->intr_anchor); init_usb_anchor(&data->bulk_anchor); init_usb_anchor(&data->isoc_anchor); init_usb_anchor(&data->deferred); hdev = hci_alloc_dev(); if (!hdev) return -ENOMEM; hdev->bus = HCI_USB; hci_set_drvdata(hdev, data); data->hdev = hdev; SET_HCIDEV_DEV(hdev, &intf->dev); hdev->open = btusb_open; hdev->close = btusb_close; hdev->flush = btusb_flush; hdev->send = btusb_send_frame; hdev->notify = btusb_notify; if (id->driver_info & BTUSB_BCM92035) hdev->setup = btusb_setup_bcm92035; if (id->driver_info & BTUSB_INTEL) hdev->setup = btusb_setup_intel; /* Interface numbers are hardcoded in the specification */ data->isoc = usb_ifnum_to_if(data->udev, 1); if (!reset) set_bit(HCI_QUIRK_RESET_ON_CLOSE, &hdev->quirks); if (force_scofix || id->driver_info & BTUSB_WRONG_SCO_MTU) { if (!disable_scofix) set_bit(HCI_QUIRK_FIXUP_BUFFER_SIZE, &hdev->quirks); } if (id->driver_info & BTUSB_BROKEN_ISOC) data->isoc = NULL; if (id->driver_info & BTUSB_DIGIANSWER) { data->cmdreq_type = USB_TYPE_VENDOR; set_bit(HCI_QUIRK_RESET_ON_CLOSE, &hdev->quirks); } if (id->driver_info & BTUSB_CSR) { struct usb_device *udev = data->udev; /* Old firmware would otherwise execute USB reset */ if (le16_to_cpu(udev->descriptor.bcdDevice) < 0x117) set_bit(HCI_QUIRK_RESET_ON_CLOSE, &hdev->quirks); } if (id->driver_info & BTUSB_SNIFFER) { struct usb_device *udev = data->udev; /* New sniffer firmware has crippled HCI interface */ if (le16_to_cpu(udev->descriptor.bcdDevice) > 0x997) set_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks); data->isoc = NULL; } if (data->isoc) { err = usb_driver_claim_interface(&btusb_driver, data->isoc, data); if (err < 0) { hci_free_dev(hdev); return err; } } err = hci_register_dev(hdev); if (err < 0) { hci_free_dev(hdev); return err; } usb_set_intfdata(intf, data); usb_enable_autosuspend(data->udev); return 0; }
static int btuart_open(btuart_info_t *info) { unsigned long flags; unsigned int iobase = info->p_dev->io.BasePort1; struct hci_dev *hdev; spin_lock_init(&(info->lock)); skb_queue_head_init(&(info->txq)); info->rx_state = RECV_WAIT_PACKET_TYPE; 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; SET_HCIDEV_DEV(hdev, &info->p_dev->dev); 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 */ outb(0, iobase + UART_MCR); /* Turn off interrupts */ outb(0, iobase + UART_IER); /* Initialize UART */ outb(UART_LCR_WLEN8, iobase + UART_LCR); /* Reset DLAB */ outb((UART_MCR_DTR | UART_MCR_RTS | UART_MCR_OUT2), iobase + UART_MCR); /* Turn on interrupts */ // outb(UART_IER_RLSI | UART_IER_RDI | UART_IER_THRI, iobase + UART_IER); spin_unlock_irqrestore(&(info->lock), flags); btuart_change_speed(info, DEFAULT_BAUD_RATE); /* Timeout before it is safe to send the first HCI packet */ msleep(1000); /* Register HCI device */ if (hci_register_dev(hdev) < 0) { BT_ERR("Can't register HCI device"); info->hdev = NULL; hci_free_dev(hdev); return -ENODEV; } return 0; }
static int bpa10x_probe(struct usb_interface *intf, const struct usb_device_id *id) { struct usb_device *udev = interface_to_usbdev(intf); struct hci_dev *hdev; struct bpa10x_data *data; int err; BT_DBG("intf %p id %p", intf, id); if (ignore) return -ENODEV; if (intf->cur_altsetting->desc.bInterfaceNumber > 0) return -ENODEV; data = kzalloc(sizeof(*data), GFP_KERNEL); if (!data) { BT_ERR("Can't allocate data structure"); return -ENOMEM; } data->udev = udev; rwlock_init(&data->lock); skb_queue_head_init(&data->cmd_queue); skb_queue_head_init(&data->tx_queue); hdev = hci_alloc_dev(); if (!hdev) { BT_ERR("Can't allocate HCI device"); kfree(data); return -ENOMEM; } data->hdev = hdev; hdev->type = HCI_USB; hdev->driver_data = data; SET_HCIDEV_DEV(hdev, &intf->dev); hdev->open = bpa10x_open; hdev->close = bpa10x_close; hdev->flush = bpa10x_flush; hdev->send = bpa10x_send_frame; hdev->destruct = bpa10x_destruct; hdev->owner = THIS_MODULE; err = hci_register_dev(hdev); if (err < 0) { BT_ERR("Can't register HCI device"); kfree(data); hci_free_dev(hdev); return err; } usb_set_intfdata(intf, data); return 0; }
static int bfusb_probe(struct usb_interface *intf, const struct usb_device_id *id) { const struct firmware *firmware; struct usb_device *udev = interface_to_usbdev(intf); struct usb_host_endpoint *bulk_out_ep; struct usb_host_endpoint *bulk_in_ep; struct hci_dev *hdev; struct bfusb_data *data; BT_DBG("intf %p id %p", intf, id); /* Check number of endpoints */ if (intf->cur_altsetting->desc.bNumEndpoints < 2) return -EIO; bulk_out_ep = &intf->cur_altsetting->endpoint[0]; bulk_in_ep = &intf->cur_altsetting->endpoint[1]; if (!bulk_out_ep || !bulk_in_ep) { BT_ERR("Bulk endpoints not found"); goto done; } /* Initialize control structure and load firmware */ data = kzalloc(sizeof(struct bfusb_data), GFP_KERNEL); if (!data) { BT_ERR("Can't allocate memory for control structure"); goto done; } data->udev = udev; data->bulk_in_ep = bulk_in_ep->desc.bEndpointAddress; data->bulk_out_ep = bulk_out_ep->desc.bEndpointAddress; data->bulk_pkt_size = le16_to_cpu(bulk_out_ep->desc.wMaxPacketSize); rwlock_init(&data->lock); data->reassembly = NULL; skb_queue_head_init(&data->transmit_q); skb_queue_head_init(&data->pending_q); skb_queue_head_init(&data->completed_q); if (request_firmware(&firmware, "bfubase.frm", &udev->dev) < 0) { BT_ERR("Firmware request failed"); goto error; } BT_DBG("firmware data %p size %zu", firmware->data, firmware->size); if (bfusb_load_firmware(data, firmware->data, firmware->size) < 0) { BT_ERR("Firmware loading failed"); goto release; } release_firmware(firmware); /* Initialize and register HCI device */ hdev = hci_alloc_dev(); if (!hdev) { BT_ERR("Can't allocate HCI device"); goto error; } data->hdev = hdev; hdev->bus = HCI_USB; hdev->driver_data = data; SET_HCIDEV_DEV(hdev, &intf->dev); hdev->open = bfusb_open; hdev->close = bfusb_close; hdev->flush = bfusb_flush; hdev->send = bfusb_send_frame; hdev->destruct = bfusb_destruct; hdev->ioctl = bfusb_ioctl; hdev->owner = THIS_MODULE; if (hci_register_dev(hdev) < 0) { BT_ERR("Can't register HCI device"); hci_free_dev(hdev); goto error; } usb_set_intfdata(intf, data); return 0; release: release_firmware(firmware); error: kfree(data); done: return -EIO; }
static int dtl1_open(dtl1_info_t *info) { unsigned long flags; unsigned int iobase = info->p_dev->resource[0]->start; struct hci_dev *hdev; spin_lock_init(&(info->lock)); skb_queue_head_init(&(info->txq)); info->rx_state = RECV_WAIT_NSH; info->rx_count = NSHL; info->rx_skb = NULL; 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->bus = HCI_PCCARD; hci_set_drvdata(hdev, info); SET_HCIDEV_DEV(hdev, &info->p_dev->dev); hdev->open = dtl1_hci_open; hdev->close = dtl1_hci_close; hdev->flush = dtl1_hci_flush; hdev->send = dtl1_hci_send_frame; spin_lock_irqsave(&(info->lock), flags); /* Reset UART */ outb(0, iobase + UART_MCR); /* Turn off interrupts */ outb(0, iobase + UART_IER); /* Initialize UART */ outb(UART_LCR_WLEN8, iobase + UART_LCR); /* Reset DLAB */ outb((UART_MCR_DTR | UART_MCR_RTS | UART_MCR_OUT2), iobase + UART_MCR); info->ri_latch = inb(info->p_dev->resource[0]->start + UART_MSR) & UART_MSR_RI; /* Turn on interrupts */ outb(UART_IER_RLSI | UART_IER_RDI | UART_IER_THRI, iobase + UART_IER); spin_unlock_irqrestore(&(info->lock), flags); /* Timeout before it is safe to send the first HCI packet */ msleep(2000); /* Register HCI device */ if (hci_register_dev(hdev) < 0) { BT_ERR("Can't register HCI device"); info->hdev = NULL; hci_free_dev(hdev); return -ENODEV; } return 0; }