diff options
author | Daniel Vetter <daniel.vetter@ffwll.ch> | 2014-11-12 05:59:47 -0500 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2014-11-14 18:40:33 -0500 |
commit | baf698b0496e93f2737b9046d3b1892c55133b0d (patch) | |
tree | 96605b931839b37fcd34284f2ae39bfa04702088 /drivers/gpu | |
parent | b0654103f55ebae8f72700b37f152942f34806cc (diff) |
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.
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Reviewed-by: Sean Paul <seanpaul@chromium.org>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu')
-rw-r--r-- | drivers/gpu/drm/drm_crtc.c | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index e8fc946ed59c..5a4be0398650 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c | |||
@@ -683,7 +683,7 @@ int drm_crtc_init_with_planes(struct drm_device *dev, struct drm_crtc *crtc, | |||
683 | drm_modeset_lock_init(&crtc->mutex); | 683 | drm_modeset_lock_init(&crtc->mutex); |
684 | ret = drm_mode_object_get(dev, &crtc->base, DRM_MODE_OBJECT_CRTC); | 684 | ret = drm_mode_object_get(dev, &crtc->base, DRM_MODE_OBJECT_CRTC); |
685 | if (ret) | 685 | if (ret) |
686 | goto out; | 686 | return ret; |
687 | 687 | ||
688 | crtc->base.properties = &crtc->properties; | 688 | crtc->base.properties = &crtc->properties; |
689 | 689 | ||
@@ -697,9 +697,7 @@ int drm_crtc_init_with_planes(struct drm_device *dev, struct drm_crtc *crtc, | |||
697 | if (cursor) | 697 | if (cursor) |
698 | cursor->possible_crtcs = 1 << drm_crtc_index(crtc); | 698 | cursor->possible_crtcs = 1 << drm_crtc_index(crtc); |
699 | 699 | ||
700 | out: | 700 | return 0; |
701 | |||
702 | return ret; | ||
703 | } | 701 | } |
704 | EXPORT_SYMBOL(drm_crtc_init_with_planes); | 702 | EXPORT_SYMBOL(drm_crtc_init_with_planes); |
705 | 703 | ||
@@ -1154,7 +1152,7 @@ int drm_universal_plane_init(struct drm_device *dev, struct drm_plane *plane, | |||
1154 | 1152 | ||
1155 | ret = drm_mode_object_get(dev, &plane->base, DRM_MODE_OBJECT_PLANE); | 1153 | ret = drm_mode_object_get(dev, &plane->base, DRM_MODE_OBJECT_PLANE); |
1156 | if (ret) | 1154 | if (ret) |
1157 | goto out; | 1155 | return ret; |
1158 | 1156 | ||
1159 | drm_modeset_lock_init(&plane->mutex); | 1157 | drm_modeset_lock_init(&plane->mutex); |
1160 | 1158 | ||
@@ -1166,8 +1164,7 @@ int drm_universal_plane_init(struct drm_device *dev, struct drm_plane *plane, | |||
1166 | if (!plane->format_types) { | 1164 | if (!plane->format_types) { |
1167 | DRM_DEBUG_KMS("out of memory when allocating plane\n"); | 1165 | DRM_DEBUG_KMS("out of memory when allocating plane\n"); |
1168 | drm_mode_object_put(dev, &plane->base); | 1166 | drm_mode_object_put(dev, &plane->base); |
1169 | ret = -ENOMEM; | 1167 | return -ENOMEM; |
1170 | goto out; | ||
1171 | } | 1168 | } |
1172 | 1169 | ||
1173 | memcpy(plane->format_types, formats, format_count * sizeof(uint32_t)); | 1170 | 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, | |||
1184 | dev->mode_config.plane_type_property, | 1181 | dev->mode_config.plane_type_property, |
1185 | plane->type); | 1182 | plane->type); |
1186 | 1183 | ||
1187 | out: | 1184 | return 0; |
1188 | |||
1189 | return ret; | ||
1190 | } | 1185 | } |
1191 | EXPORT_SYMBOL(drm_universal_plane_init); | 1186 | EXPORT_SYMBOL(drm_universal_plane_init); |
1192 | 1187 | ||
@@ -1888,7 +1883,6 @@ int drm_mode_getcrtc(struct drm_device *dev, | |||
1888 | { | 1883 | { |
1889 | struct drm_mode_crtc *crtc_resp = data; | 1884 | struct drm_mode_crtc *crtc_resp = data; |
1890 | struct drm_crtc *crtc; | 1885 | struct drm_crtc *crtc; |
1891 | int ret = 0; | ||
1892 | 1886 | ||
1893 | if (!drm_core_check_feature(dev, DRIVER_MODESET)) | 1887 | if (!drm_core_check_feature(dev, DRIVER_MODESET)) |
1894 | return -EINVAL; | 1888 | return -EINVAL; |
@@ -1916,7 +1910,7 @@ int drm_mode_getcrtc(struct drm_device *dev, | |||
1916 | } | 1910 | } |
1917 | drm_modeset_unlock_crtc(crtc); | 1911 | drm_modeset_unlock_crtc(crtc); |
1918 | 1912 | ||
1919 | return ret; | 1913 | return 0; |
1920 | } | 1914 | } |
1921 | 1915 | ||
1922 | static bool drm_mode_expose_to_userspace(const struct drm_display_mode *mode, | 1916 | static bool drm_mode_expose_to_userspace(const struct drm_display_mode *mode, |
@@ -2094,7 +2088,6 @@ int drm_mode_getencoder(struct drm_device *dev, void *data, | |||
2094 | { | 2088 | { |
2095 | struct drm_mode_get_encoder *enc_resp = data; | 2089 | struct drm_mode_get_encoder *enc_resp = data; |
2096 | struct drm_encoder *encoder; | 2090 | struct drm_encoder *encoder; |
2097 | int ret = 0; | ||
2098 | 2091 | ||
2099 | if (!drm_core_check_feature(dev, DRIVER_MODESET)) | 2092 | if (!drm_core_check_feature(dev, DRIVER_MODESET)) |
2100 | return -EINVAL; | 2093 | return -EINVAL; |
@@ -2115,7 +2108,7 @@ int drm_mode_getencoder(struct drm_device *dev, void *data, | |||
2115 | enc_resp->possible_crtcs = encoder->possible_crtcs; | 2108 | enc_resp->possible_crtcs = encoder->possible_crtcs; |
2116 | enc_resp->possible_clones = encoder->possible_clones; | 2109 | enc_resp->possible_clones = encoder->possible_clones; |
2117 | 2110 | ||
2118 | return ret; | 2111 | return 0; |
2119 | } | 2112 | } |
2120 | 2113 | ||
2121 | /** | 2114 | /** |
@@ -2198,7 +2191,6 @@ int drm_mode_getplane(struct drm_device *dev, void *data, | |||
2198 | struct drm_mode_get_plane *plane_resp = data; | 2191 | struct drm_mode_get_plane *plane_resp = data; |
2199 | struct drm_plane *plane; | 2192 | struct drm_plane *plane; |
2200 | uint32_t __user *format_ptr; | 2193 | uint32_t __user *format_ptr; |
2201 | int ret = 0; | ||
2202 | 2194 | ||
2203 | if (!drm_core_check_feature(dev, DRIVER_MODESET)) | 2195 | if (!drm_core_check_feature(dev, DRIVER_MODESET)) |
2204 | return -EINVAL; | 2196 | return -EINVAL; |
@@ -2238,7 +2230,7 @@ int drm_mode_getplane(struct drm_device *dev, void *data, | |||
2238 | } | 2230 | } |
2239 | plane_resp->count_format_types = plane->format_count; | 2231 | plane_resp->count_format_types = plane->format_count; |
2240 | 2232 | ||
2241 | return ret; | 2233 | return 0; |
2242 | } | 2234 | } |
2243 | 2235 | ||
2244 | /* | 2236 | /* |
@@ -2958,7 +2950,7 @@ int drm_mode_addfb(struct drm_device *dev, | |||
2958 | 2950 | ||
2959 | or->fb_id = r.fb_id; | 2951 | or->fb_id = r.fb_id; |
2960 | 2952 | ||
2961 | return ret; | 2953 | return 0; |
2962 | } | 2954 | } |
2963 | 2955 | ||
2964 | static int format_check(const struct drm_mode_fb_cmd2 *r) | 2956 | static int format_check(const struct drm_mode_fb_cmd2 *r) |