public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Sean Paul <seanpaul@chromium.org>
To: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Daniel Vetter <daniel.vetter@intel.com>,
	Intel Graphics Development <intel-gfx@lists.freedesktop.org>,
	DRI Development <dri-devel@lists.freedesktop.org>
Subject: Re: [PATCH] drm: Simplify return value handling in drm_crtc.c
Date: Fri, 14 Nov 2014 06:50:26 -0500	[thread overview]
Message-ID: <20141114115026.GA20877@philcollins> (raw)
In-Reply-To: <1415789987-17389-1-git-send-email-daniel.vetter@ffwll.ch>

On Wed, Nov 12, 2014 at 11:59:47AM +0100, Daniel Vetter wrote:
> 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>

> ---
>  drivers/gpu/drm/drm_crtc.c | 26 +++++++++-----------------
>  1 file changed, 9 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
> index 2beb219df1bd..46e00a29cce2 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,
>  	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)
> -- 
> 2.1.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

      parent reply	other threads:[~2014-11-14 11:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-12 10:59 [PATCH] drm: Simplify return value handling in drm_crtc.c Daniel Vetter
2014-11-12 19:29 ` [PATCH] drm: Simplify return value handling in shuang.he
2014-11-14 11:50 ` Sean Paul [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20141114115026.GA20877@philcollins \
    --to=seanpaul@chromium.org \
    --cc=daniel.vetter@ffwll.ch \
    --cc=daniel.vetter@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox