diff options
author | Tejun Heo <tj@kernel.org> | 2013-02-27 20:04:08 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-02-27 22:10:15 -0500 |
commit | 2e928815c1886fe628ed54623aa98d0889cf5509 (patch) | |
tree | 50327f66bfd641e3c809db6c69af59956c8554df /drivers/gpu/drm/drm_crtc.c | |
parent | 62f516b8d6b0610c257b4f92264e00a8dee77a0b (diff) |
drm: convert to idr_alloc()
Convert to the much saner new idr interface.
* drm_ctxbitmap_next() error handling in drm_addctx() seems broken.
drm_ctxbitmap_next() return -errno on failure not -1.
[artem.savkov@gmail.com: missing idr_preload_end in drm_gem_flink_ioctl]
[jslaby@suse.cz: fix drm_gem_flink_ioctl() return value]
Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: David Airlie <airlied@linux.ie>
Signed-off-by: Artem Savkov <artem.savkov@gmail.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/gpu/drm/drm_crtc.c')
-rw-r--r-- | drivers/gpu/drm/drm_crtc.c | 19 |
1 files changed, 4 insertions, 15 deletions
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index 99928b933b16..792c3e3795ca 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c | |||
@@ -266,32 +266,21 @@ char *drm_get_connector_status_name(enum drm_connector_status status) | |||
266 | static int drm_mode_object_get(struct drm_device *dev, | 266 | static int drm_mode_object_get(struct drm_device *dev, |
267 | struct drm_mode_object *obj, uint32_t obj_type) | 267 | struct drm_mode_object *obj, uint32_t obj_type) |
268 | { | 268 | { |
269 | int new_id = 0; | ||
270 | int ret; | 269 | int ret; |
271 | 270 | ||
272 | again: | ||
273 | if (idr_pre_get(&dev->mode_config.crtc_idr, GFP_KERNEL) == 0) { | ||
274 | DRM_ERROR("Ran out memory getting a mode number\n"); | ||
275 | return -ENOMEM; | ||
276 | } | ||
277 | |||
278 | mutex_lock(&dev->mode_config.idr_mutex); | 271 | mutex_lock(&dev->mode_config.idr_mutex); |
279 | ret = idr_get_new_above(&dev->mode_config.crtc_idr, obj, 1, &new_id); | 272 | ret = idr_alloc(&dev->mode_config.crtc_idr, obj, 1, 0, GFP_KERNEL); |
280 | 273 | if (ret >= 0) { | |
281 | if (!ret) { | ||
282 | /* | 274 | /* |
283 | * Set up the object linking under the protection of the idr | 275 | * Set up the object linking under the protection of the idr |
284 | * lock so that other users can't see inconsistent state. | 276 | * lock so that other users can't see inconsistent state. |
285 | */ | 277 | */ |
286 | obj->id = new_id; | 278 | obj->id = ret; |
287 | obj->type = obj_type; | 279 | obj->type = obj_type; |
288 | } | 280 | } |
289 | mutex_unlock(&dev->mode_config.idr_mutex); | 281 | mutex_unlock(&dev->mode_config.idr_mutex); |
290 | 282 | ||
291 | if (ret == -EAGAIN) | 283 | return ret < 0 ? ret : 0; |
292 | goto again; | ||
293 | |||
294 | return ret; | ||
295 | } | 284 | } |
296 | 285 | ||
297 | /** | 286 | /** |