use outdise defined variable can reduce the recaculate of the
count of planes, crtcs and connectors.

Signed-off-by: John Hunter <zhjwpku at gmail.com>
---
 drivers/gpu/drm/drm_atomic_helper.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/drm_atomic_helper.c 
b/drivers/gpu/drm/drm_atomic_helper.c
index 39369ee..20376e6 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -1301,8 +1301,11 @@ void drm_atomic_helper_swap_state(struct drm_device *dev,
                                  struct drm_atomic_state *state)
 {
        int i;
+       int nconnectors = dev->mode_config.num_connector;
+       int ncrtcs = dev->mode_config.num_crtc;
+       int nplanes = dev->mode_config.num_total_plane;

-       for (i = 0; i < dev->mode_config.num_connector; i++) {
+       for (i = 0; i < nconnectors; i++) {
                struct drm_connector *connector = state->connectors[i];

                if (!connector)
@@ -1313,7 +1316,7 @@ void drm_atomic_helper_swap_state(struct drm_device *dev,
                connector->state->state = NULL;
        }

-       for (i = 0; i < dev->mode_config.num_crtc; i++) {
+       for (i = 0; i < ncrtcs; i++) {
                struct drm_crtc *crtc = state->crtcs[i];

                if (!crtc)
@@ -1324,7 +1327,7 @@ void drm_atomic_helper_swap_state(struct drm_device *dev,
                crtc->state->state = NULL;
        }

-       for (i = 0; i < dev->mode_config.num_total_plane; i++) {
+       for (i = 0; i < nplanes; i++) {
                struct drm_plane *plane = state->planes[i];

                if (!plane)
-- 
1.9.1


Reply via email to