コード例 #1
0
static int agp_ioctl(struct inode *inode, struct file *file,
		     unsigned int cmd, unsigned long arg)
{
	struct agp_file_private *curr_priv = file->private_data;
	int ret_val = -ENOTTY;

	DBG("priv=%p, cmd=%x", curr_priv, cmd);
	down(&(agp_fe.agp_mutex));

	if ((agp_fe.current_controller == NULL) &&
	    (cmd != AGPIOC_ACQUIRE)) {
		ret_val = -EINVAL;
	   	goto ioctl_out;
	}
	if ((agp_fe.backend_acquired != TRUE) &&
	    (cmd != AGPIOC_ACQUIRE)) {
		ret_val = -EBUSY;
	   	goto ioctl_out;
	}
	if (cmd != AGPIOC_ACQUIRE) {
		if (!(test_bit(AGP_FF_IS_CONTROLLER, &curr_priv->access_flags))) {
			ret_val = -EPERM;
		   	goto ioctl_out;
		}
		/* Use the original pid of the controller,
		 * in case it's threaded */

		if (agp_fe.current_controller->pid != curr_priv->my_pid) {
			ret_val = -EBUSY;
		   	goto ioctl_out;
		}
	}

	switch (cmd) {
	case AGPIOC_INFO:
		ret_val = agpioc_info_wrap(curr_priv, (void __user *) arg);
		break;

	case AGPIOC_ACQUIRE:
		ret_val = agpioc_acquire_wrap(curr_priv);
		break;
	   	
	case AGPIOC_RELEASE:
		ret_val = agpioc_release_wrap(curr_priv);
		break;
	   	
	case AGPIOC_SETUP:
		ret_val = agpioc_setup_wrap(curr_priv, (void __user *) arg);
		break;
	   	
	case AGPIOC_RESERVE:
		ret_val = agpioc_reserve_wrap(curr_priv, (void __user *) arg);
		break;
	   	
	case AGPIOC_PROTECT:
		ret_val = agpioc_protect_wrap(curr_priv);
		break;
	  	
	case AGPIOC_ALLOCATE:
		ret_val = agpioc_allocate_wrap(curr_priv, (void __user *) arg);
		break;
	   	
	case AGPIOC_DEALLOCATE:
		ret_val = agpioc_deallocate_wrap(curr_priv, (int) arg);
		break;
	   	
	case AGPIOC_BIND:
		ret_val = agpioc_bind_wrap(curr_priv, (void __user *) arg);
		break;
	   	
	case AGPIOC_UNBIND:
		ret_val = agpioc_unbind_wrap(curr_priv, (void __user *) arg);
		break;
	}

ioctl_out:
	DBG("ioctl returns %d\n", ret_val);
	up(&(agp_fe.agp_mutex));
	return ret_val;
}
コード例 #2
0
static int agp_ioctl(struct inode *inode, struct file *file,
		     unsigned int cmd, unsigned long arg)
{
	agp_file_private *curr_priv = (agp_file_private *) file->private_data;
	int ret_val = -ENOTTY;

	AGP_LOCK();

	if ((agp_fe.current_controller == NULL) &&
	    (cmd != AGPIOC_ACQUIRE)) {
		ret_val = -EINVAL;
	   	goto ioctl_out;
	}
	if ((agp_fe.backend_acquired != TRUE) &&
	    (cmd != AGPIOC_ACQUIRE)) {
		ret_val = -EBUSY;
	   	goto ioctl_out;
	}
	if (cmd != AGPIOC_ACQUIRE) {
		if (!(test_bit(AGP_FF_IS_CONTROLLER,
			       &curr_priv->access_flags))) {
			ret_val = -EPERM;
		   	goto ioctl_out;
		}
		/* Use the original pid of the controller,
		 * in case it's threaded */

		if (agp_fe.current_controller->pid != curr_priv->my_pid) {
			ret_val = -EBUSY;
		   	goto ioctl_out;
		}
	}
	switch (cmd) {
	case AGPIOC_INFO:
		{
			ret_val = agpioc_info_wrap(curr_priv, arg);
		   	goto ioctl_out;
		}
	case AGPIOC_ACQUIRE:
		{
			ret_val = agpioc_acquire_wrap(curr_priv, arg);
		   	goto ioctl_out;
		}
	case AGPIOC_RELEASE:
		{
			ret_val = agpioc_release_wrap(curr_priv, arg);
		   	goto ioctl_out;
		}
	case AGPIOC_SETUP:
		{
			ret_val = agpioc_setup_wrap(curr_priv, arg);
		   	goto ioctl_out;
		}
	case AGPIOC_RESERVE:
		{
			ret_val = agpioc_reserve_wrap(curr_priv, arg);
		   	goto ioctl_out;
		}
	case AGPIOC_PROTECT:
		{
			ret_val = agpioc_protect_wrap(curr_priv, arg);
		   	goto ioctl_out;
		}
	case AGPIOC_ALLOCATE:
		{
			ret_val = agpioc_allocate_wrap(curr_priv, arg);
		   	goto ioctl_out;
		}
	case AGPIOC_DEALLOCATE:
		{
			ret_val = agpioc_deallocate_wrap(curr_priv, arg);
		   	goto ioctl_out;
		}
	case AGPIOC_BIND:
		{
			ret_val = agpioc_bind_wrap(curr_priv, arg);
		   	goto ioctl_out;
		}
	case AGPIOC_UNBIND:
		{
			ret_val = agpioc_unbind_wrap(curr_priv, arg);
		   	goto ioctl_out;
		}
	}
   
ioctl_out:
	AGP_UNLOCK();
	return ret_val;
}