static void btusb_disconnect(struct usb_interface *intf) { struct btusb_data *data = usb_get_intfdata(intf); struct hci_dev *hdev; BT_DBG("intf %p", intf); if (!data) return; hdev = data->hdev; __hci_dev_hold(hdev); usb_set_intfdata(data->intf, NULL); if (data->isoc) usb_set_intfdata(data->isoc, NULL); hci_unregister_dev(hdev); if (intf == data->isoc) usb_driver_release_interface(&btusb_driver, data->intf); else if (data->isoc) usb_driver_release_interface(&btusb_driver, data->isoc); __hci_dev_put(hdev); hci_free_dev(hdev); }
/* hci_uart_tty_close() * * Called when the line discipline is changed to something * else, the tty is closed, or the tty detects a hangup. */ static void hci_uart_tty_close(struct tty_struct *tty) { struct hci_uart *hu = (void *)tty->disc_data; BT_DBG("tty %p", tty); /* Detach from the tty */ tty->disc_data = NULL; if (hu) { struct hci_dev *hdev = hu->hdev; if (hdev) hci_uart_close(hdev); if (test_and_clear_bit(HCI_UART_PROTO_SET, &hu->flags)) { // hu->proto->close(hu); if (hdev) { hci_unregister_dev(hdev); hci_free_dev(hdev); } hu->proto->close(hu); } kfree(hu); } }
static int btuart_close(btuart_info_t *info) { unsigned long flags; unsigned int iobase = info->p_dev->resource[0]->start; struct hci_dev *hdev = info->hdev; if (!hdev) return -ENODEV; btuart_hci_close(hdev); spin_lock_irqsave(&(info->lock), flags); /* Reset UART */ outb(0, iobase + UART_MCR); /* Turn off interrupts */ outb(0, iobase + UART_IER); spin_unlock_irqrestore(&(info->lock), flags); hci_unregister_dev(hdev); hci_free_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; 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_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; }
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; }
void hci_uart_unregister_device(struct hci_uart *hu) { struct hci_dev *hdev = hu->hdev; hci_unregister_dev(hdev); hci_free_dev(hdev); cancel_work_sync(&hu->write_work); hu->proto->close(hu); }
static void __exit brf6150_exit(void) { brf6150_hci_close(exit_info->hdev); hci_free_dev(exit_info->hdev); omap_free_gpio(exit_info->btinfo->reset_gpio); omap_free_gpio(exit_info->btinfo->bt_wakeup_gpio); omap_free_gpio(exit_info->btinfo->host_wakeup_gpio); free_irq(exit_info->irq, (void *)exit_info); free_irq(OMAP_GPIO_IRQ(exit_info->btinfo->host_wakeup_gpio), (void *)exit_info); kfree(exit_info); }
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 vhci_release(struct inode *inode, struct file *file) { struct vhci_data *data = file->private_data; struct hci_dev *hdev = data->hdev; hci_unregister_dev(hdev); hci_free_dev(hdev); file->private_data = 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; 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_vhci_chr_close(struct inode *inode, struct file *file) { struct hci_vhci_struct *hci_vhci = (struct hci_vhci_struct *) file->private_data; if (hci_unregister_dev(hci_vhci->hdev) < 0) { BT_ERR("Can't unregister HCI device %s", hci_vhci->hdev->name); } hci_free_dev(hci_vhci->hdev); file->private_data = NULL; return 0; }
void hci_uart_unregister_device(struct hci_uart *hu) { struct hci_dev *hdev = hu->hdev; clear_bit(HCI_UART_PROTO_READY, &hu->flags); hci_unregister_dev(hdev); hci_free_dev(hdev); cancel_work_sync(&hu->write_work); hu->proto->close(hu); serdev_device_close(hu->serdev); }
static int hci_smd_hci_register_dev(struct hci_smd_data *hsmd) { struct hci_dev *hdev; hdev = hsmd->hdev; if (hci_register_dev(hdev) < 0) { BT_ERR("Can't register HCI device"); hci_free_dev(hdev); hsmd->hdev = NULL; return -ENODEV; } return 0; }
static void nokia_bluetooth_serdev_remove(struct serdev_device *serdev) { struct nokia_bt_dev *btdev = serdev_device_get_drvdata(serdev); struct hci_uart *hu = &btdev->hu; struct hci_dev *hdev = hu->hdev; cancel_work_sync(&hu->write_work); hci_unregister_dev(hdev); hci_free_dev(hdev); hu->proto->close(hu); pm_runtime_disable(&btdev->serdev->dev); }
static int vhci_release(struct inode *inode, struct file *file) { struct vhci_data *data = file->private_data; struct hci_dev *hdev = data->hdev; hci_unregister_dev(hdev); hci_free_dev(hdev); skb_queue_purge(&data->readq); file->private_data = NULL; kfree(data); 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 void bpa10x_disconnect(struct usb_interface *intf) { struct bpa10x_data *data = usb_get_intfdata(intf); BT_DBG("intf %p", intf); if (!data) return; usb_set_intfdata(intf, NULL); hci_unregister_dev(data->hdev); hci_free_dev(data->hdev); }
static int vhci_release(struct inode *inode, struct file *file) { struct vhci_data *data = file->private_data; struct hci_dev *hdev = data->hdev; if (hci_unregister_dev(hdev) < 0) { BT_ERR("Can't unregister HCI device %s", hdev->name); } hci_free_dev(hdev); file->private_data = 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; 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; }
int bt3c_close(bt3c_info_t *info) { struct hci_dev *hdev = info->hdev; if (!hdev) return -ENODEV; bt3c_hci_close(hdev); if (hci_unregister_dev(hdev) < 0) BT_ERR("Can't unregister HCI device %s", hdev->name); hci_free_dev(hdev); return 0; }
static void bpa10x_disconnect(struct usb_interface *intf) { struct bpa10x_data *data = usb_get_intfdata(intf); struct hci_dev *hdev = data->hdev; BT_DBG("intf %p", intf); if (!hdev) return; usb_set_intfdata(intf, NULL); if (hci_unregister_dev(hdev) < 0) BT_ERR("Can't unregister HCI device %s", hdev->name); hci_free_dev(hdev); }
static void bfusb_disconnect(struct usb_interface *intf) { struct bfusb_data *data = usb_get_intfdata(intf); struct hci_dev *hdev = data->hdev; BT_DBG("intf %p", intf); if (!hdev) return; usb_set_intfdata(intf, NULL); bfusb_close(hdev); hci_unregister_dev(hdev); hci_free_dev(hdev); }
static int vhci_release(struct inode *inode, struct file *file) { struct vhci_data *data = file->private_data; struct hci_dev *hdev = data->hdev; cancel_delayed_work_sync(&data->open_timeout); if (hdev) { hci_unregister_dev(hdev); hci_free_dev(hdev); } file->private_data = NULL; kfree(data); 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 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 hci_h4p_remove(struct platform_device *pdev) { struct hci_h4p_info *info; info = platform_get_drvdata(pdev); hci_h4p_hci_close(info->hdev); free_irq(gpio_to_irq(info->host_wakeup_gpio), info); hci_unregister_dev(info->hdev); hci_free_dev(info->hdev); gpio_free(info->reset_gpio); gpio_free(info->bt_wakeup_gpio); gpio_free(info->host_wakeup_gpio); free_irq(info->irq, (void *) info); kfree(info); return 0; }
static void hci_uart_init_work(struct work_struct *work) { struct hci_uart *hu = container_of(work, struct hci_uart, init_ready); int err; if (!test_and_clear_bit(HCI_UART_INIT_PENDING, &hu->hdev_flags)) return; err = hci_register_dev(hu->hdev); if (err < 0) { BT_ERR("Can't register HCI device"); hci_free_dev(hu->hdev); hu->hdev = NULL; hu->proto->close(hu); } set_bit(HCI_UART_REGISTERED, &hu->flags); }
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; }
/** * unregisters with the bluetooth-hci(BlueZ) interface * * @adapter - pointer to bluetooth asset's adapter * @return - 0 on success */ int bluez_deinit(PONEBOX_ADAPTER adapter) { struct hci_dev *hdev; if (!(hdev = adapter->hdev)) return -EFAULT; ONEBOX_DEBUG(ONEBOX_ZONE_INFO, (TEXT("%s: deregistering `%s'\n"), __func__, hdev->name)); onebox_hci_dev_hold(hdev); hci_unregister_dev(hdev); onebox_hci_dev_put(hdev); hci_free_dev(hdev); return ONEBOX_STATUS_SUCCESS; }
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; }