diff mbox

[v3,7/7] drm/atomic: Clean up update_connector_routing.

Message ID 1456996662-8704-8-git-send-email-maarten.lankhorst@linux.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Maarten Lankhorst March 3, 2016, 9:17 a.m. UTC
connector_state->crtc can no longer be unset by accident,
so that check can be removed. The other code open-codes
drm_atomic_get_existing_crtc_state, so use that.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
 drivers/gpu/drm/drm_atomic_helper.c | 17 ++++-------------
 1 file changed, 4 insertions(+), 13 deletions(-)

Comments

Ville Syrjälä March 4, 2016, 1:29 p.m. UTC | #1
On Thu, Mar 03, 2016 at 10:17:42AM +0100, Maarten Lankhorst wrote:
> connector_state->crtc can no longer be unset by accident,
> so that check can be removed. The other code open-codes
> drm_atomic_get_existing_crtc_state, so use that.
> 
> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> ---
>  drivers/gpu/drm/drm_atomic_helper.c | 17 ++++-------------
>  1 file changed, 4 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
> index 2395201eb7ab..9f0d16eb04b2 100644
> --- a/drivers/gpu/drm/drm_atomic_helper.c
> +++ b/drivers/gpu/drm/drm_atomic_helper.c
> @@ -265,7 +265,7 @@ update_connector_routing(struct drm_atomic_state *state,
>  	const struct drm_connector_helper_funcs *funcs;
>  	struct drm_encoder *new_encoder;
>  	struct drm_crtc_state *crtc_state;
> -	int idx, ret;
> +	int ret;
>  
>  	DRM_DEBUG_ATOMIC("Updating routing for [CONNECTOR:%d:%s]\n",
>  			 connector->base.id,
> @@ -273,16 +273,12 @@ update_connector_routing(struct drm_atomic_state *state,
>  
>  	if (connector->state->crtc != connector_state->crtc) {
>  		if (connector->state->crtc) {
> -			idx = drm_crtc_index(connector->state->crtc);
> -
> -			crtc_state = state->crtc_states[idx];
> +			crtc_state = drm_atomic_get_existing_crtc_state(state, connector->state->crtc);
>  			crtc_state->connectors_changed = true;
>  		}
>  
>  		if (connector_state->crtc) {
> -			idx = drm_crtc_index(connector_state->crtc);
> -
> -			crtc_state = state->crtc_states[idx];
> +			crtc_state = drm_atomic_get_existing_crtc_state(state, connector_state->crtc);
>  			crtc_state->connectors_changed = true;
>  		}
>  	}
> @@ -336,14 +332,9 @@ update_connector_routing(struct drm_atomic_state *state,
>  
>  	steal_encoder(state, new_encoder);
>  
> -	if (WARN_ON(!connector_state->crtc))
> -		return -EINVAL;
> -

I was going to suggest just this when I read the code previously.

>  	set_best_encoder(state, connector_state, new_encoder);
>  
> -	idx = drm_crtc_index(connector_state->crtc);
> -
> -	crtc_state = state->crtc_states[idx];
> +	crtc_state = drm_atomic_get_existing_crtc_state(state, connector_state->crtc);

These could have been a separate patch, but no biggie

Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

>  	crtc_state->connectors_changed = true;
>  
>  	DRM_DEBUG_ATOMIC("[CONNECTOR:%d:%s] using [ENCODER:%d:%s] on [CRTC:%d:%s]\n",
> -- 
> 2.1.0
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Daniel Vetter March 8, 2016, 12:20 p.m. UTC | #2
On Fri, Mar 04, 2016 at 03:29:03PM +0200, Ville Syrjälä wrote:
> On Thu, Mar 03, 2016 at 10:17:42AM +0100, Maarten Lankhorst wrote:
> > connector_state->crtc can no longer be unset by accident,
> > so that check can be removed. The other code open-codes
> > drm_atomic_get_existing_crtc_state, so use that.
> > 
> > Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> > ---
> >  drivers/gpu/drm/drm_atomic_helper.c | 17 ++++-------------
> >  1 file changed, 4 insertions(+), 13 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
> > index 2395201eb7ab..9f0d16eb04b2 100644
> > --- a/drivers/gpu/drm/drm_atomic_helper.c
> > +++ b/drivers/gpu/drm/drm_atomic_helper.c
> > @@ -265,7 +265,7 @@ update_connector_routing(struct drm_atomic_state *state,
> >  	const struct drm_connector_helper_funcs *funcs;
> >  	struct drm_encoder *new_encoder;
> >  	struct drm_crtc_state *crtc_state;
> > -	int idx, ret;
> > +	int ret;
> >  
> >  	DRM_DEBUG_ATOMIC("Updating routing for [CONNECTOR:%d:%s]\n",
> >  			 connector->base.id,
> > @@ -273,16 +273,12 @@ update_connector_routing(struct drm_atomic_state *state,
> >  
> >  	if (connector->state->crtc != connector_state->crtc) {
> >  		if (connector->state->crtc) {
> > -			idx = drm_crtc_index(connector->state->crtc);
> > -
> > -			crtc_state = state->crtc_states[idx];
> > +			crtc_state = drm_atomic_get_existing_crtc_state(state, connector->state->crtc);
> >  			crtc_state->connectors_changed = true;
> >  		}
> >  
> >  		if (connector_state->crtc) {
> > -			idx = drm_crtc_index(connector_state->crtc);
> > -
> > -			crtc_state = state->crtc_states[idx];
> > +			crtc_state = drm_atomic_get_existing_crtc_state(state, connector_state->crtc);
> >  			crtc_state->connectors_changed = true;
> >  		}
> >  	}
> > @@ -336,14 +332,9 @@ update_connector_routing(struct drm_atomic_state *state,
> >  
> >  	steal_encoder(state, new_encoder);
> >  
> > -	if (WARN_ON(!connector_state->crtc))
> > -		return -EINVAL;
> > -
> 
> I was going to suggest just this when I read the code previously.
> 
> >  	set_best_encoder(state, connector_state, new_encoder);
> >  
> > -	idx = drm_crtc_index(connector_state->crtc);
> > -
> > -	crtc_state = state->crtc_states[idx];
> > +	crtc_state = drm_atomic_get_existing_crtc_state(state, connector_state->crtc);
> 
> These could have been a separate patch, but no biggie
> 
> Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Remaining patches applied to drm-misc, thanks.
-Daniel

> 
> >  	crtc_state->connectors_changed = true;
> >  
> >  	DRM_DEBUG_ATOMIC("[CONNECTOR:%d:%s] using [ENCODER:%d:%s] on [CRTC:%d:%s]\n",
> > -- 
> > 2.1.0
> > 
> > _______________________________________________
> > Intel-gfx mailing list
> > Intel-gfx@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/intel-gfx
> 
> -- 
> Ville Syrjälä
> Intel OTC
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
diff mbox

Patch

diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
index 2395201eb7ab..9f0d16eb04b2 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -265,7 +265,7 @@  update_connector_routing(struct drm_atomic_state *state,
 	const struct drm_connector_helper_funcs *funcs;
 	struct drm_encoder *new_encoder;
 	struct drm_crtc_state *crtc_state;
-	int idx, ret;
+	int ret;
 
 	DRM_DEBUG_ATOMIC("Updating routing for [CONNECTOR:%d:%s]\n",
 			 connector->base.id,
@@ -273,16 +273,12 @@  update_connector_routing(struct drm_atomic_state *state,
 
 	if (connector->state->crtc != connector_state->crtc) {
 		if (connector->state->crtc) {
-			idx = drm_crtc_index(connector->state->crtc);
-
-			crtc_state = state->crtc_states[idx];
+			crtc_state = drm_atomic_get_existing_crtc_state(state, connector->state->crtc);
 			crtc_state->connectors_changed = true;
 		}
 
 		if (connector_state->crtc) {
-			idx = drm_crtc_index(connector_state->crtc);
-
-			crtc_state = state->crtc_states[idx];
+			crtc_state = drm_atomic_get_existing_crtc_state(state, connector_state->crtc);
 			crtc_state->connectors_changed = true;
 		}
 	}
@@ -336,14 +332,9 @@  update_connector_routing(struct drm_atomic_state *state,
 
 	steal_encoder(state, new_encoder);
 
-	if (WARN_ON(!connector_state->crtc))
-		return -EINVAL;
-
 	set_best_encoder(state, connector_state, new_encoder);
 
-	idx = drm_crtc_index(connector_state->crtc);
-
-	crtc_state = state->crtc_states[idx];
+	crtc_state = drm_atomic_get_existing_crtc_state(state, connector_state->crtc);
 	crtc_state->connectors_changed = true;
 
 	DRM_DEBUG_ATOMIC("[CONNECTOR:%d:%s] using [ENCODER:%d:%s] on [CRTC:%d:%s]\n",