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 agp_release(struct inode *inode, struct file *file) { struct agp_file_private *priv = file->private_data; down(&(agp_fe.agp_mutex)); DBG("priv=%p", priv); if (test_bit(AGP_FF_IS_CONTROLLER, &priv->access_flags)) { struct agp_controller *controller; controller = agp_find_controller_by_pid(priv->my_pid); if (controller != NULL) { if (controller == agp_fe.current_controller) agp_controller_release_current(controller, priv); agp_remove_controller(controller); controller = NULL; } } if (test_bit(AGP_FF_IS_CLIENT, &priv->access_flags)) agp_remove_client(priv->my_pid); agp_remove_file_private(priv); kfree(priv); file->private_data = NULL; up(&(agp_fe.agp_mutex)); return 0; }
static int agp_release(struct inode *inode, struct file *file) { agp_file_private *priv = (agp_file_private *) file->private_data; lock_kernel(); AGP_LOCK(); if (test_bit(AGP_FF_IS_CONTROLLER, &priv->access_flags)) { agp_controller *controller; controller = agp_find_controller_by_pid(priv->my_pid); if (controller != NULL) { if (controller == agp_fe.current_controller) { agp_controller_release_current(controller, priv); } agp_remove_controller(controller); } } if (test_bit(AGP_FF_IS_CLIENT, &priv->access_flags)) { agp_remove_client(priv->my_pid); } agp_remove_file_private(priv); kfree(priv); AGP_UNLOCK(); unlock_kernel(); 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; }