drm/crtc: Remove duplicated ioctl code
Subsystems (2)
PATCH v2 1/1 drm/crtc: Remove duplicated ioctl code
Make drm_mode_add_fb() call drm_mode_add_fb2() after converting its args to the new internal format, instead of duplicating code.
Also picks up a lot more error checking, which the legacy modes should pass after being converted to the new format.
--- drm_crtc.c | 31 +++++++------------------------ 1 file changed, 7 insertions(+), 24 deletions(-)
Against 3.17.0, compile tested only.
This time with the correct signed-off-by.
drivers/gpu/drm/drm_crtc.c +7 -24
@@ -2925,11 +2925,9 @@ int drm_mode_addfb(struct drm_device *dev, {struct drm_mode_fb_cmd *or = data;struct drm_mode_fb_cmd2 r = {}; -struct drm_mode_config *config = &dev->mode_config; -struct drm_framebuffer *fb; -int ret =0 ; +int ret; -/* Use new struct with format internally */ +/* convert to new format and call new ioctl */ r.fb_id = or->fb_id; r.width = or->width; r.height = or->height;
@@ -2937,27 +2934,12 @@ int drm_mode_addfb(struct drm_device *dev, r.pixel_format =drm_mode_legacy_fb_format (or->bpp, or->depth); r.handles[0 ] = or->handle; -if (!drm_core_check_feature (dev,DRIVER_MODESET )) -return -EINVAL ; - -if ((config->min_width > r.width) || (r.width > config->max_width)) -return -EINVAL ; - -if ((config->min_height > r.height) || (r.height > config->max_height)) -return -EINVAL ; - - fb = dev->mode_config.funcs->fb_create (dev, file_priv, &r); -if (IS_ERR (fb)) { -DRM_DEBUG_KMS ("could not create framebuffer\n" ); -return PTR_ERR (fb); - } + ret =drm_mode_addfb2 (dev, &r, file_priv); +if (ret) +return ret; + + or->fb_id = r.fb_id; -mutex_lock (&file_priv->fbs_lock); - or->fb_id = fb->base.id; -list_add (&fb->filp_head, &file_priv->fbs); -DRM_DEBUG_KMS ("[FB:%d]\n" , fb->base.id); -mutex_unlock (&file_priv->fbs_lock); -return ret; }
Quoted 7 lines · Chuck Ebbert
Make
drm_mode_add_fb()calldrm_mode_add_fb2()after converting its args to the new internal format, instead of duplicating code.Also picks up a lot more error checking, which the legacy modes should pass after being converted to the new format.
Signed-off-by Chuck Ebbert <[email protected]>
Looks good to me.
Quoted 61 lines
--- drm_crtc.c | 31 +++++++------------------------ 1 file changed, 7 insertions(+), 24 deletions(-)Against 3.17.0, compile tested only.
This time with the correct signed-off-by.diff
a/drivers/gpu/drm/drm_crtc.cb/drivers/gpu/drm/drm_crtc.cdrivers/gpu/drm/drm_crtc.c +7
-24@@ -2925,11 +2925,9 @@ int drm_mode_addfb(struct drm_device *dev, {struct drm_mode_fb_cmd *or = data;struct drm_mode_fb_cmd2 r = {}; -struct drm_mode_config *config = &dev->mode_config; -struct drm_framebuffer *fb; -int ret =0 ; +int ret; -/* Use new struct with format internally */ +/* convert to new format and call new ioctl */ r.fb_id = or->fb_id; r.width = or->width; r.height = or->height;@@ -2937,27 +2934,12 @@ int drm_mode_addfb(struct drm_device *dev, r.pixel_format =drm_mode_legacy_fb_format (or->bpp, or->depth); r.handles[0 ] = or->handle; -if (!drm_core_check_feature (dev,DRIVER_MODESET )) -return -EINVAL ; - -if ((config->min_width > r.width) || (r.width > config->max_width)) -return -EINVAL ; - -if ((config->min_height > r.height) || (r.height > config->max_height)) -return -EINVAL ; - - fb = dev->mode_config.funcs->fb_create (dev, file_priv, &r); -if (IS_ERR (fb)) { -DRM_DEBUG_KMS ("could not create framebuffer\n" ); -return PTR_ERR (fb); - } + ret =drm_mode_addfb2 (dev, &r, file_priv); +if (ret) +return ret; + + or->fb_id = r.fb_id; -mutex_lock (&file_priv->fbs_lock); - or->fb_id = fb->base.id; -list_add (&fb->filp_head, &file_priv->fbs); -DRM_DEBUG_KMS ("[FB:%d]\n" , fb->base.id); -mutex_unlock (&file_priv->fbs_lock); -return ret; }_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 2 lines
Ville Syrjälä Intel OTC
Daniel Vetter
AppliedQuoted 4 lines · Ville Syrjälä
Quoted 3 lines · Chuck Ebbert
Make
drm_mode_add_fb()calldrm_mode_add_fb2()after converting its args to the new internal format, instead of duplicating code.
Quoted 8 lines
Quoted 4 lines
Also picks up a lot more error checking, which the legacy modes should pass after being converted to the new format.
Signed-off-by Chuck Ebbert <[email protected]>Looks good to me.
Reviewed-by Ville Syrjälä <[email protected]>
Picked up into my drm core stuff queue.
-Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch