[v2,09/17] drm: Flatten drm_mode_vrefresh()
diff mbox series

Message ID 20200403204008.14864-10-ville.syrjala@linux.intel.com
State New
Headers show
Series
  • drm: Put drm_display_mode on diet
Related show

Commit Message

Ville Syrjälä April 3, 2020, 8:40 p.m. UTC
From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Remove the pointless whole-function indentation. Also don't
need to worry about negative values anymore since we switched
everything to u16.

Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/drm_modes.c | 26 ++++++++++++--------------
 1 file changed, 12 insertions(+), 14 deletions(-)

Comments

Sam Ravnborg April 7, 2020, 6:46 p.m. UTC | #1
On Fri, Apr 03, 2020 at 11:40:00PM +0300, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Remove the pointless whole-function indentation. Also don't
> need to worry about negative values anymore since we switched
> everything to u16.
> 
> Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

First change could have been in the patch that made this check
pointless. But this works too.

Reviewed-by: Sam Ravnborg <sam@ravnborg.org>

> ---
>  drivers/gpu/drm/drm_modes.c | 26 ++++++++++++--------------
>  1 file changed, 12 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c
> index 77d68120931a..f2865f88bd54 100644
> --- a/drivers/gpu/drm/drm_modes.c
> +++ b/drivers/gpu/drm/drm_modes.c
> @@ -757,24 +757,22 @@ EXPORT_SYMBOL(drm_mode_set_name);
>   */
>  int drm_mode_vrefresh(const struct drm_display_mode *mode)
>  {
> -	int refresh = 0;
> +	unsigned int num, den;
>  
> -	if (mode->htotal > 0 && mode->vtotal > 0) {
> -		unsigned int num, den;
> +	if (mode->htotal == 0 || mode->vtotal == 0)
> +		return 0;
>  
> -		num = mode->clock * 1000;
> -		den = mode->htotal * mode->vtotal;
> +	num = mode->clock * 1000;
> +	den = mode->htotal * mode->vtotal;
>  
> -		if (mode->flags & DRM_MODE_FLAG_INTERLACE)
> -			num *= 2;
> -		if (mode->flags & DRM_MODE_FLAG_DBLSCAN)
> -			den *= 2;
> -		if (mode->vscan > 1)
> -			den *= mode->vscan;
> +	if (mode->flags & DRM_MODE_FLAG_INTERLACE)
> +		num *= 2;
> +	if (mode->flags & DRM_MODE_FLAG_DBLSCAN)
> +		den *= 2;
> +	if (mode->vscan > 1)
> +		den *= mode->vscan;
>  
> -		refresh = DIV_ROUND_CLOSEST(num, den);
> -	}
> -	return refresh;
> +	return DIV_ROUND_CLOSEST(num, den);
>  }
>  EXPORT_SYMBOL(drm_mode_vrefresh);
>  
> -- 
> 2.24.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

Patch
diff mbox series

diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c
index 77d68120931a..f2865f88bd54 100644
--- a/drivers/gpu/drm/drm_modes.c
+++ b/drivers/gpu/drm/drm_modes.c
@@ -757,24 +757,22 @@  EXPORT_SYMBOL(drm_mode_set_name);
  */
 int drm_mode_vrefresh(const struct drm_display_mode *mode)
 {
-	int refresh = 0;
+	unsigned int num, den;
 
-	if (mode->htotal > 0 && mode->vtotal > 0) {
-		unsigned int num, den;
+	if (mode->htotal == 0 || mode->vtotal == 0)
+		return 0;
 
-		num = mode->clock * 1000;
-		den = mode->htotal * mode->vtotal;
+	num = mode->clock * 1000;
+	den = mode->htotal * mode->vtotal;
 
-		if (mode->flags & DRM_MODE_FLAG_INTERLACE)
-			num *= 2;
-		if (mode->flags & DRM_MODE_FLAG_DBLSCAN)
-			den *= 2;
-		if (mode->vscan > 1)
-			den *= mode->vscan;
+	if (mode->flags & DRM_MODE_FLAG_INTERLACE)
+		num *= 2;
+	if (mode->flags & DRM_MODE_FLAG_DBLSCAN)
+		den *= 2;
+	if (mode->vscan > 1)
+		den *= mode->vscan;
 
-		refresh = DIV_ROUND_CLOSEST(num, den);
-	}
-	return refresh;
+	return DIV_ROUND_CLOSEST(num, den);
 }
 EXPORT_SYMBOL(drm_mode_vrefresh);