Commit 53760655 authored by Marek Szyprowski's avatar Marek Szyprowski

drm: omapdrm: use common helper for extracting pages array

Use common helper for converting a sg_table object into struct
page pointer array.
Signed-off-by: default avatarMarek Szyprowski <m.szyprowski@samsung.com>
Reviewed-by: default avatarRobin Murphy <robin.murphy@arm.com>
parent 7690a33f
...@@ -1297,10 +1297,9 @@ struct drm_gem_object *omap_gem_new_dmabuf(struct drm_device *dev, size_t size, ...@@ -1297,10 +1297,9 @@ struct drm_gem_object *omap_gem_new_dmabuf(struct drm_device *dev, size_t size,
omap_obj->dma_addr = sg_dma_address(sgt->sgl); omap_obj->dma_addr = sg_dma_address(sgt->sgl);
} else { } else {
/* Create pages list from sgt */ /* Create pages list from sgt */
struct sg_page_iter iter;
struct page **pages; struct page **pages;
unsigned int npages; unsigned int npages;
unsigned int i = 0; unsigned int ret;
npages = DIV_ROUND_UP(size, PAGE_SIZE); npages = DIV_ROUND_UP(size, PAGE_SIZE);
pages = kcalloc(npages, sizeof(*pages), GFP_KERNEL); pages = kcalloc(npages, sizeof(*pages), GFP_KERNEL);
...@@ -1311,14 +1310,9 @@ struct drm_gem_object *omap_gem_new_dmabuf(struct drm_device *dev, size_t size, ...@@ -1311,14 +1310,9 @@ struct drm_gem_object *omap_gem_new_dmabuf(struct drm_device *dev, size_t size,
} }
omap_obj->pages = pages; omap_obj->pages = pages;
ret = drm_prime_sg_to_page_addr_arrays(sgt, pages, NULL,
for_each_sg_page(sgt->sgl, &iter, sgt->orig_nents, 0) { npages);
pages[i++] = sg_page_iter_page(&iter); if (ret) {
if (i > npages)
break;
}
if (WARN_ON(i != npages)) {
omap_gem_free_object(obj); omap_gem_free_object(obj);
obj = ERR_PTR(-ENOMEM); obj = ERR_PTR(-ENOMEM);
goto done; goto done;
......
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