aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/drm/drm_fops.c
diff options
context:
space:
mode:
authorDave Airlie <airlied@linux.ie>2007-05-25 15:01:51 -0400
committerDave Airlie <airlied@linux.ie>2007-07-10 21:58:02 -0400
commitbd1b331fae2813d9f03ceee649296f02edc0b893 (patch)
tree6139f72ebae88c332c754745f3d98cbe794ae4de /drivers/char/drm/drm_fops.c
parent4eb6bf6bfb580afaf1e1a1d30cba17a078530cf4 (diff)
drm: cleanup use of Linux list handling macros
This makes the drms use of the list handling macros a lot cleaner and more along the lines of how they should be used and uses them in some more places. Signed-off-by: Dave Airlie <airlied@linux.ie>
Diffstat (limited to 'drivers/char/drm/drm_fops.c')
-rw-r--r--drivers/char/drm/drm_fops.c47
1 files changed, 13 insertions, 34 deletions
diff --git a/drivers/char/drm/drm_fops.c b/drivers/char/drm/drm_fops.c
index 3b159cab3bc8..e82e78fa42b0 100644
--- a/drivers/char/drm/drm_fops.c
+++ b/drivers/char/drm/drm_fops.c
@@ -79,13 +79,9 @@ static int drm_setup(drm_device_t * dev)
79 drm_ht_create(&dev->magiclist, DRM_MAGIC_HASH_ORDER); 79 drm_ht_create(&dev->magiclist, DRM_MAGIC_HASH_ORDER);
80 INIT_LIST_HEAD(&dev->magicfree); 80 INIT_LIST_HEAD(&dev->magicfree);
81 81
82 dev->ctxlist = drm_alloc(sizeof(*dev->ctxlist), DRM_MEM_CTXLIST); 82 INIT_LIST_HEAD(&dev->ctxlist);
83 if (dev->ctxlist == NULL) 83 INIT_LIST_HEAD(&dev->vmalist);
84 return -ENOMEM;
85 memset(dev->ctxlist, 0, sizeof(*dev->ctxlist));
86 INIT_LIST_HEAD(&dev->ctxlist->head);
87 84
88 dev->vmalist = NULL;
89 dev->sigdata.lock = NULL; 85 dev->sigdata.lock = NULL;
90 init_waitqueue_head(&dev->lock.lock_queue); 86 init_waitqueue_head(&dev->lock.lock_queue);
91 dev->queue_count = 0; 87 dev->queue_count = 0;
@@ -258,6 +254,8 @@ static int drm_open_helper(struct inode *inode, struct file *filp,
258 priv->authenticated = capable(CAP_SYS_ADMIN); 254 priv->authenticated = capable(CAP_SYS_ADMIN);
259 priv->lock_count = 0; 255 priv->lock_count = 0;
260 256
257 INIT_LIST_HEAD(&priv->lhead);
258
261 if (dev->driver->open) { 259 if (dev->driver->open) {
262 ret = dev->driver->open(dev, priv); 260 ret = dev->driver->open(dev, priv);
263 if (ret < 0) 261 if (ret < 0)
@@ -265,19 +263,10 @@ static int drm_open_helper(struct inode *inode, struct file *filp,
265 } 263 }
266 264
267 mutex_lock(&dev->struct_mutex); 265 mutex_lock(&dev->struct_mutex);
268 if (!dev->file_last) { 266 if (list_empty(&dev->filelist))
269 priv->next = NULL;
270 priv->prev = NULL;
271 dev->file_first = priv;
272 dev->file_last = priv;
273 /* first opener automatically becomes master */
274 priv->master = 1; 267 priv->master = 1;
275 } else { 268
276 priv->next = NULL; 269 list_add(&priv->lhead, &dev->filelist);
277 priv->prev = dev->file_last;
278 dev->file_last->next = priv;
279 dev->file_last = priv;
280 }
281 mutex_unlock(&dev->struct_mutex); 270 mutex_unlock(&dev->struct_mutex);
282 271
283#ifdef __alpha__ 272#ifdef __alpha__
@@ -414,10 +403,10 @@ int drm_release(struct inode *inode, struct file *filp)
414 drm_fasync(-1, filp, 0); 403 drm_fasync(-1, filp, 0);
415 404
416 mutex_lock(&dev->ctxlist_mutex); 405 mutex_lock(&dev->ctxlist_mutex);
417 if (dev->ctxlist && (!list_empty(&dev->ctxlist->head))) { 406 if (!list_empty(&dev->ctxlist)) {
418 drm_ctx_list_t *pos, *n; 407 drm_ctx_list_t *pos, *n;
419 408
420 list_for_each_entry_safe(pos, n, &dev->ctxlist->head, head) { 409 list_for_each_entry_safe(pos, n, &dev->ctxlist, head) {
421 if (pos->tag == priv && 410 if (pos->tag == priv &&
422 pos->handle != DRM_KERNEL_CONTEXT) { 411 pos->handle != DRM_KERNEL_CONTEXT) {
423 if (dev->driver->context_dtor) 412 if (dev->driver->context_dtor)
@@ -436,22 +425,12 @@ int drm_release(struct inode *inode, struct file *filp)
436 425
437 mutex_lock(&dev->struct_mutex); 426 mutex_lock(&dev->struct_mutex);
438 if (priv->remove_auth_on_close == 1) { 427 if (priv->remove_auth_on_close == 1) {
439 drm_file_t *temp = dev->file_first; 428 drm_file_t *temp;
440 while (temp) { 429
430 list_for_each_entry(temp, &dev->filelist, lhead)
441 temp->authenticated = 0; 431 temp->authenticated = 0;
442 temp = temp->next;
443 }
444 }
445 if (priv->prev) {
446 priv->prev->next = priv->next;
447 } else {
448 dev->file_first = priv->next;
449 }
450 if (priv->next) {
451 priv->next->prev = priv->prev;
452 } else {
453 dev->file_last = priv->prev;
454 } 432 }
433 list_del(&priv->lhead);
455 mutex_unlock(&dev->struct_mutex); 434 mutex_unlock(&dev->struct_mutex);
456 435
457 if (dev->driver->postclose) 436 if (dev->driver->postclose)