static int hw_scharger_flash_mode(struct hw_flash_ctrl_t *flash_ctrl, int data)
{
    struct hw_scharger_private_data_t *pdata;
    int ret = 0;

    cam_debug("%s data=%d.\n", __func__, data);

    if (NULL == flash_ctrl) {
        cam_err("%s flash_ctrl is NULL.", __func__);
        return -1;
    }

    pdata = (struct hw_scharger_private_data_t *)flash_ctrl->pdata;

    if (data >= pdata->flash_led_num) {
        cam_err("Unsupport flash_lum_level: %d", data);
        return -1;
    }

    if ((NULL == pdata->flash_inter_ldo) || (NULL == pdata->flash_mode_ldo)) {
        cam_err("%s regulator is NULL", __func__);
        return -1;
    }

    /*if flash has already on do nothing*/
    if(BIT(FLASH_MODE) & pdata->status){
        cam_info("%s already in flash mode, do nothing",__func__);
        return 0;
    }

    ret = scharger_flash_led_timeout_config(FLASH_TIMEOUT_MS);
    if (ret < 0) {
        cam_err("%s scharger_flash_led_timeout_config  fail ret = %d ", __func__, ret);
        regulator_disable(pdata->flash_inter_ldo);
        return ret;
    }

    ret = scharger_flash_led_timeout_enable();
    if (ret < 0) {
        cam_err("%s scharger_flash_led_timeout_enable  fail ret = %d ", __func__, ret);
        return ret;
    }
    ret = regulator_enable(pdata->flash_inter_ldo);
    if (ret < 0) {
        cam_err("%s regulator_enable flash_inter_ldo fail ret = %d", __func__, ret);
/* #if defined (CONFIG_HUAWEI_DSM) */
/*         if (!dsm_client_ocuppy(client_ovisp22)){ */
/*             dsm_client_record(client_ovisp22,"[%s]regulator_enable flash_inter_ldo fail mode %d\n",__func__,mode); */
/*             dsm_client_notify(client_ovisp22, DSM_ISP22_FLASH_ERROR_NO); */
/*         } */
/* #endif */
        return ret;
    }
    udelay(500);

    ret = regulator_set_current_limit(pdata->flash_mode_ldo, pdata->flash_led[data], pdata->flash_led[data]);
    if (ret < 0) {
        cam_err("%s regulator_set_current_limit  fail ret = %d current is %d", __func__, ret, (pdata->flash_led[data]));
        regulator_disable(pdata->flash_inter_ldo);
        return ret;
    }

    ret = regulator_enable(pdata->flash_mode_ldo);
    if (ret < 0) {
        cam_err("%s regulator_enable torch_mode_ldo fail ret = %d", __func__, ret);
/* #if defined (CONFIG_HUAWEI_DSM) */
/*         if (!dsm_client_ocuppy(client_ovisp22)){ */
/*             dsm_client_record(client_ovisp22,"[%s]regulator_enable flash_mode_ldo fail mode %d\n",__func__,mode); */
/*             dsm_client_notify(client_ovisp22, DSM_ISP22_FLASH_ERROR_NO); */
/*         } */
/* #endif */
        regulator_disable(pdata->flash_inter_ldo);
        return ret;
    }

    pdata->status |= BIT(FLASH_MODE);
    return 0;
}
/*
 **************************************************************************
 * FunctionName: scharger_flash_turn_on;
 * Description : turn on flashlight;
 * Input       : NA;
 * Output      : NA;
 * ReturnValue : NA;
 * Other       : NA;
 **************************************************************************
 */
