aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/drm/drm_drv.c
diff options
context:
space:
mode:
authorDave Airlie <airlied@linux.ie>2007-05-25 15:01:51 -0400
committerDave Airlie <airlied@linux.ie>2007-07-10 21:58:02 -0400
commitbd1b331fae2813d9f03ceee649296f02edc0b893 (patch)
tree6139f72ebae88c332c754745f3d98cbe794ae4de /drivers/char/drm/drm_drv.c
parent4eb6bf6bfb580afaf1e1a1d30cba17a078530cf4 (diff)
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 and uses them in some more places. Signed-off-by: Dave Airlie <airlied@linux.ie>
Diffstat (limited to 'drivers/char/drm/drm_drv.c')
-rw-r--r--drivers/char/drm/drm_drv.c36
1 files changed, 12 insertions, 24 deletions
diff --git a/drivers/char/drm/drm_drv.c b/drivers/char/drm/drm_drv.c
index 8e77b7ed0f4..d7d10f118ea 100644
--- a/drivers/char/drm/drm_drv.c
+++ b/drivers/char/drm/drm_drv.c
@@ -132,8 +132,8 @@ static drm_ioctl_desc_t drm_ioctls[] = {
132int drm_lastclose(drm_device_t * dev) 132int drm_lastclose(drm_device_t * dev)
133{ 133{
134 drm_magic_entry_t *pt, *next; 134 drm_magic_entry_t *pt, *next;
135 drm_map_list_t *r_list; 135 drm_map_list_t *r_list, *list_t;
136 drm_vma_entry_t *vma, *vma_next; 136 drm_vma_entry_t *vma, *vma_temp;
137 int i; 137 int i;
138 138
139 DRM_DEBUG("\n"); 139 DRM_DEBUG("\n");
@@ -178,19 +178,17 @@ int drm_lastclose(drm_device_t * dev)
178 178
179 /* Clear AGP information */ 179 /* Clear AGP information */
180 if (drm_core_has_AGP(dev) && dev->agp) { 180 if (drm_core_has_AGP(dev) && dev->agp) {
181 drm_agp_mem_t *entry; 181 drm_agp_mem_t *entry, *tempe;
182 drm_agp_mem_t *nexte;
183 182
184 /* Remove AGP resources, but leave dev->agp 183 /* Remove AGP resources, but leave dev->agp
185 intact until drv_cleanup is called. */ 184 intact until drv_cleanup is called. */
186 for (entry = dev->agp->memory; entry; entry = nexte) { 185 list_for_each_entry_safe(entry, tempe, &dev->agp->memory, head) {
187 nexte = entry->next;
188 if (entry->bound) 186 if (entry->bound)
189 drm_unbind_agp(entry->memory); 187 drm_unbind_agp(entry->memory);
190 drm_free_agp(entry->memory, entry->pages); 188 drm_free_agp(entry->memory, entry->pages);
191 drm_free(entry, sizeof(*entry), DRM_MEM_AGPLISTS); 189 drm_free(entry, sizeof(*entry), DRM_MEM_AGPLISTS);
192 } 190 }
193 dev->agp->memory = NULL; 191 INIT_LIST_HEAD(&dev->agp->memory);
194 192
195 if (dev->agp->acquired) 193 if (dev->agp->acquired)
196 drm_agp_release(dev); 194 drm_agp_release(dev);
@@ -204,20 +202,14 @@ int drm_lastclose(drm_device_t * dev)
204 } 202 }
205 203
206 /* Clear vma list (only built for debugging) */ 204 /* Clear vma list (only built for debugging) */
207 if (dev->vmalist) { 205 list_for_each_entry_safe(vma, vma_temp, &dev->vmalist, head) {
208 for (vma = dev->vmalist; vma; vma = vma_next) { 206 list_del(&vma->head);
209 vma_next = vma->next; 207 drm_free(vma, sizeof(*vma), DRM_MEM_VMAS);
210 drm_free(vma, sizeof(*vma), DRM_MEM_VMAS);
211 }
212 dev->vmalist = NULL;
213 } 208 }
214 209
215 if (dev->maplist) { 210 list_for_each_entry_safe(r_list, list_t, &dev->maplist, head) {
216 while (!list_empty(&dev->maplist->head)) { 211 drm_rmmap_locked(dev, r_list->map);
217 struct list_head *list = dev->maplist->head.next; 212 r_list = NULL;
218 r_list = list_entry(list, drm_map_list_t, head);
219 drm_rmmap_locked(dev, r_list->map);
220 }
221 } 213 }
222 214
223 if (drm_core_check_feature(dev, DRIVER_DMA_QUEUE) && dev->queuelist) { 215 if (drm_core_check_feature(dev, DRIVER_DMA_QUEUE) && dev->queuelist) {
@@ -309,11 +301,7 @@ static void drm_cleanup(drm_device_t * dev)
309 301
310 drm_lastclose(dev); 302 drm_lastclose(dev);
311 303
312 if (dev->maplist) { 304 drm_ht_remove(&dev->map_hash);
313 drm_free(dev->maplist, sizeof(*dev->maplist), DRM_MEM_MAPS);
314 dev->maplist = NULL;
315 drm_ht_remove(&dev->map_hash);
316 }
317 305
318 drm_ctxbitmap_cleanup(dev); 306 drm_ctxbitmap_cleanup(dev);
319 307