zfcp_cfdc_dev_ioctl(struct inode *inode, struct file *file, unsigned int command, unsigned long buffer) 
zfcp_cfdc_dev_ioctl(struct file *file, unsigned int command, unsigned long buffer) 
zfcp_cfdc_dev_ioctl(struct inode *inode, struct file *file,                    unsigned int command, unsigned long buffer){	struct zfcp_cfdc_sense_data *sense_data, __user *sense_data_user;	struct zfcp_adapter *adapter = NULL;	struct zfcp_fsf_req *fsf_req = NULL;	struct zfcp_sg_list *sg_list = NULL;	u32 fsf_command, option;	char *bus_id = NULL;	int retval = 0;	sense_data = kmalloc(sizeof(struct zfcp_cfdc_sense_data), GFP_KERNEL);	if (sense_data == NULL) {		retval = -ENOMEM;		goto out;	}	sg_list = kmalloc(sizeof(struct zfcp_sg_list), GFP_KERNEL);	if (sg_list == NULL) {		retval = -ENOMEM;		goto out;	}	memset(sg_list, 0, sizeof(*sg_list));	if (command != ZFCP_CFDC_IOC) {		ZFCP_LOG_INFO("IOC request code 0x%x invalid\n", command);		retval = -ENOTTY;		goto out;	}	if ((sense_data_user = (void __user *) buffer) == NULL) {		ZFCP_LOG_INFO("sense data record is required\n");		retval = -EINVAL;		goto out;	}	retval = copy_from_user(sense_data, sense_data_user,				sizeof(struct zfcp_cfdc_sense_data));	if (retval) {		retval = -EFAULT;		goto out;	}	if (sense_data->signature != ZFCP_CFDC_SIGNATURE) {		ZFCP_LOG_INFO("invalid sense data request signature 0x%08x\n",			      ZFCP_CFDC_SIGNATURE);		retval = -EINVAL;		goto out;	}	switch (sense_data->command) {	case ZFCP_CFDC_CMND_DOWNLOAD_NORMAL:		fsf_command = FSF_QTCB_DOWNLOAD_CONTROL_FILE;		option = FSF_CFDC_OPTION_NORMAL_MODE;		break;	case ZFCP_CFDC_CMND_DOWNLOAD_FORCE:		fsf_command = FSF_QTCB_DOWNLOAD_CONTROL_FILE;		option = FSF_CFDC_OPTION_FORCE;		break;	case ZFCP_CFDC_CMND_FULL_ACCESS:		fsf_command = FSF_QTCB_DOWNLOAD_CONTROL_FILE;		option = FSF_CFDC_OPTION_FULL_ACCESS;		break;	case ZFCP_CFDC_CMND_RESTRICTED_ACCESS:		fsf_command = FSF_QTCB_DOWNLOAD_CONTROL_FILE;		option = FSF_CFDC_OPTION_RESTRICTED_ACCESS;		break;	case ZFCP_CFDC_CMND_UPLOAD:		fsf_command = FSF_QTCB_UPLOAD_CONTROL_FILE;		option = 0;		break;	default:		ZFCP_LOG_INFO("invalid command code 0x%08x\n",			      sense_data->command);		retval = -EINVAL;		goto out;	}	bus_id = kmalloc(BUS_ID_SIZE, GFP_KERNEL);	if (bus_id == NULL) {		retval = -ENOMEM;		goto out;	}	snprintf(bus_id, BUS_ID_SIZE, "%d.%d.%04x",		(sense_data->devno >> 24),		(sense_data->devno >> 16) & 0xFF,		(sense_data->devno & 0xFFFF));	read_lock_irq(&zfcp_data.config_lock);	adapter = zfcp_get_adapter_by_busid(bus_id);	if (adapter)		zfcp_adapter_get(adapter);	read_unlock_irq(&zfcp_data.config_lock);	kfree(bus_id);	if (adapter == NULL) {		ZFCP_LOG_INFO("invalid adapter\n");		retval = -ENXIO;		goto out;	}	if (sense_data->command & ZFCP_CFDC_WITH_CONTROL_FILE) {		retval = zfcp_sg_list_alloc(sg_list,					    ZFCP_CFDC_MAX_CONTROL_FILE_SIZE);		if (retval) {			retval = -ENOMEM;			goto out;		}	}	if ((sense_data->command & ZFCP_CFDC_DOWNLOAD) &&	    (sense_data->command & ZFCP_CFDC_WITH_CONTROL_FILE)) {		retval = zfcp_sg_list_copy_from_user(			sg_list, &sense_data_user->control_file,			ZFCP_CFDC_MAX_CONTROL_FILE_SIZE);		if (retval) {			retval = -EFAULT;			goto out;		}	}	retval = zfcp_fsf_control_file(adapter, &fsf_req, fsf_command,				       option, sg_list);	if (retval)		goto out;	if ((fsf_req->qtcb->prefix.prot_status != FSF_PROT_GOOD) &&	    (fsf_req->qtcb->prefix.prot_status != FSF_PROT_FSF_STATUS_PRESENTED)) {		retval = -ENXIO;		goto out;	}	sense_data->fsf_status = fsf_req->qtcb->header.fsf_status;	memcpy(&sense_data->fsf_status_qual,	       &fsf_req->qtcb->header.fsf_status_qual,	       sizeof(union fsf_status_qual));	memcpy(&sense_data->payloads, &fsf_req->qtcb->bottom.support.els, 256);	retval = copy_to_user(sense_data_user, sense_data,		sizeof(struct zfcp_cfdc_sense_data));	if (retval) {		retval = -EFAULT;		goto out;	}	if (sense_data->command & ZFCP_CFDC_UPLOAD) {		retval = zfcp_sg_list_copy_to_user(			&sense_data_user->control_file, sg_list,			ZFCP_CFDC_MAX_CONTROL_FILE_SIZE);		if (retval) {			retval = -EFAULT;			goto out;		}	} out:	if (fsf_req != NULL)		zfcp_fsf_req_cleanup(fsf_req);	if ((adapter != NULL) && (retval != -ENXIO))		zfcp_adapter_put(adapter);	if (sg_list != NULL) {		zfcp_sg_list_free(sg_list);		kfree(sg_list);	}	if (sense_data != NULL)		kfree(sense_data);	return retval;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/e183b06bf0be6c525867476df186d20f8f1efe54/zfcp_aux.c/buggy/drivers/s390/scsi/zfcp_aux.c