Commit 83be0038 authored by Ville Syrjälä's avatar Ville Syrjälä Committed by Daniel Vetter

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: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent 7e7392a6
...@@ -663,39 +663,30 @@ long drm_ioctl(struct file *filp, ...@@ -663,39 +663,30 @@ long drm_ioctl(struct file *filp,
int retcode = -EINVAL; int retcode = -EINVAL;
char stack_kdata[128]; char stack_kdata[128];
char *kdata = NULL; char *kdata = NULL;
unsigned int usize, asize; unsigned int usize, asize, drv_size;
dev = file_priv->minor->dev; dev = file_priv->minor->dev;
if (drm_device_is_unplugged(dev)) if (drm_device_is_unplugged(dev))
return -ENODEV; return -ENODEV;
if ((nr >= DRM_CORE_IOCTL_COUNT) && if (nr >= DRM_COMMAND_BASE && nr < DRM_COMMAND_END) {
((nr < DRM_COMMAND_BASE) || (nr >= DRM_COMMAND_END))) /* driver ioctl */
if (nr - DRM_COMMAND_BASE >= dev->driver->num_ioctls)
goto err_i1; goto err_i1;
if ((nr >= DRM_COMMAND_BASE) && (nr < DRM_COMMAND_END) &&
(nr < DRM_COMMAND_BASE + dev->driver->num_ioctls)) {
u32 drv_size;
ioctl = &dev->driver->ioctls[nr - DRM_COMMAND_BASE]; ioctl = &dev->driver->ioctls[nr - DRM_COMMAND_BASE];
drv_size = _IOC_SIZE(ioctl->cmd); } else {
usize = asize = _IOC_SIZE(cmd); /* core ioctl */
if (drv_size > asize) if (nr >= DRM_CORE_IOCTL_COUNT)
asize = drv_size; goto err_i1;
cmd = ioctl->cmd;
}
else if ((nr >= DRM_COMMAND_END) || (nr < DRM_COMMAND_BASE)) {
u32 drv_size;
ioctl = &drm_ioctls[nr]; ioctl = &drm_ioctls[nr];
}
drv_size = _IOC_SIZE(ioctl->cmd); drv_size = _IOC_SIZE(ioctl->cmd);
usize = asize = _IOC_SIZE(cmd); usize = asize = _IOC_SIZE(cmd);
if (drv_size > asize) if (drv_size > asize)
asize = drv_size; asize = drv_size;
cmd = ioctl->cmd; cmd = ioctl->cmd;
} else
goto err_i1;
DRM_DEBUG("pid=%d, dev=0x%lx, auth=%d, %s\n", DRM_DEBUG("pid=%d, dev=0x%lx, auth=%d, %s\n",
task_pid_nr(current), task_pid_nr(current),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment