[Nouveau] [PATCH envytools] nvamemtiming: Handle target < initial case when iterating values

Christian Costa titan.costa at gmail.com
Sun Aug 31 06:00:42 PDT 2014


Otherwise some values are not tested at all.
---
 nva/set_timings.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/nva/set_timings.c b/nva/set_timings.c
index 6cd831c..7a8f845 100644
--- a/nva/set_timings.c
+++ b/nva/set_timings.c
@@ -408,7 +408,7 @@ static void
 iterate_values(struct nvamemtiming_conf *conf, FILE *outf, uint8_t index, enum color color)
 {
 	uint8_t initial, target;
-	int v;
+	int v, incr;
 
 	if (conf->mode != MODE_DEEP)
 		return;
@@ -416,7 +416,8 @@ iterate_values(struct nvamemtiming_conf *conf, FILE *outf, uint8_t index, enum c
 	initial = conf->vbios.data[conf->vbios.timing_entry_offset + index];
 	target = conf->vbios.data[conf->deep.timing_entry_offset + index];
 
-	for (v = initial+1; v <= target; v++) {
+	incr = target > initial ? 1 : -1;
+	for (v = initial+incr; v != target+incr; v+=incr) {
 		conf->vbios.data[conf->vbios.timing_entry_offset + index] = v;
 		launch(conf, outf, index + 1 , COLOR);
 	}
-- 
1.9.1



More information about the Nouveau mailing list