Commit 3f257bc6 authored by Thierry Reding's avatar Thierry Reding

drm/tegra: gem: Do not return NULL in tegra_bo_mmap()

It's confusing for a function to return NULL and ERR_PTR()-encoded error
codes on failure. Make sure we only ever return the latter since that's
what callers already expect.
Reported-by: default avatarSui Jingfeng <suijingfeng@loongson.cn>
Reviewed-by: default avatarSui Jingfeng <suijingfeng@loongson.cn>
Signed-off-by: default avatarThierry Reding <treding@nvidia.com>
Link: https://patchwork.freedesktop.org/patch/msgid/ZSVuVcqdGfGtQIQj@orome.fritz.box
parent 3868ff00
...@@ -178,6 +178,7 @@ static void *tegra_bo_mmap(struct host1x_bo *bo) ...@@ -178,6 +178,7 @@ static void *tegra_bo_mmap(struct host1x_bo *bo)
{ {
struct tegra_bo *obj = host1x_to_tegra_bo(bo); struct tegra_bo *obj = host1x_to_tegra_bo(bo);
struct iosys_map map = { 0 }; struct iosys_map map = { 0 };
void *vaddr;
int ret; int ret;
if (obj->vaddr) if (obj->vaddr)
...@@ -185,10 +186,18 @@ static void *tegra_bo_mmap(struct host1x_bo *bo) ...@@ -185,10 +186,18 @@ static void *tegra_bo_mmap(struct host1x_bo *bo)
if (obj->gem.import_attach) { if (obj->gem.import_attach) {
ret = dma_buf_vmap_unlocked(obj->gem.import_attach->dmabuf, &map); ret = dma_buf_vmap_unlocked(obj->gem.import_attach->dmabuf, &map);
return ret ? NULL : map.vaddr; if (ret < 0)
return ERR_PTR(ret);
return map.vaddr;
} }
return vmap(obj->pages, obj->num_pages, VM_MAP, pgprot_writecombine(PAGE_KERNEL)); vaddr = vmap(obj->pages, obj->num_pages, VM_MAP,
pgprot_writecombine(PAGE_KERNEL));
if (!vaddr)
return ERR_PTR(-ENOMEM);
return vaddr;
} }
static void tegra_bo_munmap(struct host1x_bo *bo, void *addr) static void tegra_bo_munmap(struct host1x_bo *bo, void *addr)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment