From: Ville Syrjala <ville.syrjala@linux.intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t 6/7] tools/cnl_compute_wrpll: Fix abs(unsigned)
Date: Tue, 14 Jan 2020 16:25:22 +0200 [thread overview]
Message-ID: <20200114142523.10603-6-ville.syrjala@linux.intel.com> (raw)
In-Reply-To: <20200114142523.10603-1-ville.syrjala@linux.intel.com>
From: Ville Syrjälä <ville.syrjala@linux.intel.com>
../tools/cnl_compute_wrpll.c: In function ‘cnl_ddi_calculate_wrpll2’:
../tools/cnl_compute_wrpll.c:216:21: warning: taking the absolute value of unsigned type ‘uint32_t’ {aka ‘unsigned int’} has no effect [-Wabsolute-value]
216 | dco_centrality = abs(dco - dco_mid);
| ^~~
../tools/cnl_compute_wrpll.c: In function ‘test_multipliers’:
../tools/cnl_compute_wrpll.c:258:21: warning: taking the absolute value of unsigned type ‘unsigned int’ has no effect [-Wabsolute-value]
258 | dco_centrality = abs(dco - dco_mid);
| ^~~
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
tools/cnl_compute_wrpll.c | 28 ++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)
diff --git a/tools/cnl_compute_wrpll.c b/tools/cnl_compute_wrpll.c
index c7b7bd723123..9caf69f13bd0 100644
--- a/tools/cnl_compute_wrpll.c
+++ b/tools/cnl_compute_wrpll.c
@@ -23,6 +23,7 @@
#include <assert.h>
#include <inttypes.h>
+#include <limits.h>
#include <stdio.h>
#include <stdbool.h>
#include <stdint.h>
@@ -30,7 +31,6 @@
#include <string.h>
#include <math.h>
-#define U32_MAX ((uint32_t)~0ULL)
#define ARRAY_SIZE(arr) (sizeof(arr)/sizeof(arr[0]))
static inline uint64_t div_u64(uint64_t dividend, uint32_t divisor)
@@ -194,20 +194,20 @@ static bool
cnl_ddi_calculate_wrpll2(int clock,
struct skl_wrpll_params *params)
{
- uint32_t afe_clock = clock * 5 / 1000; /* clock in kHz */
- uint32_t dco_min = 7998000;
- uint32_t dco_max = 10000000;
- uint32_t dco_mid = (dco_min + dco_max) / 2;
+ int afe_clock = clock * 5 / 1000; /* clock in kHz */
+ int dco_min = 7998000;
+ int dco_max = 10000000;
+ int dco_mid = (dco_min + dco_max) / 2;
static const int dividers[] = { 2, 4, 6, 8, 10, 12, 14, 16,
18, 20, 24, 28, 30, 32, 36, 40,
42, 44, 48, 50, 52, 54, 56, 60,
64, 66, 68, 70, 72, 76, 78, 80,
84, 88, 90, 92, 96, 98, 100, 102,
3, 5, 7, 9, 15, 21 };
- uint32_t dco, best_dco = 0, dco_centrality = 0;
- uint32_t best_dco_centrality = U32_MAX; /* Spec meaning of 999999 MHz */
+ int dco, best_dco = 0, dco_centrality = 0;
+ int best_dco_centrality = INT_MAX; /* Spec meaning of 999999 MHz */
int d, best_div = 0, pdiv = 0, qdiv = 0, kdiv = 0;
- uint32_t ref_clock = params->ref_clock;
+ int ref_clock = params->ref_clock;
for (d = 0; d < ARRAY_SIZE(dividers); d++) {
dco = afe_clock * dividers[d];
@@ -236,10 +236,10 @@ cnl_ddi_calculate_wrpll2(int clock,
static void test_multipliers(unsigned int clock)
{
- uint64_t afe_clock = clock * 5 / 1000; /* clocks in kHz */
- unsigned int dco_min = 7998000;
- unsigned int dco_max = 10000000;
- unsigned int dco_mid = (dco_min + dco_max) / 2;
+ int afe_clock = clock * 5 / 1000; /* clocks in kHz */
+ int dco_min = 7998000;
+ int dco_max = 10000000;
+ int dco_mid = (dco_min + dco_max) / 2;
static const int dividerlist[] = { 2, 4, 6, 8, 10, 12, 14, 16,
18, 20, 24, 28, 30, 32, 36, 40,
@@ -247,8 +247,8 @@ static void test_multipliers(unsigned int clock)
64, 66, 68, 70, 72, 76, 78, 80,
84, 88, 90, 92, 96, 98, 100, 102,
3, 5, 7, 9, 15, 21 };
- unsigned int dco, dco_centrality = 0;
- unsigned int best_dco_centrality = U32_MAX;
+ int dco, dco_centrality = 0;
+ int best_dco_centrality = INT_MAX;
int d, best_div = 0, pdiv = 0, qdiv = 0, kdiv = 0;
for (d = 0; d < ARRAY_SIZE(dividerlist); d++) {
--
2.24.1
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
next prev parent reply other threads:[~2020-01-14 14:25 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-14 14:25 [igt-dev] [PATCH i-g-t 1/7] tests/kms_vrr: Fix compiler warn on 32bit Ville Syrjala
2020-01-14 14:25 ` [igt-dev] [PATCH i-g-t 2/7] tests/eviction_common: " Ville Syrjala
2020-01-14 14:25 ` [igt-dev] [PATCH i-g-t 3/7] tests/perf: " Ville Syrjala
2020-01-14 14:25 ` [igt-dev] [PATCH i-g-t 4/7] lib/intel_aux_pgtable: Fix uint64_t vs. long mismatch Ville Syrjala
2020-01-14 14:25 ` [igt-dev] [PATCH i-g-t 5/7] tests/kms_dp_tiled_display: Use labs() for long Ville Syrjala
2020-01-14 14:25 ` Ville Syrjala [this message]
2020-01-14 14:25 ` [igt-dev] [PATCH i-g-t 7/7] tools/intel_panel_fitter: Fix abs(unsigned) Ville Syrjala
2020-01-14 14:29 ` Chris Wilson
2020-01-14 15:24 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,1/7] tests/kms_vrr: Fix compiler warn on 32bit Patchwork
2020-01-16 18:49 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200114142523.10603-6-ville.syrjala@linux.intel.com \
--to=ville.syrjala@linux.intel.com \
--cc=igt-dev@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox