aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVille Syrjälä <ville.syrjala@linux.intel.com>2015-03-27 09:51:58 -0400
committerDaniel Vetter <daniel.vetter@ffwll.ch>2015-03-27 11:08:41 -0400
commit83be003807415a07465fc5d748803b702409f3da (patch)
tree309079b59e50b28dc89dcc5e32cb974c6b1d4f13
parent7e7392a6e854a29016377b87bebe5ae263f65e5c (diff)
drm: Simplify core vs. drv ioctl handling
Now that cmd_drv is gone the handling for core and driver ioctls is mostly identical, so eliminate the duplication. Also take the opportunity to simplify the range checks to be less cluttered. Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
-rw-r--r--drivers/gpu/drm/drm_ioctl.c39
1 files changed, 15 insertions, 24 deletions
diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
index fc0cf4a84011..68ba014886c2 100644
--- a/drivers/gpu/drm/drm_ioctl.c
+++ b/drivers/gpu/drm/drm_ioctl.c
@@ -663,39 +663,30 @@ long drm_ioctl(struct file *filp,
663 int retcode = -EINVAL; 663 int retcode = -EINVAL;
664 char stack_kdata[128]; 664 char stack_kdata[128];
665 char *kdata = NULL; 665 char *kdata = NULL;
666 unsigned int usize, asize; 666 unsigned int usize, asize, drv_size;
667 667
668 dev = file_priv->minor->dev; 668 dev = file_priv->minor->dev;
669 669
670 if (drm_device_is_unplugged(dev)) 670 if (drm_device_is_unplugged(dev))
671 return -ENODEV; 671 return -ENODEV;
672 672
673 if ((nr >= DRM_CORE_IOCTL_COUNT) && 673 if (nr >= DRM_COMMAND_BASE && nr < DRM_COMMAND_END) {
674 ((nr < DRM_COMMAND_BASE) || (nr >= DRM_COMMAND_END))) 674 /* driver ioctl */
675 goto err_i1; 675 if (nr - DRM_COMMAND_BASE >= dev->driver->num_ioctls)
676 if ((nr >= DRM_COMMAND_BASE) && (nr < DRM_COMMAND_END) && 676 goto err_i1;
677 (nr < DRM_COMMAND_BASE + dev->driver->num_ioctls)) {
678 u32 drv_size;
679 ioctl = &dev->driver->ioctls[nr - DRM_COMMAND_BASE]; 677 ioctl = &dev->driver->ioctls[nr - DRM_COMMAND_BASE];
680 drv_size = _IOC_SIZE(ioctl->cmd); 678 } else {
681 usize = asize = _IOC_SIZE(cmd); 679 /* core ioctl */
682 if (drv_size > asize) 680 if (nr >= DRM_CORE_IOCTL_COUNT)
683 asize = drv_size; 681 goto err_i1;
684 cmd = ioctl->cmd;
685 }
686 else if ((nr >= DRM_COMMAND_END) || (nr < DRM_COMMAND_BASE)) {
687 u32 drv_size;
688
689 ioctl = &drm_ioctls[nr]; 682 ioctl = &drm_ioctls[nr];
683 }
690 684
691 drv_size = _IOC_SIZE(ioctl->cmd); 685 drv_size = _IOC_SIZE(ioctl->cmd);
692 usize = asize = _IOC_SIZE(cmd); 686 usize = asize = _IOC_SIZE(cmd);
693 if (drv_size > asize) 687 if (drv_size > asize)
694 asize = drv_size; 688 asize = drv_size;
695 689 cmd = ioctl->cmd;
696 cmd = ioctl->cmd;
697 } else
698 goto err_i1;
699 690
700 DRM_DEBUG("pid=%d, dev=0x%lx, auth=%d, %s\n", 691 DRM_DEBUG("pid=%d, dev=0x%lx, auth=%d, %s\n",
701 task_pid_nr(current), 692 task_pid_nr(current),