aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/drm_hashtab.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/drm_hashtab.c')
-rw-r--r--drivers/gpu/drm/drm_hashtab.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/drivers/gpu/drm/drm_hashtab.c b/drivers/gpu/drm/drm_hashtab.c
index 80254547a3f8..7e4bae760e27 100644
--- a/drivers/gpu/drm/drm_hashtab.c
+++ b/drivers/gpu/drm/drm_hashtab.c
@@ -60,14 +60,13 @@ void drm_ht_verbose_list(struct drm_open_hash *ht, unsigned long key)
60{ 60{
61 struct drm_hash_item *entry; 61 struct drm_hash_item *entry;
62 struct hlist_head *h_list; 62 struct hlist_head *h_list;
63 struct hlist_node *list;
64 unsigned int hashed_key; 63 unsigned int hashed_key;
65 int count = 0; 64 int count = 0;
66 65
67 hashed_key = hash_long(key, ht->order); 66 hashed_key = hash_long(key, ht->order);
68 DRM_DEBUG("Key is 0x%08lx, Hashed key is 0x%08x\n", key, hashed_key); 67 DRM_DEBUG("Key is 0x%08lx, Hashed key is 0x%08x\n", key, hashed_key);
69 h_list = &ht->table[hashed_key]; 68 h_list = &ht->table[hashed_key];
70 hlist_for_each_entry(entry, list, h_list, head) 69 hlist_for_each_entry(entry, h_list, head)
71 DRM_DEBUG("count %d, key: 0x%08lx\n", count++, entry->key); 70 DRM_DEBUG("count %d, key: 0x%08lx\n", count++, entry->key);
72} 71}
73 72
@@ -76,14 +75,13 @@ static struct hlist_node *drm_ht_find_key(struct drm_open_hash *ht,
76{ 75{
77 struct drm_hash_item *entry; 76 struct drm_hash_item *entry;
78 struct hlist_head *h_list; 77 struct hlist_head *h_list;
79 struct hlist_node *list;
80 unsigned int hashed_key; 78 unsigned int hashed_key;
81 79
82 hashed_key = hash_long(key, ht->order); 80 hashed_key = hash_long(key, ht->order);
83 h_list = &ht->table[hashed_key]; 81 h_list = &ht->table[hashed_key];
84 hlist_for_each_entry(entry, list, h_list, head) { 82 hlist_for_each_entry(entry, h_list, head) {
85 if (entry->key == key) 83 if (entry->key == key)
86 return list; 84 return &entry->head;
87 if (entry->key > key) 85 if (entry->key > key)
88 break; 86 break;
89 } 87 }
@@ -95,14 +93,13 @@ static struct hlist_node *drm_ht_find_key_rcu(struct drm_open_hash *ht,
95{ 93{
96 struct drm_hash_item *entry; 94 struct drm_hash_item *entry;
97 struct hlist_head *h_list; 95 struct hlist_head *h_list;
98 struct hlist_node *list;
99 unsigned int hashed_key; 96 unsigned int hashed_key;
100 97
101 hashed_key = hash_long(key, ht->order); 98 hashed_key = hash_long(key, ht->order);
102 h_list = &ht->table[hashed_key]; 99 h_list = &ht->table[hashed_key];
103 hlist_for_each_entry_rcu(entry, list, h_list, head) { 100 hlist_for_each_entry_rcu(entry, h_list, head) {
104 if (entry->key == key) 101 if (entry->key == key)
105 return list; 102 return &entry->head;
106 if (entry->key > key) 103 if (entry->key > key)
107 break; 104 break;
108 } 105 }
@@ -113,19 +110,19 @@ int drm_ht_insert_item(struct drm_open_hash *ht, struct drm_hash_item *item)
113{ 110{
114 struct drm_hash_item *entry; 111 struct drm_hash_item *entry;
115 struct hlist_head *h_list; 112 struct hlist_head *h_list;
116 struct hlist_node *list, *parent; 113 struct hlist_node *parent;
117 unsigned int hashed_key; 114 unsigned int hashed_key;
118 unsigned long key = item->key; 115 unsigned long key = item->key;
119 116
120 hashed_key = hash_long(key, ht->order); 117 hashed_key = hash_long(key, ht->order);
121 h_list = &ht->table[hashed_key]; 118 h_list = &ht->table[hashed_key];
122 parent = NULL; 119 parent = NULL;
123 hlist_for_each_entry(entry, list, h_list, head) { 120 hlist_for_each_entry(entry, h_list, head) {
124 if (entry->key == key) 121 if (entry->key == key)
125 return -EINVAL; 122 return -EINVAL;
126 if (entry->key > key) 123 if (entry->key > key)
127 break; 124 break;
128 parent = list; 125 parent = &entry->head;
129 } 126 }
130 if (parent) { 127 if (parent) {
131 hlist_add_after_rcu(parent, &item->head); 128 hlist_add_after_rcu(parent, &item->head);