treewide: remove redundant IS_ERR() before error code check
[linux/fpc-iii.git] / drivers / gpu / drm / msm / msm_gem_prime.c
blobd7c8948427fe005e7f315e0cc8aafe1e14068445
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * Copyright (C) 2013 Red Hat
4 * Author: Rob Clark <robdclark@gmail.com>
5 */
7 #include <linux/dma-buf.h>
9 #include <drm/drm_prime.h>
11 #include "msm_drv.h"
12 #include "msm_gem.h"
14 struct sg_table *msm_gem_prime_get_sg_table(struct drm_gem_object *obj)
16 struct msm_gem_object *msm_obj = to_msm_bo(obj);
17 int npages = obj->size >> PAGE_SHIFT;
19 if (WARN_ON(!msm_obj->pages)) /* should have already pinned! */
20 return NULL;
22 return drm_prime_pages_to_sg(msm_obj->pages, npages);
25 void *msm_gem_prime_vmap(struct drm_gem_object *obj)
27 return msm_gem_get_vaddr(obj);
30 void msm_gem_prime_vunmap(struct drm_gem_object *obj, void *vaddr)
32 msm_gem_put_vaddr(obj);
35 int msm_gem_prime_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma)
37 int ret;
39 ret = drm_gem_mmap_obj(obj, obj->size, vma);
40 if (ret < 0)
41 return ret;
43 return msm_gem_mmap_obj(vma->vm_private_data, vma);
46 struct drm_gem_object *msm_gem_prime_import_sg_table(struct drm_device *dev,
47 struct dma_buf_attachment *attach, struct sg_table *sg)
49 return msm_gem_import(dev, attach->dmabuf, sg);
52 int msm_gem_prime_pin(struct drm_gem_object *obj)
54 if (!obj->import_attach)
55 msm_gem_get_pages(obj);
56 return 0;
59 void msm_gem_prime_unpin(struct drm_gem_object *obj)
61 if (!obj->import_attach)
62 msm_gem_put_pages(obj);