[PATCH 2/3] drm: replace the 'for' condition with outside defined variable

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

Signed-off-by: John Hunter <zhjwpku@xxxxxxxxx>
---
 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


_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/dri-devel





[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux