diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2011-01-26 13:33:25 -0500 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2011-02-22 20:16:40 -0500 |
commit | 7811bddb6654337fd85837ef14c1a96a0c264745 (patch) | |
tree | 668ab27b5a002824f62434c9b8ffc0654e358ffd | |
parent | 4cb81ac2028a18f3f872f56fb7527afe5f5d0278 (diff) |
drm: Remove unused members from struct drm_open_hash
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Dave Airlie <airlied@redhat.com>
-rw-r--r-- | drivers/gpu/drm/drm_hashtab.c | 27 | ||||
-rw-r--r-- | include/drm/drm_hashtab.h | 6 |
2 files changed, 9 insertions, 24 deletions
diff --git a/drivers/gpu/drm/drm_hashtab.c b/drivers/gpu/drm/drm_hashtab.c index a93d7b4ddaa6..e3a75688f3cd 100644 --- a/drivers/gpu/drm/drm_hashtab.c +++ b/drivers/gpu/drm/drm_hashtab.c | |||
@@ -39,27 +39,18 @@ | |||
39 | 39 | ||
40 | int drm_ht_create(struct drm_open_hash *ht, unsigned int order) | 40 | int drm_ht_create(struct drm_open_hash *ht, unsigned int order) |
41 | { | 41 | { |
42 | unsigned int i; | 42 | unsigned int size = 1 << order; |
43 | 43 | ||
44 | ht->size = 1 << order; | ||
45 | ht->order = order; | 44 | ht->order = order; |
46 | ht->fill = 0; | ||
47 | ht->table = NULL; | 45 | ht->table = NULL; |
48 | ht->use_vmalloc = ((ht->size * sizeof(*ht->table)) > PAGE_SIZE); | 46 | if (size <= PAGE_SIZE / sizeof(*ht->table)) |
49 | if (!ht->use_vmalloc) { | 47 | ht->table = kcalloc(size, sizeof(*ht->table), GFP_KERNEL); |
50 | ht->table = kcalloc(ht->size, sizeof(*ht->table), GFP_KERNEL); | 48 | else |
51 | } | 49 | ht->table = vzalloc(size*sizeof(*ht->table)); |
52 | if (!ht->table) { | ||
53 | ht->use_vmalloc = 1; | ||
54 | ht->table = vmalloc(ht->size*sizeof(*ht->table)); | ||
55 | } | ||
56 | if (!ht->table) { | 50 | if (!ht->table) { |
57 | DRM_ERROR("Out of memory for hash table\n"); | 51 | DRM_ERROR("Out of memory for hash table\n"); |
58 | return -ENOMEM; | 52 | return -ENOMEM; |
59 | } | 53 | } |
60 | for (i=0; i< ht->size; ++i) { | ||
61 | INIT_HLIST_HEAD(&ht->table[i]); | ||
62 | } | ||
63 | return 0; | 54 | return 0; |
64 | } | 55 | } |
65 | EXPORT_SYMBOL(drm_ht_create); | 56 | EXPORT_SYMBOL(drm_ht_create); |
@@ -180,7 +171,6 @@ int drm_ht_remove_key(struct drm_open_hash *ht, unsigned long key) | |||
180 | list = drm_ht_find_key(ht, key); | 171 | list = drm_ht_find_key(ht, key); |
181 | if (list) { | 172 | if (list) { |
182 | hlist_del_init(list); | 173 | hlist_del_init(list); |
183 | ht->fill--; | ||
184 | return 0; | 174 | return 0; |
185 | } | 175 | } |
186 | return -EINVAL; | 176 | return -EINVAL; |
@@ -189,7 +179,6 @@ int drm_ht_remove_key(struct drm_open_hash *ht, unsigned long key) | |||
189 | int drm_ht_remove_item(struct drm_open_hash *ht, struct drm_hash_item *item) | 179 | int drm_ht_remove_item(struct drm_open_hash *ht, struct drm_hash_item *item) |
190 | { | 180 | { |
191 | hlist_del_init(&item->head); | 181 | hlist_del_init(&item->head); |
192 | ht->fill--; | ||
193 | return 0; | 182 | return 0; |
194 | } | 183 | } |
195 | EXPORT_SYMBOL(drm_ht_remove_item); | 184 | EXPORT_SYMBOL(drm_ht_remove_item); |
@@ -197,10 +186,10 @@ EXPORT_SYMBOL(drm_ht_remove_item); | |||
197 | void drm_ht_remove(struct drm_open_hash *ht) | 186 | void drm_ht_remove(struct drm_open_hash *ht) |
198 | { | 187 | { |
199 | if (ht->table) { | 188 | if (ht->table) { |
200 | if (ht->use_vmalloc) | 189 | if ((PAGE_SIZE / sizeof(*ht->table)) >> ht->order) |
201 | vfree(ht->table); | ||
202 | else | ||
203 | kfree(ht->table); | 190 | kfree(ht->table); |
191 | else | ||
192 | vfree(ht->table); | ||
204 | ht->table = NULL; | 193 | ht->table = NULL; |
205 | } | 194 | } |
206 | } | 195 | } |
diff --git a/include/drm/drm_hashtab.h b/include/drm/drm_hashtab.h index 0af087a4d3b3..3650d5d011ee 100644 --- a/include/drm/drm_hashtab.h +++ b/include/drm/drm_hashtab.h | |||
@@ -45,14 +45,10 @@ struct drm_hash_item { | |||
45 | }; | 45 | }; |
46 | 46 | ||
47 | struct drm_open_hash { | 47 | struct drm_open_hash { |
48 | unsigned int size; | ||
49 | unsigned int order; | ||
50 | unsigned int fill; | ||
51 | struct hlist_head *table; | 48 | struct hlist_head *table; |
52 | int use_vmalloc; | 49 | u8 order; |
53 | }; | 50 | }; |
54 | 51 | ||
55 | |||
56 | extern int drm_ht_create(struct drm_open_hash *ht, unsigned int order); | 52 | extern int drm_ht_create(struct drm_open_hash *ht, unsigned int order); |
57 | extern int drm_ht_insert_item(struct drm_open_hash *ht, struct drm_hash_item *item); | 53 | extern int drm_ht_insert_item(struct drm_open_hash *ht, struct drm_hash_item *item); |
58 | extern int drm_ht_just_insert_please(struct drm_open_hash *ht, struct drm_hash_item *item, | 54 | extern int drm_ht_just_insert_please(struct drm_open_hash *ht, struct drm_hash_item *item, |