aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/drm/drm_vm.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_vm.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_vm.c')
-rw-r--r--drivers/char/drm/drm_vm.c34
1 files changed, 10 insertions, 24 deletions
diff --git a/drivers/char/drm/drm_vm.c b/drivers/char/drm/drm_vm.c
index b5c5b9fa84c..948e60d272d 100644
--- a/drivers/char/drm/drm_vm.c
+++ b/drivers/char/drm/drm_vm.c
@@ -116,7 +116,7 @@ static __inline__ struct page *drm_do_vm_nopage(struct vm_area_struct *vma,
116 /* 116 /*
117 * It's AGP memory - find the real physical page to map 117 * It's AGP memory - find the real physical page to map
118 */ 118 */
119 for (agpmem = dev->agp->memory; agpmem; agpmem = agpmem->next) { 119 list_for_each_entry(agpmem, &dev->agp->memory, head) {
120 if (agpmem->bound <= baddr && 120 if (agpmem->bound <= baddr &&
121 agpmem->bound + agpmem->pages * PAGE_SIZE > baddr) 121 agpmem->bound + agpmem->pages * PAGE_SIZE > baddr)
122 break; 122 break;
@@ -196,10 +196,9 @@ static void drm_vm_shm_close(struct vm_area_struct *vma)
196{ 196{
197 drm_file_t *priv = vma->vm_file->private_data; 197 drm_file_t *priv = vma->vm_file->private_data;
198 drm_device_t *dev = priv->head->dev; 198 drm_device_t *dev = priv->head->dev;
199 drm_vma_entry_t *pt, *prev, *next; 199 drm_vma_entry_t *pt, *temp;
200 drm_map_t *map; 200 drm_map_t *map;
201 drm_map_list_t *r_list; 201 drm_map_list_t *r_list;
202 struct list_head *list;
203 int found_maps = 0; 202 int found_maps = 0;
204 203
205 DRM_DEBUG("0x%08lx,0x%08lx\n", 204 DRM_DEBUG("0x%08lx,0x%08lx\n",
@@ -209,30 +208,22 @@ static void drm_vm_shm_close(struct vm_area_struct *vma)
209 map = vma->vm_private_data; 208 map = vma->vm_private_data;
210 209
211 mutex_lock(&dev->struct_mutex); 210 mutex_lock(&dev->struct_mutex);
212 for (pt = dev->vmalist, prev = NULL; pt; pt = next) { 211 list_for_each_entry_safe(pt, temp, &dev->vmalist, head) {
213 next = pt->next;
214 if (pt->vma->vm_private_data == map) 212 if (pt->vma->vm_private_data == map)
215 found_maps++; 213 found_maps++;
216 if (pt->vma == vma) { 214 if (pt->vma == vma) {
217 if (prev) { 215 list_del(&pt->head);
218 prev->next = pt->next;
219 } else {
220 dev->vmalist = pt->next;
221 }
222 drm_free(pt, sizeof(*pt), DRM_MEM_VMAS); 216 drm_free(pt, sizeof(*pt), DRM_MEM_VMAS);
223 } else {
224 prev = pt;
225 } 217 }
226 } 218 }
219
227 /* We were the only map that was found */ 220 /* We were the only map that was found */
228 if (found_maps == 1 && map->flags & _DRM_REMOVABLE) { 221 if (found_maps == 1 && map->flags & _DRM_REMOVABLE) {
229 /* Check to see if we are in the maplist, if we are not, then 222 /* Check to see if we are in the maplist, if we are not, then
230 * we delete this mappings information. 223 * we delete this mappings information.
231 */ 224 */
232 found_maps = 0; 225 found_maps = 0;
233 list = &dev->maplist->head; 226 list_for_each_entry(r_list, &dev->maplist, head) {
234 list_for_each(list, &dev->maplist->head) {
235 r_list = list_entry(list, drm_map_list_t, head);
236 if (r_list->map == map) 227 if (r_list->map == map)
237 found_maps++; 228 found_maps++;
238 } 229 }
@@ -425,9 +416,8 @@ static void drm_vm_open_locked(struct vm_area_struct *vma)
425 vma_entry = drm_alloc(sizeof(*vma_entry), DRM_MEM_VMAS); 416 vma_entry = drm_alloc(sizeof(*vma_entry), DRM_MEM_VMAS);
426 if (vma_entry) { 417 if (vma_entry) {
427 vma_entry->vma = vma; 418 vma_entry->vma = vma;
428 vma_entry->next = dev->vmalist;
429 vma_entry->pid = current->pid; 419 vma_entry->pid = current->pid;
430 dev->vmalist = vma_entry; 420 list_add(&vma_entry->head, &dev->vmalist);
431 } 421 }
432} 422}
433 423
@@ -453,20 +443,16 @@ static void drm_vm_close(struct vm_area_struct *vma)
453{ 443{
454 drm_file_t *priv = vma->vm_file->private_data; 444 drm_file_t *priv = vma->vm_file->private_data;
455 drm_device_t *dev = priv->head->dev; 445 drm_device_t *dev = priv->head->dev;
456 drm_vma_entry_t *pt, *prev; 446 drm_vma_entry_t *pt, *temp;
457 447
458 DRM_DEBUG("0x%08lx,0x%08lx\n", 448 DRM_DEBUG("0x%08lx,0x%08lx\n",
459 vma->vm_start, vma->vm_end - vma->vm_start); 449 vma->vm_start, vma->vm_end - vma->vm_start);
460 atomic_dec(&dev->vma_count); 450 atomic_dec(&dev->vma_count);
461 451
462 mutex_lock(&dev->struct_mutex); 452 mutex_lock(&dev->struct_mutex);
463 for (pt = dev->vmalist, prev = NULL; pt; prev = pt, pt = pt->next) { 453 list_for_each_entry_safe(pt, temp, &dev->vmalist, head) {
464 if (pt->vma == vma) { 454 if (pt->vma == vma) {
465 if (prev) { 455 list_del(&pt->head);
466 prev->next = pt->next;
467 } else {
468 dev->vmalist = pt->next;
469 }
470 drm_free(pt, sizeof(*pt), DRM_MEM_VMAS); 456 drm_free(pt, sizeof(*pt), DRM_MEM_VMAS);
471 break; 457 break;
472 } 458 }