Merge tag 'jg-20061012-00' of git://electric-eye.fr.zoreil.com/home/romieu/linux...
[powerpc.git] / drivers / char / drm / drm_fops.c
index 403f44a..898f47d 100644 (file)
@@ -53,6 +53,8 @@ static int drm_setup(drm_device_t * dev)
                        return ret;
        }
 
+       dev->magicfree.next = NULL;
+
        /* prebuild the SAREA */
        i = drm_addmap(dev, 0, SAREA_MAX, _DRM_SHM, _DRM_CONTAINS_LOCK, &map);
        if (i != 0)
@@ -69,13 +71,11 @@ static int drm_setup(drm_device_t * dev)
                        return i;
        }
 
-       for (i = 0; i < DRM_ARRAY_SIZE(dev->counts); i++)
+       for (i = 0; i < ARRAY_SIZE(dev->counts); i++)
                atomic_set(&dev->counts[i], 0);
 
-       for (i = 0; i < DRM_HASH_SIZE; i++) {
-               dev->magiclist[i].head = NULL;
-               dev->magiclist[i].tail = NULL;
-       }
+       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)
@@ -175,7 +175,7 @@ int drm_stub_open(struct inode *inode, struct file *filp)
        drm_device_t *dev = NULL;
        int minor = iminor(inode);
        int err = -ENODEV;
-       struct file_operations *old_fops;
+       const struct file_operations *old_fops;
 
        DRM_DEBUG("\n");
 
@@ -262,7 +262,7 @@ static int drm_open_helper(struct inode *inode, struct file *filp,
                        goto out_free;
        }
 
-       down(&dev->struct_sem);
+       mutex_lock(&dev->struct_mutex);
        if (!dev->file_last) {
                priv->next = NULL;
                priv->prev = NULL;
@@ -276,7 +276,7 @@ static int drm_open_helper(struct inode *inode, struct file *filp,
                dev->file_last->next = priv;
                dev->file_last = priv;
        }
-       up(&dev->struct_sem);
+       mutex_unlock(&dev->struct_mutex);
 
 #ifdef __alpha__
        /*
@@ -413,7 +413,7 @@ int drm_release(struct inode *inode, struct file *filp)
 
        drm_fasync(-1, filp, 0);
 
-       down(&dev->ctxlist_sem);
+       mutex_lock(&dev->ctxlist_mutex);
        if (dev->ctxlist && (!list_empty(&dev->ctxlist->head))) {
                drm_ctx_list_t *pos, *n;
 
@@ -432,9 +432,9 @@ int drm_release(struct inode *inode, struct file *filp)
                        }
                }
        }
-       up(&dev->ctxlist_sem);
+       mutex_unlock(&dev->ctxlist_mutex);
 
-       down(&dev->struct_sem);
+       mutex_lock(&dev->struct_mutex);
        if (priv->remove_auth_on_close == 1) {
                drm_file_t *temp = dev->file_first;
                while (temp) {
@@ -452,7 +452,7 @@ int drm_release(struct inode *inode, struct file *filp)
        } else {
                dev->file_last = priv->prev;
        }
-       up(&dev->struct_sem);
+       mutex_unlock(&dev->struct_mutex);
 
        if (dev->driver->postclose)
                dev->driver->postclose(dev, priv);