static int SetSecurityUnlock(struct wacom_i2c *wac_i2c, int *pStatus)
{
	int rv;

	if (!flash_query(wac_i2c)) {
		if (!wacom_flash_cmd(wac_i2c)) {
			return EXIT_FAIL_ENTER_FLASH_MODE;
		} else {
			msleep(100);
			if (!flash_query(wac_i2c))
				return EXIT_FAIL_FLASH_QUERY;
		}
	}

	rv = flash_security_unlock(wac_i2c, pStatus);
	if (rv)
		return EXIT_OK;
	else
		return EXIT_FAIL;
}
static int GetMpuType(struct wacom_i2c *wac_i2c, int *pMpuType)
{
	int rv;

	if (!flash_query(wac_i2c)) {
		if (!wacom_flash_cmd(wac_i2c)) {
			return EXIT_FAIL_ENTER_FLASH_MODE;
		} else {
			msleep(100);
			if (!flash_query(wac_i2c))
				return EXIT_FAIL_FLASH_QUERY;
		}
	}

	rv = flash_mputype(wac_i2c, pMpuType);
	if (rv)
		return EXIT_OK;
	else
		return EXIT_FAIL_GET_MPU_TYPE;
}
int wacom_i2c_flash(struct wacom_i2c *wac_i2c)
{
	int ret;

	fw_data = wac_i2c->fw_img->data;
	if (fw_data == NULL) {
		printk(KERN_ERR "epen:Data is NULL. Exit.\n");
		return -1;
	}

	wac_i2c->pdata->compulsory_flash_mode(true);
	wac_i2c->pdata->reset_platform_hw();
	msleep(200);

	ret = wacom_flash_cmd(wac_i2c);
	if (ret < 0) {
		printk(KERN_DEBUG"epen:%s cannot send flash command \n", __func__);
	}

	ret = flash_query(wac_i2c);
	if (ret < 0) {
		printk(KERN_DEBUG"epen:%s Error: cannot send query \n", __func__);
		ret = -EXIT_FAIL;
		goto end_wacom_flash;
	}

	ret = wacom_i2c_flash_w9012(wac_i2c, fw_data);
	if (ret < 0) {
		printk(KERN_DEBUG"epen:%s Error: flash failed \n", __func__);
		ret = -EXIT_FAIL;
		goto end_wacom_flash;
	}

 end_wacom_flash:
	wac_i2c->pdata->compulsory_flash_mode(false);
	wac_i2c->pdata->reset_platform_hw();
	msleep(200);

	return ret;
}
static int GetBLVersion(struct wacom_i2c *wac_i2c, int *pBLVer)
{
	int rv;
	int retry = 0;

	rv = wacom_flash_cmd(wac_i2c);
	if (rv < 0)
		msleep(500);

	do {
		msleep(100);
		rv = flash_query(wac_i2c);
		retry++;
	} while (rv < 0 && retry < 10);

	if (rv < 0)
		return EXIT_FAIL_GET_BOOT_LOADER_VERSION;

	rv = flash_blver(wac_i2c, pBLVer);
	if (rv)
		return EXIT_OK;
	else
		return EXIT_FAIL_GET_BOOT_LOADER_VERSION;
}