Skip to content

Commit

Permalink
asiliantfb: fix test of unsigned in asiliant_calc_dclk2()
Browse files Browse the repository at this point in the history
Ftarget, Fret, n and m are unsigned so the tests did not work.

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
Cc: Andres Salomon <dilinger@debian.org>
Cc: Krzysztof Helt <krzysztof.h1@poczta.fm>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Roel Kluin authored and Linus Torvalds committed Mar 12, 2010
1 parent 6e3e37a commit 0d3580d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/video/asiliantfb.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ static void asiliant_calc_dclk2(u32 *ppixclock, u8 *dclk2_m, u8 *dclk2_n, u8 *dc

/* 3 <= m <= 257 */
if (m >= 3 && m <= 257) {
unsigned new_error = ((Ftarget * n) - (Fref * m)) >= 0 ?
unsigned new_error = Ftarget * n >= Fref * m ?
((Ftarget * n) - (Fref * m)) : ((Fref * m) - (Ftarget * n));
if (new_error < best_error) {
best_n = n;
Expand All @@ -152,7 +152,7 @@ static void asiliant_calc_dclk2(u32 *ppixclock, u8 *dclk2_m, u8 *dclk2_n, u8 *dc
else if (m <= 1028) {
/* remember there are still only 8-bits of precision in m, so
* avoid over-optimistic error calculations */
unsigned new_error = ((Ftarget * n) - (Fref * (m & ~3))) >= 0 ?
unsigned new_error = Ftarget * n >= Fref * (m & ~3) ?
((Ftarget * n) - (Fref * (m & ~3))) : ((Fref * (m & ~3)) - (Ftarget * n));
if (new_error < best_error) {
best_n = n;
Expand Down

0 comments on commit 0d3580d

Please sign in to comment.