software/drivers/sd8887/src/bluetooth/bt/bt_main.c
/**
 *  @brief Module configuration and register device
 *
 *  @param priv      A Pointer to bt_private structure
 *  @return      BT_STATUS_SUCCESS or BT_STATUS_FAILURE
 */
@brief Module configuration and register device
@param priv      A Pointer to bt_private structure
@return      BT_STATUS_SUCCESS or BT_STATUS_FAILURE
@brief Module configuration and register device @param priv A Pointer to bt_private structure @return BT_STATUS_SUCCESS or BT_STATUS_FAILURE
int
sbi_register_conf_dpc(bt_private *priv)
{
	int ret = BT_STATUS_SUCCESS;
	struct hci_dev *hdev = NULL;
	unsigned char dev_type = 0;
	ENTER();
	priv->bt_dev.tx_dnld_rdy = TRUE;
	if (drv_mode & DRV_MODE_BT) {
		hdev = hci_alloc_dev();
		if (!hdev) {
			PRINTM(FATAL, "Can not allocate HCI device\n");
			ret = -ENOMEM;
			goto err_kmalloc;
		}
		hdev->open = bt_open;
		hdev->close = bt_close;
		hdev->flush = bt_flush;
		hdev->send = bt_send_frame;
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 4, 0)
		hdev->destruct = bt_destruct;
#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 13, 0)
		hdev->ioctl = bt_ioctl;
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 4, 0)
		hci_set_drvdata(hdev, priv);
#else
		hdev->driver_data = priv;
#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 4, 0)
		hdev->owner = THIS_MODULE;
#endif
		init_m_dev(&(priv->bt_dev.m_dev[BT_SEQ]));
		priv->bt_dev.m_dev[BT_SEQ].dev_type = BT_TYPE;
		priv->bt_dev.m_dev[BT_SEQ].spec_type = BLUEZ_SPEC;
		priv->bt_dev.m_dev[BT_SEQ].dev_pointer = (void *)hdev;
		priv->bt_dev.m_dev[BT_SEQ].driver_data = priv;
	}
	dev_type = HCI_SDIO;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 34)
	if (hdev)
		hdev->bus = dev_type;
#else
	if (hdev)
		hdev->type = dev_type;
#endif 
	ret = bt_init_cmd(priv);
	if (ret < 0) {
		PRINTM(FATAL, "BT init command failed!\n");
		goto done;
	}
	if (init_cfg) {
		if (BT_STATUS_SUCCESS != bt_init_config(priv, init_cfg)) {
			PRINTM(FATAL,
			       "BT: Set user init data and param failed\n");
			ret = BT_STATUS_FAILURE;
			goto done;
		}
	}
	if (cal_cfg) {
		if (BT_STATUS_SUCCESS != bt_cal_config(priv, cal_cfg, bt_mac)) {
			PRINTM(FATAL, "BT: Set cal data failed\n");
			ret = BT_STATUS_FAILURE;
			goto done;
		}
	} else if (bt_mac) {
		PRINTM(INFO,
		       "Set BT mac_addr from insmod parametre bt_mac = %s\n",
		       bt_mac);
		if (BT_STATUS_SUCCESS != bt_init_mac_address(priv, bt_mac)) {
			PRINTM(FATAL,
			       "BT: Fail to set mac address from insmod parametre\n");
			ret = BT_STATUS_FAILURE;
			goto done;
		}
	}
	if (cal_cfg_ext) {
		if (BT_STATUS_SUCCESS != bt_cal_config_ext(priv, cal_cfg_ext)) {
			PRINTM(FATAL, "BT: Set cal ext data failed\n");
			ret = BT_STATUS_FAILURE;
			goto done;
		}
	}
	if (init_cmds) {
		if (BT_STATUS_SUCCESS != bt_init_cmds(priv, init_cmds)) {
			PRINTM(FATAL, "BT: Set user init commands failed\n");
			ret = BT_STATUS_FAILURE;
			goto done;
		}
	}
	bt_get_fw_version(priv);
	snprintf((char *)priv->adapter->drv_ver, MAX_VER_STR_LEN,
		 mbt_driver_version, fw_version);
	if (hdev) {
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 34)
		hdev->dev_type = priv->bt_dev.devType;
#endif
		ret = hci_register_dev(hdev);
		if (ret < 0) {
			PRINTM(FATAL, "Can not register HCI device\n");
			ret = BT_STATUS_FAILURE;
			goto done;
		}
		snprintf((char *)priv->bt_dev.m_dev[BT_SEQ].name,
			 sizeof(priv->bt_dev.m_dev[BT_SEQ].name), hdev->name);
		bt_proc_init(priv, &(priv->bt_dev.m_dev[BT_SEQ]), BT_SEQ);
	}
done:
	LEAVE();
	return ret;
