[Intel-gfx] [PATCH 6/6] ddi_compute_wrpll: Factor out a common expression

Damien Lespiau damien.lespiau at intel.com
Wed May 8 15:09:31 CEST 2013


Signed-off-by: Damien Lespiau <damien.lespiau at intel.com>
---
 tests/ddi_compute_wrpll.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/tests/ddi_compute_wrpll.c b/tests/ddi_compute_wrpll.c
index bdde61c..39f4ffc 100644
--- a/tests/ddi_compute_wrpll.c
+++ b/tests/ddi_compute_wrpll.c
@@ -102,7 +102,7 @@ static void wrpll_update_rnp(uint64_t freq2k, unsigned budget,
 			     unsigned r2, unsigned n2, unsigned p,
 			     struct wrpll_rnp *best)
 {
-	uint64_t a, b, c, d;
+	uint64_t a, b, c, d, diff, diff_best;
 
 	/* No best (r,n,p) yet */
 	if (best->p == 0) {
@@ -128,16 +128,15 @@ static void wrpll_update_rnp(uint64_t freq2k, unsigned budget,
 	 */
 	a = freq2k * budget * p * r2;
 	b = freq2k * budget * best->p * best->r2;
-	c = 1e6 * ABS_DIFF((freq2k * p * r2), (LC_FREQ_2K * n2));
-	d = 1e6 * ABS_DIFF((freq2k * best->p * best->r2),
-			   (LC_FREQ_2K * best->n2));
+	diff = ABS_DIFF((freq2k * p * r2), (LC_FREQ_2K * n2));
+	diff_best = ABS_DIFF((freq2k * best->p * best->r2),
+			     (LC_FREQ_2K * best->n2));
+	c = 1e6 * diff;
+	d = 1e6 * diff_best;
 
 	if (a < c && b < d) {
 		/* If both are above the budget, pick the closer */
-		if (best->p * best->r2 * ABS_DIFF((freq2k * p * r2),
-						  (LC_FREQ_2K * n2)) <
-		    p * r2 * ABS_DIFF((freq2k * best->p * best->r2),
-				      (LC_FREQ_2K * best->n2))) {
+		if (best->p * best->r2 * diff < p * r2 * diff_best) {
 			best->p = p;
 			best->n2 = n2;
 			best->r2 = r2;
-- 
1.8.1.4




More information about the Intel-gfx mailing list