aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVille Syrjälä <ville.syrjala@linux.intel.com>2012-03-15 13:58:31 -0400
committerDave Airlie <airlied@redhat.com>2012-04-24 04:50:20 -0400
commitf1ae126cdf1d1514da6e89a248232a7f7d315fe0 (patch)
treeb698a6cfeb735df7873865614f5f834fbcdaace9
parent343d4a79fdaeb8753201324c03fbc108f4e62636 (diff)
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: Ville Syrjälä <ville.syrjala@linux.intel.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
-rw-r--r--drivers/gpu/drm/drm_context.c9
-rw-r--r--drivers/gpu/drm/drm_crtc.c4
-rw-r--r--drivers/gpu/drm/drm_gem.c6
-rw-r--r--drivers/gpu/drm/drm_stub.c5
4 files changed, 12 insertions, 12 deletions
diff --git a/drivers/gpu/drm/drm_context.c b/drivers/gpu/drm/drm_context.c
index 325365f6d355..affa629589ac 100644
--- a/drivers/gpu/drm/drm_context.c
+++ b/drivers/gpu/drm/drm_context.c
@@ -85,11 +85,12 @@ again:
85 mutex_lock(&dev->struct_mutex); 85 mutex_lock(&dev->struct_mutex);
86 ret = idr_get_new_above(&dev->ctx_idr, NULL, 86 ret = idr_get_new_above(&dev->ctx_idr, NULL,
87 DRM_RESERVED_CONTEXTS, &new_id); 87 DRM_RESERVED_CONTEXTS, &new_id);
88 if (ret == -EAGAIN) {
89 mutex_unlock(&dev->struct_mutex);
90 goto again;
91 }
92 mutex_unlock(&dev->struct_mutex); 88 mutex_unlock(&dev->struct_mutex);
89 if (ret == -EAGAIN)
90 goto again;
91 else if (ret)
92 return ret;
93
93 return new_id; 94 return new_id;
94} 95}
95 96
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 4d4e8b055731..a9ca1b80fc28 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -227,7 +227,7 @@ static int drm_mode_object_get(struct drm_device *dev,
227again: 227again:
228 if (idr_pre_get(&dev->mode_config.crtc_idr, GFP_KERNEL) == 0) { 228 if (idr_pre_get(&dev->mode_config.crtc_idr, GFP_KERNEL) == 0) {
229 DRM_ERROR("Ran out memory getting a mode number\n"); 229 DRM_ERROR("Ran out memory getting a mode number\n");
230 return -EINVAL; 230 return -ENOMEM;
231 } 231 }
232 232
233 mutex_lock(&dev->mode_config.idr_mutex); 233 mutex_lock(&dev->mode_config.idr_mutex);
@@ -235,6 +235,8 @@ again:
235 mutex_unlock(&dev->mode_config.idr_mutex); 235 mutex_unlock(&dev->mode_config.idr_mutex);
236 if (ret == -EAGAIN) 236 if (ret == -EAGAIN)
237 goto again; 237 goto again;
238 else if (ret)
239 return ret;
238 240
239 obj->id = new_id; 241 obj->id = new_id;
240 obj->type = obj_type; 242 obj->type = obj_type;
diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
index 83114b5e3cee..fc6ded8f318b 100644
--- a/drivers/gpu/drm/drm_gem.c
+++ b/drivers/gpu/drm/drm_gem.c
@@ -272,8 +272,7 @@ again:
272 spin_unlock(&file_priv->table_lock); 272 spin_unlock(&file_priv->table_lock);
273 if (ret == -EAGAIN) 273 if (ret == -EAGAIN)
274 goto again; 274 goto again;
275 275 else if (ret)
276 if (ret != 0)
277 return ret; 276 return ret;
278 277
279 drm_gem_object_handle_reference(obj); 278 drm_gem_object_handle_reference(obj);
@@ -456,8 +455,7 @@ again:
456 455
457 if (ret == -EAGAIN) 456 if (ret == -EAGAIN)
458 goto again; 457 goto again;
459 458 else if (ret)
460 if (ret != 0)
461 goto err; 459 goto err;
462 460
463 /* Allocate a reference for the name table. */ 461 /* Allocate a reference for the name table. */
diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
index aa454f80e109..ae1ccf1d5d96 100644
--- a/drivers/gpu/drm/drm_stub.c
+++ b/drivers/gpu/drm/drm_stub.c
@@ -122,11 +122,10 @@ again:
122 ret = idr_get_new_above(&drm_minors_idr, NULL, 122 ret = idr_get_new_above(&drm_minors_idr, NULL,
123 base, &new_id); 123 base, &new_id);
124 mutex_unlock(&dev->struct_mutex); 124 mutex_unlock(&dev->struct_mutex);
125 if (ret == -EAGAIN) { 125 if (ret == -EAGAIN)
126 goto again; 126 goto again;
127 } else if (ret) { 127 else if (ret)
128 return ret; 128 return ret;
129 }
130 129
131 if (new_id >= limit) { 130 if (new_id >= limit) {
132 idr_remove(&drm_minors_idr, new_id); 131 idr_remove(&drm_minors_idr, new_id);