drm: Remove unused members from struct drm_open_hash
authorChris Wilson <chris@chris-wilson.co.uk>
Wed, 26 Jan 2011 18:33:25 +0000 (18:33 +0000)
committerDave Airlie <airlied@redhat.com>
Wed, 23 Feb 2011 01:16:40 +0000 (11:16 +1000)
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Dave Airlie <airlied@redhat.com>
drivers/gpu/drm/drm_hashtab.c
include/drm/drm_hashtab.h

index a93d7b4ddaa6a75c795e88113d6faf07fe3f9024..e3a75688f3cdc6543b67fef3d6b8c3c2a6149a8c 100644 (file)
 
 int drm_ht_create(struct drm_open_hash *ht, unsigned int order)
 {
-       unsigned int i;
+       unsigned int size = 1 << order;
 
-       ht->size = 1 << order;
        ht->order = order;
-       ht->fill = 0;
        ht->table = NULL;
-       ht->use_vmalloc = ((ht->size * sizeof(*ht->table)) > PAGE_SIZE);
-       if (!ht->use_vmalloc) {
-               ht->table = kcalloc(ht->size, sizeof(*ht->table), GFP_KERNEL);
-       }
-       if (!ht->table) {
-               ht->use_vmalloc = 1;
-               ht->table = vmalloc(ht->size*sizeof(*ht->table));
-       }
+       if (size <= PAGE_SIZE / sizeof(*ht->table))
+               ht->table = kcalloc(size, sizeof(*ht->table), GFP_KERNEL);
+       else
+               ht->table = vzalloc(size*sizeof(*ht->table));
        if (!ht->table) {
                DRM_ERROR("Out of memory for hash table\n");
                return -ENOMEM;
        }
-       for (i=0; i< ht->size; ++i) {
-               INIT_HLIST_HEAD(&ht->table[i]);
-       }
        return 0;
 }
 EXPORT_SYMBOL(drm_ht_create);
@@ -180,7 +171,6 @@ int drm_ht_remove_key(struct drm_open_hash *ht, unsigned long key)
        list = drm_ht_find_key(ht, key);
        if (list) {
                hlist_del_init(list);
-               ht->fill--;
                return 0;
        }
        return -EINVAL;
@@ -189,7 +179,6 @@ int drm_ht_remove_key(struct drm_open_hash *ht, unsigned long key)
 int drm_ht_remove_item(struct drm_open_hash *ht, struct drm_hash_item *item)
 {
        hlist_del_init(&item->head);
-       ht->fill--;
        return 0;
 }
 EXPORT_SYMBOL(drm_ht_remove_item);
@@ -197,10 +186,10 @@ EXPORT_SYMBOL(drm_ht_remove_item);
 void drm_ht_remove(struct drm_open_hash *ht)
 {
        if (ht->table) {
-               if (ht->use_vmalloc)
-                       vfree(ht->table);
-               else
+               if ((PAGE_SIZE / sizeof(*ht->table)) >> ht->order)
                        kfree(ht->table);
+               else
+                       vfree(ht->table);
                ht->table = NULL;
        }
 }
index 0af087a4d3b38e7ecaf8aeb05f3b3e1ee2d224f0..3650d5d011ee7707890851889cff8a2e120796fb 100644 (file)
@@ -45,14 +45,10 @@ struct drm_hash_item {
 };
 
 struct drm_open_hash {
-       unsigned int size;
-       unsigned int order;
-       unsigned int fill;
        struct hlist_head *table;
-       int use_vmalloc;
+       u8 order;
 };
 
-
 extern int drm_ht_create(struct drm_open_hash *ht, unsigned int order);
 extern int drm_ht_insert_item(struct drm_open_hash *ht, struct drm_hash_item *item);
 extern int drm_ht_just_insert_please(struct drm_open_hash *ht, struct drm_hash_item *item,