aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/drm/radeon_mem.c
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2007-09-02 22:06:45 -0400
committerDave Airlie <airlied@optimus.(none)>2007-10-14 20:38:20 -0400
commitc153f45f9b7e30289157bba3ff5682291df16caa (patch)
tree33f21e1ebd83ec548751f3d490afe6230ab99972 /drivers/char/drm/radeon_mem.c
parentb589ee5943a9610ebaea6e4e3433f2ae4d812b0b (diff)
drm: Replace DRM_IOCTL_ARGS with (dev, data, file_priv) and remove DRM_DEVICE.
The data is now in kernel space, copied in/out as appropriate according to t This results in DRM_COPY_{TO,FROM}_USER going away, and error paths to deal with those failures. This also means that XFree86 4.2.0 support for i810 DR is lost. Signed-off-by: Dave Airlie <airlied@linux.ie>
Diffstat (limited to 'drivers/char/drm/radeon_mem.c')
-rw-r--r--drivers/char/drm/radeon_mem.c44
1 files changed, 16 insertions, 28 deletions
diff --git a/drivers/char/drm/radeon_mem.c b/drivers/char/drm/radeon_mem.c
index 966d521cf27c..a29acfe2f973 100644
--- a/drivers/char/drm/radeon_mem.c
+++ b/drivers/char/drm/radeon_mem.c
@@ -217,11 +217,10 @@ static struct mem_block **get_heap(drm_radeon_private_t * dev_priv, int region)
217 } 217 }
218} 218}
219 219
220int radeon_mem_alloc(DRM_IOCTL_ARGS) 220int radeon_mem_alloc(struct drm_device *dev, void *data, struct drm_file *file_priv)
221{ 221{
222 DRM_DEVICE;
223 drm_radeon_private_t *dev_priv = dev->dev_private; 222 drm_radeon_private_t *dev_priv = dev->dev_private;
224 drm_radeon_mem_alloc_t alloc; 223 drm_radeon_mem_alloc_t *alloc = data;
225 struct mem_block *block, **heap; 224 struct mem_block *block, **heap;
226 225
227 if (!dev_priv) { 226 if (!dev_priv) {
@@ -229,25 +228,23 @@ int radeon_mem_alloc(DRM_IOCTL_ARGS)
229 return -EINVAL; 228 return -EINVAL;
230 } 229 }
231 230
232 DRM_COPY_FROM_USER_IOCTL(alloc, (drm_radeon_mem_alloc_t __user *) data, 231 heap = get_heap(dev_priv, alloc->region);
233 sizeof(alloc));
234
235 heap = get_heap(dev_priv, alloc.region);
236 if (!heap || !*heap) 232 if (!heap || !*heap)
237 return -EFAULT; 233 return -EFAULT;
238 234
239 /* Make things easier on ourselves: all allocations at least 235 /* Make things easier on ourselves: all allocations at least
240 * 4k aligned. 236 * 4k aligned.
241 */ 237 */
242 if (alloc.alignment < 12) 238 if (alloc->alignment < 12)
243 alloc.alignment = 12; 239 alloc->alignment = 12;
244 240
245 block = alloc_block(*heap, alloc.size, alloc.alignment, file_priv); 241 block = alloc_block(*heap, alloc->size, alloc->alignment, file_priv);
246 242
247 if (!block) 243 if (!block)
248 return -ENOMEM; 244 return -ENOMEM;
249 245
250 if (DRM_COPY_TO_USER(alloc.region_offset, &block->start, sizeof(int))) { 246 if (DRM_COPY_TO_USER(alloc->region_offset, &block->start,
247 sizeof(int))) {
251 DRM_ERROR("copy_to_user\n"); 248 DRM_ERROR("copy_to_user\n");
252 return -EFAULT; 249 return -EFAULT;
253 } 250 }
@@ -255,11 +252,10 @@ int radeon_mem_alloc(DRM_IOCTL_ARGS)
255 return 0; 252 return 0;
256} 253}
257 254
258int radeon_mem_free(DRM_IOCTL_ARGS) 255int radeon_mem_free(struct drm_device *dev, void *data, struct drm_file *file_priv)
259{ 256{
260 DRM_DEVICE;
261 drm_radeon_private_t *dev_priv = dev->dev_private; 257 drm_radeon_private_t *dev_priv = dev->dev_private;
262 drm_radeon_mem_free_t memfree; 258 drm_radeon_mem_free_t *memfree = data;
263 struct mem_block *block, **heap; 259 struct mem_block *block, **heap;
264 260
265 if (!dev_priv) { 261 if (!dev_priv) {
@@ -267,14 +263,11 @@ int radeon_mem_free(DRM_IOCTL_ARGS)
267 return -EINVAL; 263 return -EINVAL;
268 } 264 }
269 265
270 DRM_COPY_FROM_USER_IOCTL(memfree, (drm_radeon_mem_free_t __user *) data, 266 heap = get_heap(dev_priv, memfree->region);
271 sizeof(memfree));
272
273 heap = get_heap(dev_priv, memfree.region);
274 if (!heap || !*heap) 267 if (!heap || !*heap)
275 return -EFAULT; 268 return -EFAULT;
276 269
277 block = find_block(*heap, memfree.region_offset); 270 block = find_block(*heap, memfree->region_offset);
278 if (!block) 271 if (!block)
279 return -EFAULT; 272 return -EFAULT;
280 273
@@ -285,11 +278,10 @@ int radeon_mem_free(DRM_IOCTL_ARGS)
285 return 0; 278 return 0;
286} 279}
287 280
288int radeon_mem_init_heap(DRM_IOCTL_ARGS) 281int radeon_mem_init_heap(struct drm_device *dev, void *data, struct drm_file *file_priv)
289{ 282{
290 DRM_DEVICE;
291 drm_radeon_private_t *dev_priv = dev->dev_private; 283 drm_radeon_private_t *dev_priv = dev->dev_private;
292 drm_radeon_mem_init_heap_t initheap; 284 drm_radeon_mem_init_heap_t *initheap = data;
293 struct mem_block **heap; 285 struct mem_block **heap;
294 286
295 if (!dev_priv) { 287 if (!dev_priv) {
@@ -297,11 +289,7 @@ int radeon_mem_init_heap(DRM_IOCTL_ARGS)
297 return -EINVAL; 289 return -EINVAL;
298 } 290 }
299 291
300 DRM_COPY_FROM_USER_IOCTL(initheap, 292 heap = get_heap(dev_priv, initheap->region);
301 (drm_radeon_mem_init_heap_t __user *) data,
302 sizeof(initheap));
303
304 heap = get_heap(dev_priv, initheap.region);
305 if (!heap) 293 if (!heap)
306 return -EFAULT; 294 return -EFAULT;
307 295
@@ -310,5 +298,5 @@ int radeon_mem_init_heap(DRM_IOCTL_ARGS)
310 return -EFAULT; 298 return -EFAULT;
311 } 299 }
312 300
313 return init_heap(heap, initheap.start, initheap.size); 301 return init_heap(heap, initheap->start, initheap->size);
314} 302}