static long simple_sd_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
    struct msdc_ioctl *msdc_ctl = (struct msdc_ioctl *)arg;
	int ret;
	if(msdc_ctl == NULL){
		switch(cmd){
			//#ifdef MTK_SD_REINIT_SUPPORT
			case MSDC_REINIT_SDCARD:
				ret = sd_ioctl_reinit(msdc_ctl);
				break;
			//#endif
        	default:
            printk("mt_sd_ioctl:this opcode value is illegal!!\n");
            return -EINVAL;
			}
		return ret;		
	}
	else{	
    switch (msdc_ctl->opcode){
        case MSDC_SINGLE_READ_WRITE:
            msdc_ctl->result = simple_sd_ioctl_single_rw(msdc_ctl);
            break;
        case MSDC_MULTIPLE_READ_WRITE:
            msdc_ctl->result = simple_sd_ioctl_multi_rw(msdc_ctl);
            break;
        case MSDC_GET_CID:
            msdc_ctl->result = simple_sd_ioctl_get_cid(msdc_ctl);
            break;
        case MSDC_GET_CSD:
            msdc_ctl->result = simple_sd_ioctl_get_csd(msdc_ctl);
            break;
        case MSDC_GET_EXCSD:
            msdc_ctl->result = simple_sd_ioctl_get_excsd(msdc_ctl);
            break;
        case MSDC_DRIVING_SETTING:
            printk("in ioctl to change driving\n");
            if (1 == msdc_ctl->iswrite){
                msdc_ctl->result = simple_sd_ioctl_set_driving(msdc_ctl);
            } else {
                msdc_ctl->result = simple_sd_ioctl_get_driving(msdc_ctl);
            }
            break;
        case MSDC_ERASE_PARTITION:
            msdc_ctl->result = simple_mmc_erase_partition_wrap(msdc_ctl);
            break;
		case MSDC_SD30_MODE_SWITCH:
			msdc_ctl->result = simple_sd_ioctl_sd30_mode_switch(msdc_ctl);
			break;
        default:
            printk("simple_sd_ioctl:this opcode value is illegal!!\n");
            return -EINVAL;
    }

    return msdc_ctl->result;
}
}
static long simple_sd_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
    struct msdc_ioctl msdc_ctl;
    int ret;

    if((struct msdc_ioctl*)arg == NULL){
        switch(cmd){
            case MSDC_REINIT_SDCARD:
                ret = sd_ioctl_reinit((struct msdc_ioctl*)arg);
                break;

            case MSDC_CD_PIN_EN_SDCARD:
                ret = sd_ioctl_cd_pin_en((struct msdc_ioctl*)arg);
                break;

            default:
			pr_err("mt_sd_ioctl:this opcode value is illegal!!\n");
			return -EINVAL;
		}
		return ret;
    }
    else{
        if (copy_from_user(&msdc_ctl, (struct msdc_ioctl*)arg, sizeof(struct msdc_ioctl))){
            return -EFAULT;
        }

        switch (msdc_ctl.opcode){
            case MSDC_SINGLE_READ_WRITE:
                msdc_ctl.result = simple_sd_ioctl_single_rw(&msdc_ctl);
                break;
            case MSDC_MULTIPLE_READ_WRITE:
                msdc_ctl.result = simple_sd_ioctl_multi_rw(&msdc_ctl);
                break;
            case MSDC_GET_CID:
                msdc_ctl.result = simple_sd_ioctl_get_cid(&msdc_ctl);
                break;
            case MSDC_GET_CSD:
                msdc_ctl.result = simple_sd_ioctl_get_csd(&msdc_ctl);
                break;
            case MSDC_GET_EXCSD:
                msdc_ctl.result = simple_sd_ioctl_get_excsd(&msdc_ctl);
                break;
            case MSDC_DRIVING_SETTING:
			pr_debug("in ioctl to change driving\n");
                if (1 == msdc_ctl.iswrite){
                    msdc_ctl.result = simple_sd_ioctl_set_driving(&msdc_ctl);
                } else {
                    msdc_ctl.result = simple_sd_ioctl_get_driving(&msdc_ctl);
                }
                break;
            case MSDC_ERASE_PARTITION:
                msdc_ctl.result = simple_mmc_erase_partition_wrap(&msdc_ctl);
                break;
            case MSDC_SD30_MODE_SWITCH:
                msdc_ctl.result = simple_sd_ioctl_sd30_mode_switch(&msdc_ctl);
                break;
            default:
			pr_err("simple_sd_ioctl:this opcode value is illegal!!\n");
			return -EINVAL;
		}
        if (copy_to_user((struct msdc_ioctl*)arg, &msdc_ctl, sizeof(struct msdc_ioctl))) {
            return -EFAULT;
        }

        return msdc_ctl.result;
	}
}