Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

+55 -53
+52
drivers/gpu/drm/drm_bufs.c
··· 416 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 472 * Remove a map private from list and deallocate resources if the mapping 421 473 * isn't in use.
+1 -53
drivers/gpu/drm/drm_ioctl.c
··· 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 153 * Get client information. 206 154 * 207 155 * \param inode device inode. ··· 506 558 DRM_IOCTL_DEF(DRM_IOCTL_GET_UNIQUE, drm_getunique, 0), 507 559 DRM_IOCTL_DEF(DRM_IOCTL_GET_MAGIC, drm_getmagic, 0), 508 560 DRM_IOCTL_DEF(DRM_IOCTL_IRQ_BUSID, drm_irq_by_busid, DRM_MASTER|DRM_ROOT_ONLY), 509 - DRM_IOCTL_DEF(DRM_IOCTL_GET_MAP, drm_getmap, DRM_UNLOCKED), 561 + DRM_IOCTL_DEF(DRM_IOCTL_GET_MAP, drm_legacy_getmap_ioctl, DRM_UNLOCKED), 510 562 DRM_IOCTL_DEF(DRM_IOCTL_GET_CLIENT, drm_getclient, DRM_UNLOCKED), 511 563 DRM_IOCTL_DEF(DRM_IOCTL_GET_STATS, drm_getstats, DRM_UNLOCKED), 512 564 DRM_IOCTL_DEF(DRM_IOCTL_GET_CAP, drm_getcap, DRM_UNLOCKED|DRM_RENDER_ALLOW),
+2
drivers/gpu/drm/drm_legacy.h
··· 63 63 64 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 68 int drm_legacy_addmap_ioctl(struct drm_device *d, void *v, struct drm_file *f); 67 69 int drm_legacy_rmmap_ioctl(struct drm_device *d, void *v, struct drm_file *f); 68 70 int drm_legacy_addbufs(struct drm_device *d, void *v, struct drm_file *f);