diff options
Diffstat (limited to 'drivers/char/drm/drm_agpsupport.c')
-rw-r--r-- | drivers/char/drm/drm_agpsupport.c | 28 |
1 files changed, 10 insertions, 18 deletions
diff --git a/drivers/char/drm/drm_agpsupport.c b/drivers/char/drm/drm_agpsupport.c index 40bfd9b01e39..54c59e7ec7b6 100644 --- a/drivers/char/drm/drm_agpsupport.c +++ b/drivers/char/drm/drm_agpsupport.c | |||
@@ -232,11 +232,7 @@ int drm_agp_alloc(drm_device_t *dev, drm_agp_buffer_t *request) | |||
232 | entry->memory = memory; | 232 | entry->memory = memory; |
233 | entry->bound = 0; | 233 | entry->bound = 0; |
234 | entry->pages = pages; | 234 | entry->pages = pages; |
235 | entry->prev = NULL; | 235 | list_add(&entry->head, &dev->agp->memory); |
236 | entry->next = dev->agp->memory; | ||
237 | if (dev->agp->memory) | ||
238 | dev->agp->memory->prev = entry; | ||
239 | dev->agp->memory = entry; | ||
240 | 236 | ||
241 | request->handle = entry->handle; | 237 | request->handle = entry->handle; |
242 | request->physical = memory->physical; | 238 | request->physical = memory->physical; |
@@ -262,10 +258,12 @@ int drm_agp_alloc_ioctl(struct inode *inode, struct file *filp, | |||
262 | return err; | 258 | return err; |
263 | 259 | ||
264 | if (copy_to_user(argp, &request, sizeof(request))) { | 260 | if (copy_to_user(argp, &request, sizeof(request))) { |
265 | drm_agp_mem_t *entry = dev->agp->memory; | 261 | drm_agp_mem_t *entry; |
266 | 262 | list_for_each_entry(entry, &dev->agp->memory, head) { | |
267 | dev->agp->memory = entry->next; | 263 | if (entry->handle == request.handle) |
268 | dev->agp->memory->prev = NULL; | 264 | break; |
265 | } | ||
266 | list_del(&entry->head); | ||
269 | drm_free_agp(entry->memory, entry->pages); | 267 | drm_free_agp(entry->memory, entry->pages); |
270 | drm_free(entry, sizeof(*entry), DRM_MEM_AGPLISTS); | 268 | drm_free(entry, sizeof(*entry), DRM_MEM_AGPLISTS); |
271 | return -EFAULT; | 269 | return -EFAULT; |
@@ -288,7 +286,7 @@ static drm_agp_mem_t *drm_agp_lookup_entry(drm_device_t * dev, | |||
288 | { | 286 | { |
289 | drm_agp_mem_t *entry; | 287 | drm_agp_mem_t *entry; |
290 | 288 | ||
291 | for (entry = dev->agp->memory; entry; entry = entry->next) { | 289 | list_for_each_entry(entry, &dev->agp->memory, head) { |
292 | if (entry->handle == handle) | 290 | if (entry->handle == handle) |
293 | return entry; | 291 | return entry; |
294 | } | 292 | } |
@@ -413,13 +411,7 @@ int drm_agp_free(drm_device_t *dev, drm_agp_buffer_t *request) | |||
413 | if (entry->bound) | 411 | if (entry->bound) |
414 | drm_unbind_agp(entry->memory); | 412 | drm_unbind_agp(entry->memory); |
415 | 413 | ||
416 | if (entry->prev) | 414 | list_del(&entry->head); |
417 | entry->prev->next = entry->next; | ||
418 | else | ||
419 | dev->agp->memory = entry->next; | ||
420 | |||
421 | if (entry->next) | ||
422 | entry->next->prev = entry->prev; | ||
423 | 415 | ||
424 | drm_free_agp(entry->memory, entry->pages); | 416 | drm_free_agp(entry->memory, entry->pages); |
425 | drm_free(entry, sizeof(*entry), DRM_MEM_AGPLISTS); | 417 | drm_free(entry, sizeof(*entry), DRM_MEM_AGPLISTS); |
@@ -472,7 +464,7 @@ drm_agp_head_t *drm_agp_init(drm_device_t * dev) | |||
472 | drm_free(head, sizeof(*head), DRM_MEM_AGPLISTS); | 464 | drm_free(head, sizeof(*head), DRM_MEM_AGPLISTS); |
473 | return NULL; | 465 | return NULL; |
474 | } | 466 | } |
475 | head->memory = NULL; | 467 | INIT_LIST_HEAD(&head->memory); |
476 | head->cant_use_aperture = head->agp_info.cant_use_aperture; | 468 | head->cant_use_aperture = head->agp_info.cant_use_aperture; |
477 | head->page_mask = head->agp_info.page_mask; | 469 | head->page_mask = head->agp_info.page_mask; |
478 | 470 | ||