Pekka J Enberg
2008-Mar-09 16:36 UTC
[Nouveau] [PATCH 2/4] nouveau: add nouveau_map_block function
From: Pekka Enberg <penberg at cs.helsinki.fi> This extracts the struct mem_block to struct drm_map_list entry mapping into a separate function. Signed-off-by: Pekka Enberg <penberg at cs.helsinki.fi> --- shared-core/nouveau_mem.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) Index: drm/shared-core/nouveau_mem.c ==================================================================--- drm.orig/shared-core/nouveau_mem.c +++ drm/shared-core/nouveau_mem.c @@ -515,6 +515,20 @@ int nouveau_mem_init(struct drm_device * return 0; } +/* Returns zero on success; otherwise returns non-zero. */ +static int nouveau_map_block(struct drm_device *dev, struct mem_block *block) +{ + struct drm_map_list *entry; + + entry = drm_find_matching_map(dev, block->map); + if (!entry) + return -EINVAL; + + block->map_handle = entry->user_token; + block->flags |= NOUVEAU_MEM_MAPPED; + return 0; +} + static int nouveau_addmap(struct drm_device *dev, struct mem_block *block, unsigned long offset, enum drm_map_type type) { @@ -619,9 +633,7 @@ alloc_ok: if (flags&NOUVEAU_MEM_MAPPED) { - struct drm_map_list *entry; int ret = 0; - block->flags|=NOUVEAU_MEM_MAPPED; if (type == NOUVEAU_MEM_AGP) ret = nouveau_addmap_agp(dev, block); @@ -635,12 +647,10 @@ alloc_ok: return NULL; } - entry = drm_find_matching_map(dev, block->map); - if (!entry) { + if (!nouveau_map_block(dev, block)) { nouveau_mem_free_block(block); return NULL; } - block->map_handle = entry->user_token; } DRM_DEBUG("allocated %lld bytes at 0x%llx type=0x%08x\n", block->size, block->start, block->flags);
Maybe Matching Threads
- [PATCH 4/4] nouveau: clean up nouveau_mem_alloc function
- [PATCH 3/4] nouveau: move nouveau_map_block() call to nouveau_addmap()
- [PATCH 1/4] nouveau: add nouveau_addmap_{agp, fb, pci} functions
- [PATCH 1/6] drm/nouveau: bo read/write wrappers for nv04_crtc.c
- drm bo accessors etc. v2