From: Damien Lespiau Subject: [PATCH 6/6] ddi_compute_wrpll: Factor out a common expression Date: Wed, 8 May 2013 14:09:31 +0100 Message-ID: <1368018571-24705-6-git-send-email-damien.lespiau@intel.com> References: <1368018571-24705-1-git-send-email-damien.lespiau@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mga03.intel.com (mga03.intel.com [143.182.124.21]) by gabe.freedesktop.org (Postfix) with ESMTP id 341B8E6319 for ; Wed, 8 May 2013 06:10:00 -0700 (PDT) In-Reply-To: <1368018571-24705-1-git-send-email-damien.lespiau@intel.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: intel-gfx-bounces+gcfxdi-intel-gfx=m.gmane.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+gcfxdi-intel-gfx=m.gmane.org@lists.freedesktop.org To: intel-gfx@lists.freedesktop.org List-Id: intel-gfx@lists.freedesktop.org Signed-off-by: Damien Lespiau --- 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