* [patch] drm: radeon: fix sign bug
@ 2010-07-17 10:28 Dan Carpenter
2010-07-19 17:01 ` Alex Deucher
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2010-07-17 10:28 UTC (permalink / raw)
To: David Airlie; +Cc: Dave Airlie, Jerome Glisse, kernel-janitors, dri-devel
The "error" variable is unsigned so it's never less than zero. I
changed it to check if (freq < current_freq) directly.
"best_error" is also unsigned so "best_error - 100" could be a large
number instead of a negative. Since "error" is unsigned it is never
less than a negative and so the cases where "best_error" is less than or
equal to 100 are false.
Signed-off-by: Dan Carpenter <error27@gmail.com>
diff --git a/drivers/gpu/drm/radeon/radeon_display.c b/drivers/gpu/drm/radeon/radeon_display.c
index 8154cdf..a68728d 100644
--- a/drivers/gpu/drm/radeon/radeon_display.c
+++ b/drivers/gpu/drm/radeon/radeon_display.c
@@ -558,15 +558,17 @@ static void radeon_compute_pll_legacy(struct radeon_pll *pll,
current_freq = radeon_div(tmp, ref_div * post_div);
if (pll->flags & RADEON_PLL_PREFER_CLOSEST_LOWER) {
- error = freq - current_freq;
- error = error < 0 ? 0xffffffff : error;
+ if (freq < current_freq)
+ error = 0xffffffff;
+ else
+ error = freq - current_freq;
} else
error = abs(current_freq - freq);
vco_diff = abs(vco - best_vco);
if ((best_vco = 0 && error < best_error) ||
(best_vco != 0 &&
- (error < best_error - 100 ||
+ ((best_error > 100 && error < best_error - 100) ||
(abs(error - best_error) < 100 && vco_diff < best_vco_diff)))) {
best_post_div = post_div;
best_ref_div = ref_div;
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [patch] drm: radeon: fix sign bug
2010-07-17 10:28 [patch] drm: radeon: fix sign bug Dan Carpenter
@ 2010-07-19 17:01 ` Alex Deucher
0 siblings, 0 replies; 2+ messages in thread
From: Alex Deucher @ 2010-07-19 17:01 UTC (permalink / raw)
To: Dan Carpenter; +Cc: Dave Airlie, Jerome Glisse, kernel-janitors, dri-devel
On Sat, Jul 17, 2010 at 6:28 AM, Dan Carpenter <error27@gmail.com> wrote:
> The "error" variable is unsigned so it's never less than zero. I
> changed it to check if (freq < current_freq) directly.
>
> "best_error" is also unsigned so "best_error - 100" could be a large
> number instead of a negative. Since "error" is unsigned it is never
> less than a negative and so the cases where "best_error" is less than or
> equal to 100 are false.
>
> Signed-off-by: Dan Carpenter <error27@gmail.com>
>
This looks good Dan. Dave, please apply,
Reviewed-by: Alex Deucher <alexdeucher@gmail.com>
> diff --git a/drivers/gpu/drm/radeon/radeon_display.c b/drivers/gpu/drm/radeon/radeon_display.c
> index 8154cdf..a68728d 100644
> --- a/drivers/gpu/drm/radeon/radeon_display.c
> +++ b/drivers/gpu/drm/radeon/radeon_display.c
> @@ -558,15 +558,17 @@ static void radeon_compute_pll_legacy(struct radeon_pll *pll,
> current_freq = radeon_div(tmp, ref_div * post_div);
>
> if (pll->flags & RADEON_PLL_PREFER_CLOSEST_LOWER) {
> - error = freq - current_freq;
> - error = error < 0 ? 0xffffffff : error;
> + if (freq < current_freq)
> + error = 0xffffffff;
> + else
> + error = freq - current_freq;
> } else
> error = abs(current_freq - freq);
> vco_diff = abs(vco - best_vco);
>
> if ((best_vco = 0 && error < best_error) ||
> (best_vco != 0 &&
> - (error < best_error - 100 ||
> + ((best_error > 100 && error < best_error - 100) ||
> (abs(error - best_error) < 100 && vco_diff < best_vco_diff)))) {
> best_post_div = post_div;
> best_ref_div = ref_div;
>
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-07-19 17:01 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-17 10:28 [patch] drm: radeon: fix sign bug Dan Carpenter
2010-07-19 17:01 ` Alex Deucher
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).