drm: Simplify return value handling in drm_crtc.c
Subsystems (2)
PATCH 1/1 drm: Simplify return value handling in drm_crtc.c
While looking through drm_crtc.c to double-check make locking changes I've noticed that there's a few other places that would now benefit from simplified return value handling.
So let's flatten the control flow and replace and always 0 ret with 0 where possible.
--- drivers/gpu/drm/drm_crtc.c | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-)
drivers/gpu/drm/drm_crtc.c +9 -17
@@ -683,7 +683,7 @@ int drm_crtc_init_with_planes(struct drm_device *dev, struct drm_crtc *crtc,drm_modeset_lock_init (&crtc->mutex); ret =drm_mode_object_get (dev, &crtc->base,DRM_MODE_OBJECT_CRTC );if (ret) - goto out; +return ret; crtc->base.properties = &crtc->properties;
@@ -697,9 +697,7 @@ int drm_crtc_init_with_planes(struct drm_device *dev, struct drm_crtc *crtc,if (cursor) cursor->possible_crtcs =1 <<drm_crtc_index (crtc); - out: - -return ret; +return 0 ; }EXPORT_SYMBOL (drm_crtc_init_with_planes);
@@ -1154,7 +1152,7 @@ int drm_universal_plane_init(struct drm_device *dev, struct drm_plane *plane, ret =drm_mode_object_get (dev, &plane->base,DRM_MODE_OBJECT_PLANE );if (ret) - goto out; +return ret;drm_modeset_lock_init (&plane->mutex);
@@ -1166,8 +1164,7 @@ int drm_universal_plane_init(struct drm_device *dev, struct drm_plane *plane,if (!plane->format_types) {DRM_DEBUG_KMS ("out of memory when allocating plane\n" );drm_mode_object_put (dev, &plane->base); - ret = -ENOMEM ; - goto out; +return -ENOMEM ; }memcpy (plane->format_types, formats, format_count *sizeof (uint32_t ));
@@ -1184,9 +1181,7 @@ int drm_universal_plane_init(struct drm_device *dev, struct drm_plane *plane, dev->mode_config.plane_type_property, plane->type); - out: - -return ret; +return 0 ; }EXPORT_SYMBOL (drm_universal_plane_init);
@@ -1887,7 +1882,6 @@ int drm_mode_getcrtc(struct drm_device *dev, {struct drm_mode_crtc *crtc_resp = data;struct drm_crtc *crtc; -int ret =0 ;if (!drm_core_check_feature (dev,DRIVER_MODESET ))return -EINVAL ;
@@ -1915,7 +1909,7 @@ int drm_mode_getcrtc(struct drm_device *dev, }drm_modeset_unlock_crtc (crtc); -return ret; +return 0 ; } static bool drm_mode_expose_to_userspace(const struct drm_display_mode *mode,
@@ -2093,7 +2087,6 @@ int drm_mode_getencoder(struct drm_device *dev, void *data, {struct drm_mode_get_encoder *enc_resp = data;struct drm_encoder *encoder; -int ret =0 ;if (!drm_core_check_feature (dev,DRIVER_MODESET ))return -EINVAL ;
@@ -2114,7 +2107,7 @@ int drm_mode_getencoder(struct drm_device *dev, void *data, enc_resp->possible_crtcs = encoder->possible_crtcs; enc_resp->possible_clones = encoder->possible_clones; -return ret; +return 0 ; }/**
@@ -2197,7 +2190,6 @@ int drm_mode_getplane(struct drm_device *dev, void *data,struct drm_mode_get_plane *plane_resp = data;struct drm_plane *plane;uint32_t __user *format_ptr; -int ret =0 ;if (!drm_core_check_feature (dev,DRIVER_MODESET ))return -EINVAL ;
@@ -2237,7 +2229,7 @@ int drm_mode_getplane(struct drm_device *dev, void *data, } plane_resp->count_format_types = plane->format_count; -return ret; +return 0 ; }/*
@@ -2957,7 +2949,7 @@ int drm_mode_addfb(struct drm_device *dev, or->fb_id = r.fb_id; -return ret; +return 0 ; }static int format_check (const struct drm_mode_fb_cmd2 *r)
Signature · 6 lines
2.1.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH] drm: Simplify return value handling in
-------------------------------------Summary-------------------------------------
Platform: baseline_drm_intel_nightly_pass_rate->patch_applied_pass_rate
BYT: pass/total=291/291->291/291
PNV: pass/total=356/356->356/356
ILK: pass/total=372/372->371/372
IVB: pass/total=545/546->545/546
SNB: pass/total=380/380->379/380
HSW: pass/total=579/579->579/579
BDW: pass/total=422/423->422/423
-------------------------------------Detailed-------------------------------------test_platform: test_suite, test_case, result_with_drm_intel_nightly(count, machine_id...)...->result_with_patch_applied(count, machine_id)...
ILK: Intel_gpu_tools, igt_kms_setmode_invalid-clone-single-crtc, TIMEOUT(6, M37M6)PASS(1, M26) -> TIMEOUT(1, M37)PASS(3, M37)
IVB: Intel_gpu_tools, igt_gem_bad_reloc_negative-reloc, NSPT(3, M21M34)PASS(4, M34M21) -> NSPT(1, M34)PASS(3, M34)
IVB: Intel_gpu_tools, igt_kms_setmode_invalid-clone-single-crtc, TIMEOUT(5, M34M21)PASS(1, M21) -> TIMEOUT(1, M34)PASS(3, M34)
SNB: Intel_gpu_tools, igt_kms_setmode_invalid-clone-single-crtc, TIMEOUT(4, M35M22)PASS(1, M35) -> TIMEOUT(1, M35)PASS(3, M35)
BDW: Intel_gpu_tools, igt_gem_reset_stats_ban-bsd, DMESG_WARN(1, M28)PASS(6, M42M30) -> PASS(4, M42)
BDW: Intel_gpu_tools, igt_kms_setmode_invalid-clone-single-crtc, TIMEOUT(6, M42M30)PASS(1, M28) -> TIMEOUT(1, M42)PASS(3, M42)
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 8 lines · Daniel Vetter
While looking through
drm_crtc.cto double-check make locking changes I've noticed that there's a few other places that would now benefit from simplified return value handling.So let's flatten the control flow and replace and always 0 ret with 0 where possible.
Signed-off-by Daniel Vetter <[email protected]>
Quoted 125 lines
--- drivers/gpu/drm/drm_crtc.c | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-)drivers/gpu/drm/drm_crtc.c +9
-17@@ -683,7 +683,7 @@ int drm_crtc_init_with_planes(struct drm_device *dev, struct drm_crtc *crtc,drm_modeset_lock_init (&crtc->mutex); ret =drm_mode_object_get (dev, &crtc->base,DRM_MODE_OBJECT_CRTC );if (ret) - goto out; +return ret; crtc->base.properties = &crtc->properties;@@ -697,9 +697,7 @@ int drm_crtc_init_with_planes(struct drm_device *dev, struct drm_crtc *crtc,if (cursor) cursor->possible_crtcs =1 <<drm_crtc_index (crtc); - out: - -return ret; +return 0 ; }EXPORT_SYMBOL (drm_crtc_init_with_planes);@@ -1154,7 +1152,7 @@ int drm_universal_plane_init(struct drm_device *dev, struct drm_plane *plane, ret =drm_mode_object_get (dev, &plane->base,DRM_MODE_OBJECT_PLANE );if (ret) - goto out; +return ret;drm_modeset_lock_init (&plane->mutex);@@ -1166,8 +1164,7 @@ int drm_universal_plane_init(struct drm_device *dev, struct drm_plane *plane,if (!plane->format_types) {DRM_DEBUG_KMS ("out of memory when allocating plane\n" );drm_mode_object_put (dev, &plane->base); - ret = -ENOMEM ; - goto out; +return -ENOMEM ; }memcpy (plane->format_types, formats, format_count *sizeof (uint32_t ));@@ -1184,9 +1181,7 @@ int drm_universal_plane_init(struct drm_device *dev, struct drm_plane *plane, dev->mode_config.plane_type_property, plane->type); - out: - -return ret; +return 0 ; }EXPORT_SYMBOL (drm_universal_plane_init);@@ -1887,7 +1882,6 @@ int drm_mode_getcrtc(struct drm_device *dev, {struct drm_mode_crtc *crtc_resp = data;struct drm_crtc *crtc; -int ret =0 ;if (!drm_core_check_feature (dev,DRIVER_MODESET ))return -EINVAL ;@@ -1915,7 +1909,7 @@ int drm_mode_getcrtc(struct drm_device *dev, }drm_modeset_unlock_crtc (crtc); -return ret; +return 0 ; } static bool drm_mode_expose_to_userspace(const struct drm_display_mode *mode,@@ -2093,7 +2087,6 @@ int drm_mode_getencoder(struct drm_device *dev, void *data, {struct drm_mode_get_encoder *enc_resp = data;struct drm_encoder *encoder; -int ret =0 ;if (!drm_core_check_feature (dev,DRIVER_MODESET ))return -EINVAL ;@@ -2114,7 +2107,7 @@ int drm_mode_getencoder(struct drm_device *dev, void *data, enc_resp->possible_crtcs = encoder->possible_crtcs; enc_resp->possible_clones = encoder->possible_clones; -return ret; +return 0 ; }/** @@ -2197,7 +2190,6 @@ int drm_mode_getplane(struct drm_device *dev, void *data,struct drm_mode_get_plane *plane_resp = data;struct drm_plane *plane;uint32_t __user *format_ptr; -int ret =0 ;if (!drm_core_check_feature (dev,DRIVER_MODESET ))return -EINVAL ;@@ -2237,7 +2229,7 @@ int drm_mode_getplane(struct drm_device *dev, void *data, } plane_resp->count_format_types = plane->format_count; -return ret; +return 0 ; }/* @@ -2957,7 +2949,7 @@ int drm_mode_addfb(struct drm_device *dev, or->fb_id = r.fb_id; -return ret; +return 0 ; }static int format_check (const struct drm_mode_fb_cmd2 *r)Signature · 6 lines
2.1.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel