summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/drm_stub.c
diff options
context:
space:
mode:
authorDavid Herrmann <dh.herrmann@gmail.com>2014-02-24 15:35:09 +0100
committerDavid Herrmann <dh.herrmann@gmail.com>2014-03-16 12:25:19 +0100
commit7d86cf1a4fc0c0bdb6947185c6fe71301dfea7b1 (patch)
tree9e4b0285901252512e6239a5ceac72aff4a89258 /drivers/gpu/drm/drm_stub.c
parentdrm: coding-style fixes in minor handling (diff)
downloadlinux-7d86cf1a4fc0c0bdb6947185c6fe71301dfea7b1.tar.xz
linux-7d86cf1a4fc0c0bdb6947185c6fe71301dfea7b1.zip
drm: inline drm_minor_get_id()
We can significantly simplify this helper by using plain multiplication. Note that we converted the minor-type to an enum earlier so this didn't work before. We also fix a minor range-bug here: the limit argument of idr_alloc() is *exclusive*, not inclusive, so we should use 64 instead of 63 as offset. Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Diffstat (limited to 'drivers/gpu/drm/drm_stub.c')
-rw-r--r--drivers/gpu/drm/drm_stub.c27
1 files changed, 6 insertions, 21 deletions
diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
index 5268ffc5d94e..83ef4a63358c 100644
--- a/drivers/gpu/drm/drm_stub.c
+++ b/drivers/gpu/drm/drm_stub.c
@@ -117,26 +117,6 @@ void drm_ut_debug_printk(unsigned int request_level,
}
EXPORT_SYMBOL(drm_ut_debug_printk);
-static int drm_minor_get_id(struct drm_device *dev, int type)
-{
- int ret;
- int base = 0, limit = 63;
-
- if (type == DRM_MINOR_CONTROL) {
- base += 64;
- limit = base + 63;
- } else if (type == DRM_MINOR_RENDER) {
- base += 128;
- limit = base + 63;
- }
-
- mutex_lock(&dev->struct_mutex);
- ret = idr_alloc(&drm_minors_idr, NULL, base, limit, GFP_KERNEL);
- mutex_unlock(&dev->struct_mutex);
-
- return ret == -ENOSPC ? -EINVAL : ret;
-}
-
struct drm_master *drm_master_create(struct drm_minor *minor)
{
struct drm_master *master;
@@ -314,7 +294,12 @@ static int drm_minor_register(struct drm_device *dev, unsigned int type)
if (!new_minor)
return 0;
- minor_id = drm_minor_get_id(dev, type);
+ minor_id = idr_alloc(&drm_minors_idr,
+ NULL,
+ 64 * type,
+ 64 * (type + 1),
+ GFP_KERNEL);
+
if (minor_id < 0)
return minor_id;