Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f1ae126c authored by Ville Syrjälä's avatar Ville Syrjälä Committed by Dave Airlie
Browse files

drm: Unify and fix idr error handling



The error handling code w.r.t. idr usage looks inconsistent.

In the case of drm_mode_object_get() and drm_ctxbitmap_next() the error
handling is also incomplete.

Unify the code to follow the same pattern always.

Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
parent 343d4a79
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -85,11 +85,12 @@ static int drm_ctxbitmap_next(struct drm_device * dev)
	mutex_lock(&dev->struct_mutex);
	ret = idr_get_new_above(&dev->ctx_idr, NULL,
				DRM_RESERVED_CONTEXTS, &new_id);
	if (ret == -EAGAIN) {
	mutex_unlock(&dev->struct_mutex);
	if (ret == -EAGAIN)
		goto again;
	}
	mutex_unlock(&dev->struct_mutex);
	else if (ret)
		return ret;

	return new_id;
}

+3 −1
Original line number Diff line number Diff line
@@ -227,7 +227,7 @@ static int drm_mode_object_get(struct drm_device *dev,
again:
	if (idr_pre_get(&dev->mode_config.crtc_idr, GFP_KERNEL) == 0) {
		DRM_ERROR("Ran out memory getting a mode number\n");
		return -EINVAL;
		return -ENOMEM;
	}

	mutex_lock(&dev->mode_config.idr_mutex);
@@ -235,6 +235,8 @@ static int drm_mode_object_get(struct drm_device *dev,
	mutex_unlock(&dev->mode_config.idr_mutex);
	if (ret == -EAGAIN)
		goto again;
	else if (ret)
		return ret;

	obj->id = new_id;
	obj->type = obj_type;
+2 −4
Original line number Diff line number Diff line
@@ -272,8 +272,7 @@ drm_gem_handle_create(struct drm_file *file_priv,
	spin_unlock(&file_priv->table_lock);
	if (ret == -EAGAIN)
		goto again;

	if (ret != 0)
	else if (ret)
		return ret;

	drm_gem_object_handle_reference(obj);
@@ -456,8 +455,7 @@ drm_gem_flink_ioctl(struct drm_device *dev, void *data,

		if (ret == -EAGAIN)
			goto again;

		if (ret != 0)
		else if (ret)
			goto err;

		/* Allocate a reference for the name table.  */
+2 −3
Original line number Diff line number Diff line
@@ -122,11 +122,10 @@ static int drm_minor_get_id(struct drm_device *dev, int type)
	ret = idr_get_new_above(&drm_minors_idr, NULL,
				base, &new_id);
	mutex_unlock(&dev->struct_mutex);
	if (ret == -EAGAIN) {
	if (ret == -EAGAIN)
		goto again;
	} else if (ret) {
	else if (ret)
		return ret;
	}

	if (new_id >= limit) {
		idr_remove(&drm_minors_idr, new_id);