diff options
author | Daniel Stone <daniels@collabora.com> | 2015-05-22 14:34:47 +0200 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2015-05-22 16:18:20 +0200 |
commit | 7dec9a9648f825a0698fd875d2834b597f122bd6 (patch) | |
tree | 9f56fa54854f179a9c73f3eadb7e6b32838dd665 /drivers/gpu/drm/drm_crtc.c | |
parent | drm/crtc_helper: Replace open-coded CRTC state helpers (diff) | |
download | linux-7dec9a9648f825a0698fd875d2834b597f122bd6.tar.xz linux-7dec9a9648f825a0698fd875d2834b597f122bd6.zip |
drm/mode: Validate modes inside drm_crtc_convert_umode
The only user of convert_umode was also performing mode validation, so
do that in the same place.
Signed-off-by: Daniel Stone <daniels@collabora.com>
Tested-by: Sean Paul <seanpaul@chromium.org>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'drivers/gpu/drm/drm_crtc.c')
-rw-r--r-- | drivers/gpu/drm/drm_crtc.c | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index 7e5085fe4b75..baad4e856006 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c @@ -1785,11 +1785,15 @@ static void drm_crtc_convert_to_umode(struct drm_mode_modeinfo *out, static int drm_crtc_convert_umode(struct drm_display_mode *out, const struct drm_mode_modeinfo *in) { - if (in->clock > INT_MAX || in->vrefresh > INT_MAX) - return -ERANGE; + int ret = -EINVAL; + + if (in->clock > INT_MAX || in->vrefresh > INT_MAX) { + ret = -ERANGE; + goto out; + } if ((in->flags & DRM_MODE_FLAG_3D_MASK) > DRM_MODE_FLAG_3D_MAX) - return -EINVAL; + goto out; out->clock = in->clock; out->hdisplay = in->hdisplay; @@ -1808,7 +1812,14 @@ static int drm_crtc_convert_umode(struct drm_display_mode *out, strncpy(out->name, in->name, DRM_DISPLAY_MODE_LEN); out->name[DRM_DISPLAY_MODE_LEN-1] = 0; - return 0; + out->status = drm_mode_validate_basic(out); + if (out->status != MODE_OK) + goto out; + + ret = 0; + +out: + return ret; } /** @@ -2821,12 +2832,6 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data, goto out; } - mode->status = drm_mode_validate_basic(mode); - if (mode->status != MODE_OK) { - ret = -EINVAL; - goto out; - } - drm_mode_set_crtcinfo(mode, CRTC_INTERLACE_HALVE_V); /* |