aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/drm_bufs.c
diff options
context:
space:
mode:
authorDaniel Vetter <daniel.vetter@ffwll.ch>2016-04-26 13:29:36 -0400
committerDaniel Vetter <daniel.vetter@ffwll.ch>2016-04-27 02:42:48 -0400
commitec1f52efc0406a72870a1fcb859f18dea24bcd8b (patch)
tree39971b03d5e9b84704a9f90320d271095312a580 /drivers/gpu/drm/drm_bufs.c
parent68dfbebab131146b460550cebf8c38667c490a04 (diff)
drm: Move drm_getmap into drm_bufs.c and give it a legacy prefix
It belongs right next to the addmap and rmmap functions really. And for OCD consistency name it drm_legacy_getmap_ioctl. Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com> Link: http://patchwork.freedesktop.org/patch/msgid/1461691808-12414-4-git-send-email-daniel.vetter@ffwll.ch
Diffstat (limited to 'drivers/gpu/drm/drm_bufs.c')
-rw-r--r--drivers/gpu/drm/drm_bufs.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
index f1a204d253cc..d92db7007f62 100644
--- a/drivers/gpu/drm/drm_bufs.c
+++ b/drivers/gpu/drm/drm_bufs.c
@@ -416,6 +416,58 @@ int drm_legacy_addmap_ioctl(struct drm_device *dev, void *data,
416 return 0; 416 return 0;
417} 417}
418 418
419/*
420 * Get a mapping information.
421 *
422 * \param inode device inode.
423 * \param file_priv DRM file private.
424 * \param cmd command.
425 * \param arg user argument, pointing to a drm_map structure.
426 *
427 * \return zero on success or a negative number on failure.
428 *
429 * Searches for the mapping with the specified offset and copies its information
430 * into userspace
431 */
432int drm_legacy_getmap_ioctl(struct drm_device *dev, void *data,
433 struct drm_file *file_priv)
434{
435 struct drm_map *map = data;
436 struct drm_map_list *r_list = NULL;
437 struct list_head *list;
438 int idx;
439 int i;
440
441 idx = map->offset;
442 if (idx < 0)
443 return -EINVAL;
444
445 i = 0;
446 mutex_lock(&dev->struct_mutex);
447 list_for_each(list, &dev->maplist) {
448 if (i == idx) {
449 r_list = list_entry(list, struct drm_map_list, head);
450 break;
451 }
452 i++;
453 }
454 if (!r_list || !r_list->map) {
455 mutex_unlock(&dev->struct_mutex);
456 return -EINVAL;
457 }
458
459 map->offset = r_list->map->offset;
460 map->size = r_list->map->size;
461 map->type = r_list->map->type;
462 map->flags = r_list->map->flags;
463 map->handle = (void *)(unsigned long) r_list->user_token;
464 map->mtrr = arch_phys_wc_index(r_list->map->mtrr);
465
466 mutex_unlock(&dev->struct_mutex);
467
468 return 0;
469}
470
419/** 471/**
420 * Remove a map private from list and deallocate resources if the mapping 472 * Remove a map private from list and deallocate resources if the mapping
421 * isn't in use. 473 * isn't in use.