From 7b48f0022a24bc5f565ae64b450dda77dee616c1 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Sat, 26 May 2007 04:26:24 +1000 Subject: 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. --- linux-core/drm_fops.c | 46 ++++++++++++---------------------------------- 1 file changed, 12 insertions(+), 34 deletions(-) (limited to 'linux-core/drm_fops.c') diff --git a/linux-core/drm_fops.c b/linux-core/drm_fops.c index d400a4d5..fce2be97 100644 --- a/linux-core/drm_fops.c +++ b/linux-core/drm_fops.c @@ -79,13 +79,9 @@ static int drm_setup(drm_device_t * dev) drm_ht_create(&dev->magiclist, DRM_MAGIC_HASH_ORDER); INIT_LIST_HEAD(&dev->magicfree); - dev->ctxlist = drm_alloc(sizeof(*dev->ctxlist), DRM_MEM_CTXLIST); - if (dev->ctxlist == NULL) - return -ENOMEM; - memset(dev->ctxlist, 0, sizeof(*dev->ctxlist)); - INIT_LIST_HEAD(&dev->ctxlist->head); + INIT_LIST_HEAD(&dev->ctxlist); + INIT_LIST_HEAD(&dev->vmalist); - dev->vmalist = NULL; dev->sigdata.lock = NULL; init_waitqueue_head(&dev->lock.lock_queue); dev->queue_count = 0; @@ -268,6 +264,7 @@ static int drm_open_helper(struct inode *inode, struct file *filp, priv->authenticated = capable(CAP_SYS_ADMIN); priv->lock_count = 0; + INIT_LIST_HEAD(&priv->lhead); INIT_LIST_HEAD(&priv->user_objects); INIT_LIST_HEAD(&priv->refd_objects); @@ -291,19 +288,10 @@ static int drm_open_helper(struct inode *inode, struct file *filp, } mutex_lock(&dev->struct_mutex); - if (!dev->file_last) { - priv->next = NULL; - priv->prev = NULL; - dev->file_first = priv; - dev->file_last = priv; - /* first opener automatically becomes master */ + if (list_empty(&dev->filelist)) priv->master = 1; - } else { - priv->next = NULL; - priv->prev = dev->file_last; - dev->file_last->next = priv; - dev->file_last = priv; - } + + list_add(&priv->lhead, &dev->filelist); mutex_unlock(&dev->struct_mutex); #ifdef __alpha__ @@ -480,10 +468,10 @@ int drm_release(struct inode *inode, struct file *filp) mutex_lock(&dev->ctxlist_mutex); - if (dev->ctxlist && (!list_empty(&dev->ctxlist->head))) { + if (!list_empty(&dev->ctxlist)) { drm_ctx_list_t *pos, *n; - list_for_each_entry_safe(pos, n, &dev->ctxlist->head, head) { + list_for_each_entry_safe(pos, n, &dev->ctxlist, head) { if (pos->tag == priv && pos->handle != DRM_KERNEL_CONTEXT) { if (dev->driver->context_dtor) @@ -503,22 +491,12 @@ int drm_release(struct inode *inode, struct file *filp) mutex_lock(&dev->struct_mutex); drm_object_release(filp); if (priv->remove_auth_on_close == 1) { - drm_file_t *temp = dev->file_first; - while (temp) { + drm_file_t *temp; + + list_for_each_entry(temp, &dev->filelist, lhead) temp->authenticated = 0; - temp = temp->next; - } - } - if (priv->prev) { - priv->prev->next = priv->next; - } else { - dev->file_first = priv->next; - } - if (priv->next) { - priv->next->prev = priv->prev; - } else { - dev->file_last = priv->prev; } + list_del(&priv->lhead); mutex_unlock(&dev->struct_mutex); if (dev->driver->postclose) -- cgit v1.2.3