/** 
 * @brief request_firmware callback
 *        This function is invoked by request_firmware_nowait system call
 * 
 * @param firmware     A pointer to firmware structure
 * @param context      A Pointer to bt_private structure
 * @return             None    
 **/
static void
sd_request_fw_callback(const struct firmware *firmware, void *context)
{
    ENTER();
    sd_request_fw_dpc(firmware, context);
    LEAVE();
    return;
}
/**
 *  @brief This function downloads firmware image to the card.
 *
 *  @param priv     A pointer to bt_private structure
 *  @return         BT_STATUS_SUCCESS/BT_STATUS_FAILURE or other error no.
 */
int
sd_download_firmware_w_helper(bt_private *priv)
{
	int ret = BT_STATUS_SUCCESS;
	int err;
	char *cur_fw_name = NULL;

	ENTER();

	cur_fw_name = fw_name;
	if (fw_name == NULL) {
		if (priv->card_type == CARD_TYPE_SD8787)
			cur_fw_name = DEFAULT_FW_NAME_8787;
		else
			cur_fw_name = DEFAULT_FW_NAME;
	}

	if (bt_req_fw_nowait) {
#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 32)
		ret = request_firmware_nowait(THIS_MODULE, FW_ACTION_HOTPLUG,
					      cur_fw_name, priv->hotplug_device,
					      GFP_KERNEL, priv,
					      sd_request_fw_callback);
#else
#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 13)
		ret = request_firmware_nowait(THIS_MODULE, FW_ACTION_HOTPLUG,
					      cur_fw_name, priv->hotplug_device,
					      priv, sd_request_fw_callback);
#else
		ret = request_firmware_nowait(THIS_MODULE,
					      cur_fw_name, priv->hotplug_device,
					      priv, sd_request_fw_callback);
#endif
#endif
		if (ret < 0)
			PRINTM(FATAL,
			       "BT: request_firmware_nowait() failed, error code = %#x\n",
			       ret);
	} else {
		err = request_firmware(&priv->firmware, cur_fw_name,
				       priv->hotplug_device);
		if (err < 0) {
			PRINTM(FATAL,
			       "BT: request_firmware() failed, error code = %#x\n",
			       err);
			ret = BT_STATUS_FAILURE;
		} else
			ret = sd_request_fw_dpc(priv->firmware, priv);
	}

	LEAVE();
	return ret;
}
/** 
 *  @brief This function downloads firmware image to the card.
 *  
 *  @param priv    	A pointer to bt_private structure
 *  @return 	   	BT_STATUS_SUCCESS/BT_STATUS_FAILURE or other error no.
 */
int
sd_download_firmware_w_helper(bt_private * priv)
{
    int ret = BT_STATUS_SUCCESS;
    int err;
    char *cur_fw_name = NULL;

    ENTER();

    cur_fw_name = fw_name;

    if (req_fw_nowait) {
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,32)
        if ((ret = request_firmware_nowait(THIS_MODULE, FW_ACTION_HOTPLUG,
                                           cur_fw_name, priv->hotplug_device,
                                           GFP_KERNEL, priv,
                                           sd_request_fw_callback)) < 0)
#else
        if ((ret = request_firmware_nowait(THIS_MODULE, FW_ACTION_HOTPLUG,
                                           cur_fw_name, priv->hotplug_device,
                                           priv, sd_request_fw_callback)) < 0)
#endif
            PRINTM(FATAL,
                   "BT: request_firmware_nowait() failed, error code = %#x\n",
                   ret);
    } else {
        if ((err =
             request_firmware(&priv->firmware, cur_fw_name,
                              priv->hotplug_device)) < 0) {
            PRINTM(FATAL, "BT: request_firmware() failed, error code = %#x\n",
                   err);
            ret = BT_STATUS_FAILURE;
        } else
            ret = sd_request_fw_dpc(priv->firmware, priv);
    }

    LEAVE();
    return ret;
}