diff options
author | Daniel Vetter <daniel.vetter@ffwll.ch> | 2016-04-26 13:29:36 -0400 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2016-04-27 02:42:48 -0400 |
commit | ec1f52efc0406a72870a1fcb859f18dea24bcd8b (patch) | |
tree | 39971b03d5e9b84704a9f90320d271095312a580 | |
parent | 68dfbebab131146b460550cebf8c38667c490a04 (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
-rw-r--r-- | drivers/gpu/drm/drm_bufs.c | 52 | ||||
-rw-r--r-- | drivers/gpu/drm/drm_ioctl.c | 54 | ||||
-rw-r--r-- | drivers/gpu/drm/drm_legacy.h | 2 |
3 files changed, 55 insertions, 53 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 | */ | ||
432 | int 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. |
diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c index 8ce2a0c59116..b7a39771c152 100644 --- a/drivers/gpu/drm/drm_ioctl.c +++ b/drivers/gpu/drm/drm_ioctl.c | |||
@@ -150,58 +150,6 @@ static int drm_set_busid(struct drm_device *dev, struct drm_file *file_priv) | |||
150 | } | 150 | } |
151 | 151 | ||
152 | /* | 152 | /* |
153 | * Get a mapping information. | ||
154 | * | ||
155 | * \param inode device inode. | ||
156 | * \param file_priv DRM file private. | ||
157 | * \param cmd command. | ||
158 | * \param arg user argument, pointing to a drm_map structure. | ||
159 | * | ||
160 | * \return zero on success or a negative number on failure. | ||
161 | * | ||
162 | * Searches for the mapping with the specified offset and copies its information | ||
163 | * into userspace | ||
164 | */ | ||
165 | static int drm_getmap(struct drm_device *dev, void *data, | ||
166 | struct drm_file *file_priv) | ||
167 | { | ||
168 | struct drm_map *map = data; | ||
169 | struct drm_map_list *r_list = NULL; | ||
170 | struct list_head *list; | ||
171 | int idx; | ||
172 | int i; | ||
173 | |||
174 | idx = map->offset; | ||
175 | if (idx < 0) | ||
176 | return -EINVAL; | ||
177 | |||
178 | i = 0; | ||
179 | mutex_lock(&dev->struct_mutex); | ||
180 | list_for_each(list, &dev->maplist) { | ||
181 | if (i == idx) { | ||
182 | r_list = list_entry(list, struct drm_map_list, head); | ||
183 | break; | ||
184 | } | ||
185 | i++; | ||
186 | } | ||
187 | if (!r_list || !r_list->map) { | ||
188 | mutex_unlock(&dev->struct_mutex); | ||
189 | return -EINVAL; | ||
190 | } | ||
191 | |||
192 | map->offset = r_list->map->offset; | ||
193 | map->size = r_list->map->size; | ||
194 | map->type = r_list->map->type; | ||
195 | map->flags = r_list->map->flags; | ||
196 | map->handle = (void *)(unsigned long) r_list->user_token; | ||
197 | map->mtrr = arch_phys_wc_index(r_list->map->mtrr); | ||
198 | |||
199 | mutex_unlock(&dev->struct_mutex); | ||
200 | |||
201 | return 0; | ||
202 | } | ||
203 | |||
204 | /* | ||
205 | * Get client information. | 153 | * Get client information. |
206 | * | 154 | * |
207 | * \param inode device inode. | 155 | * \param inode device inode. |
@@ -558,7 +506,7 @@ static const struct drm_ioctl_desc drm_ioctls[] = { | |||
558 | DRM_IOCTL_DEF(DRM_IOCTL_GET_UNIQUE, drm_getunique, 0), | 506 | DRM_IOCTL_DEF(DRM_IOCTL_GET_UNIQUE, drm_getunique, 0), |
559 | DRM_IOCTL_DEF(DRM_IOCTL_GET_MAGIC, drm_getmagic, 0), | 507 | DRM_IOCTL_DEF(DRM_IOCTL_GET_MAGIC, drm_getmagic, 0), |
560 | DRM_IOCTL_DEF(DRM_IOCTL_IRQ_BUSID, drm_irq_by_busid, DRM_MASTER|DRM_ROOT_ONLY), | 508 | DRM_IOCTL_DEF(DRM_IOCTL_IRQ_BUSID, drm_irq_by_busid, DRM_MASTER|DRM_ROOT_ONLY), |
561 | DRM_IOCTL_DEF(DRM_IOCTL_GET_MAP, drm_getmap, DRM_UNLOCKED), | 509 | DRM_IOCTL_DEF(DRM_IOCTL_GET_MAP, drm_legacy_getmap_ioctl, DRM_UNLOCKED), |
562 | DRM_IOCTL_DEF(DRM_IOCTL_GET_CLIENT, drm_getclient, DRM_UNLOCKED), | 510 | DRM_IOCTL_DEF(DRM_IOCTL_GET_CLIENT, drm_getclient, DRM_UNLOCKED), |
563 | DRM_IOCTL_DEF(DRM_IOCTL_GET_STATS, drm_getstats, DRM_UNLOCKED), | 511 | DRM_IOCTL_DEF(DRM_IOCTL_GET_STATS, drm_getstats, DRM_UNLOCKED), |
564 | DRM_IOCTL_DEF(DRM_IOCTL_GET_CAP, drm_getcap, DRM_UNLOCKED|DRM_RENDER_ALLOW), | 512 | DRM_IOCTL_DEF(DRM_IOCTL_GET_CAP, drm_getcap, DRM_UNLOCKED|DRM_RENDER_ALLOW), |
diff --git a/drivers/gpu/drm/drm_legacy.h b/drivers/gpu/drm/drm_legacy.h index 9b731786e4db..d3b6ee357a2b 100644 --- a/drivers/gpu/drm/drm_legacy.h +++ b/drivers/gpu/drm/drm_legacy.h | |||
@@ -63,6 +63,8 @@ int drm_legacy_getsareactx(struct drm_device *d, void *v, struct drm_file *f); | |||
63 | 63 | ||
64 | #define DRM_MAP_HASH_OFFSET 0x10000000 | 64 | #define DRM_MAP_HASH_OFFSET 0x10000000 |
65 | 65 | ||
66 | int drm_legacy_getmap_ioctl(struct drm_device *dev, void *data, | ||
67 | struct drm_file *file_priv); | ||
66 | int drm_legacy_addmap_ioctl(struct drm_device *d, void *v, struct drm_file *f); | 68 | int drm_legacy_addmap_ioctl(struct drm_device *d, void *v, struct drm_file *f); |
67 | int drm_legacy_rmmap_ioctl(struct drm_device *d, void *v, struct drm_file *f); | 69 | int drm_legacy_rmmap_ioctl(struct drm_device *d, void *v, struct drm_file *f); |
68 | int drm_legacy_addbufs(struct drm_device *d, void *v, struct drm_file *f); | 70 | int drm_legacy_addbufs(struct drm_device *d, void *v, struct drm_file *f); |