Ejemplo n.º 1
0
static int agpioc_acquire_wrap(agp_file_private * priv, unsigned long arg)
{
	agp_controller *controller;
	if (!(test_bit(AGP_FF_ALLOW_CONTROLLER, &priv->access_flags))) {
		return -EPERM;
	}
	if (agp_fe.current_controller != NULL) {
		return -EBUSY;
	}
	if ((agp_backend_acquire()) == 0) {
		agp_fe.backend_acquired = TRUE;
	} else {
		return -EBUSY;
	}

	controller = agp_find_controller_by_pid(priv->my_pid);

	if (controller != NULL) {
		agp_controller_make_current(controller);
	} else {
		controller = agp_create_controller(priv->my_pid);

		if (controller == NULL) {
			agp_fe.backend_acquired = FALSE;
			agp_backend_release();
			return -ENOMEM;
		}
		agp_insert_controller(controller);
		agp_controller_make_current(controller);
	}

	set_bit(AGP_FF_IS_CONTROLLER, &priv->access_flags);
	set_bit(AGP_FF_IS_VALID, &priv->access_flags);
	return 0;
}
static int agpioc_acquire_wrap(struct agp_file_private *priv)
{
	int ret;
	struct agp_controller *controller;

	DBG("");

	if (!(test_bit(AGP_FF_ALLOW_CONTROLLER, &priv->access_flags)))
		return -EPERM;

	if (agp_fe.current_controller != NULL)
		return -EBUSY;

	ret = agp_backend_acquire();
	if (ret == 0)
		agp_fe.backend_acquired = TRUE;
	else
		return ret;

	controller = agp_find_controller_by_pid(priv->my_pid);

	if (controller != NULL) {
		agp_controller_make_current(controller);
	} else {
		controller = agp_create_controller(priv->my_pid);

		if (controller == NULL) {
			agp_fe.backend_acquired = FALSE;
			agp_backend_release();
			return -ENOMEM;
		}
		agp_insert_controller(controller);
		agp_controller_make_current(controller);
	}

	set_bit(AGP_FF_IS_CONTROLLER, &priv->access_flags);
	set_bit(AGP_FF_IS_VALID, &priv->access_flags);
	return 0;
}