static int scharger_flash_turn_on(work_mode mode, flash_lum_level lum)
{
	int ret = 0;
	print_info("enter %s work_mode = %d , lum = %d",__func__, mode, lum);
	SAFE_DOWN(&switch_lock);
	if (mode == TORCH_MODE) {
		if (lum >= TORCH_LUM_LEVEL_NUM) {
			print_error("Unsupport torch_lum_level: %d", lum);
			ret = -1;
			goto out;
		}

		
		flash_mode = TORCH_MODE;

		/*if flash has already on go out do nothing*/
		if(FLASH_TORCH_MODE&flash_on){
			ret = 0;
			print_info("%s torch mode already in do nothing",__func__);
			goto out;
		}
		
		ret = regulator_set_current_limit(torch_mode_ldo, torch_lum_table[lum], torch_lum_table[lum]);
		if (ret < 0){
			print_error("%s regulator_set_current_limit  fail ret = %d current is %d", __func__, ret, (torch_lum_table[lum]));
			goto out;
		}
		ret = regulator_enable(flash_inter_ldo);
		if (ret < 0){
			print_error("%s regulator_enable flash_inter_ldo fail ret = %d", __func__, ret);
			#if defined (CONFIG_HUAWEI_DSM)
			if (!dsm_client_ocuppy(client_ovisp22)){
			    dsm_client_record(client_ovisp22,"[%s]regulator_enable flash_inter_ldo fail mode %d\n",__func__,mode);
			    dsm_client_notify(client_ovisp22, DSM_ISP22_FLASH_ERROR_NO);
			}
			#endif
			goto out;
		}

		udelay(500);

		ret = regulator_enable(torch_mode_ldo);
		if (ret < 0){
			print_error("%s regulator_enable torch_mode_ldo fail ret = %d", __func__, ret);
			#if defined (CONFIG_HUAWEI_DSM)
			if (!dsm_client_ocuppy(client_ovisp22)){
			    dsm_client_record(client_ovisp22,"[%s]regulator_enable torch_mode_ldo fail mode %d\n",__func__,mode);
			    dsm_client_notify(client_ovisp22, DSM_ISP22_FLASH_ERROR_NO);
			}
			#endif
			if (flash_inter_ldo){
				regulator_disable(flash_inter_ldo);
			}
			goto out;
		}
		flash_on |= FLASH_TORCH_MODE;
	} else {
		if (lum >= FLASH_LUM_LEVEL_NUM) {
			print_error("Unsupport flash_lum_level: %d", lum);
			ret = -1;
			goto out;
		}
		
		flash_mode = FLASH_MODE;
		
		if(FLASH_FLASH_MODE&flash_on){
			ret = 0;
			print_info("%s flash mode already in do nothing",__func__);
			goto out;
		}

		if(audio_codec_mute_flag){
			audio_codec_mute_pga(1);
			flash_mute = true;
		}
		ret = regulator_set_current_limit(flash_mode_ldo, flash_lum_table[lum], flash_lum_table[lum]);
		if (ret < 0){
			print_error("%s regulator_set_current_limit  fail ret = %d current is %d", __func__, ret, (flash_lum_table[lum]));
			goto out;
		}
		ret = scharger_flash_led_timeout_config(FLASH_TIMEOUT_MS);
		if (ret < 0){
			print_error("%s scharger_flash_led_timeout_config  fail ret = %d ", __func__, ret);
			goto out;
		}
		ret = scharger_flash_led_timeout_enable();
		if (ret < 0){
			print_error("%s scharger_flash_led_timeout_enable  fail ret = %d ", __func__, ret);
			goto out;
		}
		ret = regulator_enable(flash_inter_ldo);
		if (ret < 0){
			print_error("%s regulator_enable flash_inter_ldo fail ret = %d", __func__, ret);
			#if defined (CONFIG_HUAWEI_DSM)
			if (!dsm_client_ocuppy(client_ovisp22)){
			    dsm_client_record(client_ovisp22,"[%s]regulator_enable flash_inter_ldo fail mode %d\n",__func__,mode);
			    dsm_client_notify(client_ovisp22, DSM_ISP22_FLASH_ERROR_NO);
			}
			#endif
			goto out;
		}
		udelay(500);
		ret = regulator_enable(flash_mode_ldo);
		if (ret < 0){
			print_error("%s regulator_enable torch_mode_ldo fail ret = %d", __func__, ret);
			#if defined (CONFIG_HUAWEI_DSM)
			if (!dsm_client_ocuppy(client_ovisp22)){
			    dsm_client_record(client_ovisp22,"[%s]regulator_enable flash_mode_ldo fail mode %d\n",__func__,mode);
			    dsm_client_notify(client_ovisp22, DSM_ISP22_FLASH_ERROR_NO);
			}
			#endif
			if (flash_inter_ldo){
				regulator_disable(flash_inter_ldo);
			}
			goto out;
		}
		flash_on |= FLASH_FLASH_MODE;

	}
	
out:
	SAFE_UP(&switch_lock);
	return ret;
}