err_kmalloc:
	LEAVE();
	return ret;
}
int sbi_register_conf_dpc ( bt_private * priv ) { int ret = BT_STATUS_SUCCESS ; struct hci_dev * hdev = NULL ; unsigned char dev_type = 0 ; ENTER ( ) ; priv -> bt_dev . tx_dnld_rdy = TRUE ; if ( drv_mode & DRV_MODE_BT ) { hdev = hci_alloc_dev ( ) ; if ( ! hdev ) { PRINTM ( FATAL , " \n " ) ; ret = - ENOMEM ; goto err_kmalloc ; } hdev -> open = bt_open ; hdev -> close = bt_close ; hdev -> flush = bt_flush ; hdev -> send = bt_send_frame ; #if LINUX_VERSION_CODE < KERNEL_VERSION ( 3 , 4 , 0 ) hdev -> destruct = bt_destruct ; #endif #if LINUX_VERSION_CODE < KERNEL_VERSION ( 3 , 13 , 0 ) hdev -> ioctl = bt_ioctl ; #endif #if LINUX_VERSION_CODE >= KERNEL_VERSION ( 3 , 4 , 0 ) hci_set_drvdata ( hdev , priv ) ; #else hdev -> driver_data = priv ; #endif #if LINUX_VERSION_CODE < KERNEL_VERSION ( 3 , 4 , 0 ) hdev -> owner = THIS_MODULE ; #endif init_m_dev ( & ( priv -> bt_dev . m_dev [ BT_SEQ ] ) ) ; priv -> bt_dev . m_dev [ BT_SEQ ] . dev_type = BT_TYPE ; priv -> bt_dev . m_dev [ BT_SEQ ] . spec_type = BLUEZ_SPEC ; priv -> bt_dev . m_dev [ BT_SEQ ] . dev_pointer = ( void * ) hdev ; priv -> bt_dev . m_dev [ BT_SEQ ] . driver_data = priv ; } dev_type = HCI_SDIO ; #if LINUX_VERSION_CODE >= KERNEL_VERSION ( 2 , 6 , 34 ) if ( hdev ) hdev -> bus = dev_type ; #else if ( hdev ) hdev -> type = dev_type ; #endif ret = bt_init_cmd ( priv ) ; if ( ret < 0 ) { PRINTM ( FATAL , " \n " ) ; goto done ; } if ( init_cfg ) { if ( BT_STATUS_SUCCESS != bt_init_config ( priv , init_cfg ) ) { PRINTM ( FATAL , " \n " ) ; ret = BT_STATUS_FAILURE ; goto done ; } } if ( cal_cfg ) { if ( BT_STATUS_SUCCESS != bt_cal_config ( priv , cal_cfg , bt_mac ) ) { PRINTM ( FATAL , " \n " ) ; ret = BT_STATUS_FAILURE ; goto done ; } } else if ( bt_mac ) { PRINTM ( INFO , " \n " , bt_mac ) ; if ( BT_STATUS_SUCCESS != bt_init_mac_address ( priv , bt_mac ) ) { PRINTM ( FATAL , " \n " ) ; ret = BT_STATUS_FAILURE ; goto done ; } } if ( cal_cfg_ext ) { if ( BT_STATUS_SUCCESS != bt_cal_config_ext ( priv , cal_cfg_ext ) ) { PRINTM ( FATAL , " \n " ) ; ret = BT_STATUS_FAILURE ; goto done ; } } if ( init_cmds ) { if ( BT_STATUS_SUCCESS != bt_init_cmds ( priv , init_cmds ) ) { PRINTM ( FATAL , " \n " ) ; ret = BT_STATUS_FAILURE ; goto done ; } } bt_get_fw_version ( priv ) ; snprintf ( ( char * ) priv -> adapter -> drv_ver , MAX_VER_STR_LEN , mbt_driver_version , fw_version ) ; if ( hdev ) { #if LINUX_VERSION_CODE >= KERNEL_VERSION ( 2 , 6 , 34 ) hdev -> dev_type = priv -> bt_dev . devType ; #endif ret = hci_register_dev ( hdev ) ; if ( ret < 0 ) { PRINTM ( FATAL , " \n " ) ; ret = BT_STATUS_FAILURE ; goto done ; } snprintf ( ( char * ) priv -> bt_dev . m_dev [ BT_SEQ ] . name , sizeof ( priv -> bt_dev . m_dev [ BT_SEQ ] . name ) , hdev -> name ) ; bt_proc_init ( priv , & ( priv -> bt_dev . m_dev [ BT_SEQ ] ) , BT_SEQ ) ; } done : LEAVE ( ) ; return ret ; err_kmalloc : LEAVE ( ) ; return ret ; }
@brief Module configuration and register device
  @param priv      A Pointer to bt_private structure
  @return      BT_STATUS_SUCCESS or BT_STATUS_FAILURE
@brief Module configuration and register device @param priv A Pointer to bt_private structure @return BT_STATUS_SUCCESS or BT_STATUS_FAILURE
/* >= 2.6.34 */ /** Process device tree init parameters before register hci device.
	 *  Since uplayer device has not yet registered, no need to block tx queue.
	 * */ /* Get FW version */