[5/5] drm/i915: Move encoder variable to tighter scope
diff mbox series

Message ID 20200115190813.17971-5-ville.syrjala@linux.intel.com
State New
Headers show
Series
  • [1/5] drm/i915: Fix post-fastset modeset check for port sync
Related show

Commit Message

Ville Syrjälä Jan. 15, 2020, 7:08 p.m. UTC
From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Let's not pollute the function scope with variables when they're
only needed inside some loops.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/i915/display/intel_display.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

Comments

Souza, Jose Jan. 16, 2020, 12:20 a.m. UTC | #1
On Wed, 2020-01-15 at 21:08 +0200, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Let's not pollute the function scope with variables when they're
> only needed inside some loops.

Reviewed-by: José Roberto de Souza <jose.souza@intel.com>

> 
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
>  drivers/gpu/drm/i915/display/intel_display.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/display/intel_display.c
> b/drivers/gpu/drm/i915/display/intel_display.c
> index 97cf8457c956..76c17341df2b 100644
> --- a/drivers/gpu/drm/i915/display/intel_display.c
> +++ b/drivers/gpu/drm/i915/display/intel_display.c
> @@ -13070,7 +13070,6 @@ intel_modeset_pipe_config(struct
> intel_crtc_state *pipe_config)
>  {
>  	struct drm_crtc *crtc = pipe_config->uapi.crtc;
>  	struct drm_atomic_state *state = pipe_config->uapi.state;
> -	struct intel_encoder *encoder;
>  	struct drm_connector *connector;
>  	struct drm_connector_state *connector_state;
>  	int base_bpp, ret;
> @@ -13113,11 +13112,12 @@ intel_modeset_pipe_config(struct
> intel_crtc_state *pipe_config)
>  			       &pipe_config->pipe_src_h);
>  
>  	for_each_new_connector_in_state(state, connector,
> connector_state, i) {
> +		struct intel_encoder *encoder =
> +			to_intel_encoder(connector_state-
> >best_encoder);
> +
>  		if (connector_state->crtc != crtc)
>  			continue;
>  
> -		encoder = to_intel_encoder(connector_state-
> >best_encoder);
> -
>  		if (!check_single_encoder_cloning(state,
> to_intel_crtc(crtc), encoder)) {
>  			DRM_DEBUG_KMS("rejecting invalid cloning
> configuration\n");
>  			return -EINVAL;
> @@ -13167,6 +13167,9 @@ intel_modeset_pipe_config(struct
> intel_crtc_state *pipe_config)
>  	 * a chance to reject the mode entirely.
>  	 */
>  	for_each_new_connector_in_state(state, connector,
> connector_state, i) {
> +		struct intel_encoder *encoder =
> +			to_intel_encoder(connector_state-
> >best_encoder);
> +
>  		if (connector_state->crtc != crtc)
>  			continue;
>  
> @@ -13178,7 +13181,6 @@ intel_modeset_pipe_config(struct
> intel_crtc_state *pipe_config)
>  			return ret;
>  		}
>  
> -		encoder = to_intel_encoder(connector_state-
> >best_encoder);
>  		ret = encoder->compute_config(encoder, pipe_config,
>  					      connector_state);
>  		if (ret < 0) {

Patch
diff mbox series

diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c
index 97cf8457c956..76c17341df2b 100644
--- a/drivers/gpu/drm/i915/display/intel_display.c
+++ b/drivers/gpu/drm/i915/display/intel_display.c
@@ -13070,7 +13070,6 @@  intel_modeset_pipe_config(struct intel_crtc_state *pipe_config)
 {
 	struct drm_crtc *crtc = pipe_config->uapi.crtc;
 	struct drm_atomic_state *state = pipe_config->uapi.state;
-	struct intel_encoder *encoder;
 	struct drm_connector *connector;
 	struct drm_connector_state *connector_state;
 	int base_bpp, ret;
@@ -13113,11 +13112,12 @@  intel_modeset_pipe_config(struct intel_crtc_state *pipe_config)
 			       &pipe_config->pipe_src_h);
 
 	for_each_new_connector_in_state(state, connector, connector_state, i) {
+		struct intel_encoder *encoder =
+			to_intel_encoder(connector_state->best_encoder);
+
 		if (connector_state->crtc != crtc)
 			continue;
 
-		encoder = to_intel_encoder(connector_state->best_encoder);
-
 		if (!check_single_encoder_cloning(state, to_intel_crtc(crtc), encoder)) {
 			DRM_DEBUG_KMS("rejecting invalid cloning configuration\n");
 			return -EINVAL;
@@ -13167,6 +13167,9 @@  intel_modeset_pipe_config(struct intel_crtc_state *pipe_config)
 	 * a chance to reject the mode entirely.
 	 */
 	for_each_new_connector_in_state(state, connector, connector_state, i) {
+		struct intel_encoder *encoder =
+			to_intel_encoder(connector_state->best_encoder);
+
 		if (connector_state->crtc != crtc)
 			continue;
 
@@ -13178,7 +13181,6 @@  intel_modeset_pipe_config(struct intel_crtc_state *pipe_config)
 			return ret;
 		}
 
-		encoder = to_intel_encoder(connector_state->best_encoder);
 		ret = encoder->compute_config(encoder, pipe_config,
 					      connector_state);
 		if (ret < 0) {