/* This handle (of course) holds a reference to the object, so the object will not go away until the handle is deleted.  */
int drm_gem_open_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv)
/* This handle (of course) holds a reference to the object, so the object will not go away until the handle is deleted.  */
int drm_gem_open_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv)
{
	struct drm_gem_open *args = data;
	struct drm_gem_object *obj;
	int ret;
	u32 handle;
	if (!(dev->driver->driver_features & DRIVER_GEM))
		return -ENODEV;
	spin_lock(&dev->object_name_lock);
	obj = idr_find(&dev->object_name_idr, (int) args->name);
	if (obj)
		drm_gem_object_reference(obj);
	spin_unlock(&dev->object_name_lock);
	if (!obj)
		return -ENOENT;
	ret = drm_gem_handle_create(file_priv, obj, &handle);
	mutex_lock(&dev->struct_mutex);
	drm_gem_object_unreference(obj);
	mutex_unlock(&dev->struct_mutex);
	if (ret)
		return ret;
	args->handle = handle;
	args->size = obj->size;
	return 0;
}