aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/udl
diff options
context:
space:
mode:
authorRob Clark <robdclark@gmail.com>2013-08-07 13:41:26 -0400
committerDave Airlie <airlied@redhat.com>2013-08-18 20:36:12 -0400
commit5dc9e1e87229cb786a5bb58ddd0d60fee6eb4641 (patch)
treeebd037f17f185e0309a03fa09febf9f689f559bf /drivers/gpu/drm/udl
parent8b9ba7a38c4916e67f43223a7973374e7c44e5cb (diff)
drm/udl: use gem get/put page helpers
Signed-off-by: Rob Clark <robdclark@gmail.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/udl')
-rw-r--r--drivers/gpu/drm/udl/udl_gem.c44
1 files changed, 6 insertions, 38 deletions
diff --git a/drivers/gpu/drm/udl/udl_gem.c b/drivers/gpu/drm/udl/udl_gem.c
index b5e3b8038253..8dbe9d0ae9a7 100644
--- a/drivers/gpu/drm/udl/udl_gem.c
+++ b/drivers/gpu/drm/udl/udl_gem.c
@@ -117,55 +117,23 @@ int udl_gem_init_object(struct drm_gem_object *obj)
117 117
118static int udl_gem_get_pages(struct udl_gem_object *obj, gfp_t gfpmask) 118static int udl_gem_get_pages(struct udl_gem_object *obj, gfp_t gfpmask)
119{ 119{
120 int page_count, i; 120 struct page **pages;
121 struct page *page;
122 struct inode *inode;
123 struct address_space *mapping;
124 121
125 if (obj->pages) 122 if (obj->pages)
126 return 0; 123 return 0;
127 124
128 page_count = obj->base.size / PAGE_SIZE; 125 pages = drm_gem_get_pages(&obj->base, gfpmask);
129 BUG_ON(obj->pages != NULL); 126 if (IS_ERR(pages))
130 obj->pages = drm_malloc_ab(page_count, sizeof(struct page *)); 127 return PTR_ERR(pages);
131 if (obj->pages == NULL)
132 return -ENOMEM;
133
134 inode = file_inode(obj->base.filp);
135 mapping = inode->i_mapping;
136 gfpmask |= mapping_gfp_mask(mapping);
137 128
138 for (i = 0; i < page_count; i++) { 129 obj->pages = pages;
139 page = shmem_read_mapping_page_gfp(mapping, i, gfpmask);
140 if (IS_ERR(page))
141 goto err_pages;
142 obj->pages[i] = page;
143 }
144 130
145 return 0; 131 return 0;
146err_pages:
147 while (i--)
148 page_cache_release(obj->pages[i]);
149 drm_free_large(obj->pages);
150 obj->pages = NULL;
151 return PTR_ERR(page);
152} 132}
153 133
154static void udl_gem_put_pages(struct udl_gem_object *obj) 134static void udl_gem_put_pages(struct udl_gem_object *obj)
155{ 135{
156 int page_count = obj->base.size / PAGE_SIZE; 136 drm_gem_put_pages(&obj->base, obj->pages, false, false);
157 int i;
158
159 if (obj->base.import_attach) {
160 drm_free_large(obj->pages);
161 obj->pages = NULL;
162 return;
163 }
164
165 for (i = 0; i < page_count; i++)
166 page_cache_release(obj->pages[i]);
167
168 drm_free_large(obj->pages);
169 obj->pages = NULL; 137 obj->pages = NULL;
170} 138}
171 139