nb/i945,gm45,x4x/gma.c: fix unsigned arithmetics
This issue was found by Coverity Scan, CID 1364118. Change-Id: Iba3c0f4f952729d9e0987d928b63ef8b8fe8841e Signed-off-by: Arthur Heymans <arthur@aheymans.xyz> Reviewed-on: https://review.coreboot.org/16992 Reviewed-by: Martin Roth <martinroth@google.com> Tested-by: build bot (Jenkins)
This commit is contained in:
committed by
Martin Roth
parent
063cd5f6ee
commit
75f9131453
@@ -171,7 +171,8 @@ static void gma_init_lvds(const struct northbridge_intel_gm45_config *info,
|
||||
u32 p = candp1 * pixel_p2;
|
||||
u32 vco = DIV_ROUND_CLOSEST(BASE_FREQUENCY * m, candn + 2);
|
||||
u32 dot = DIV_ROUND_CLOSEST(vco, p);
|
||||
u32 this_err = ABS(dot - target_frequency);
|
||||
u32 this_err = MAX(dot, target_frequency) -
|
||||
MIN(dot, target_frequency);
|
||||
if (this_err < smallest_err) {
|
||||
smallest_err = this_err;
|
||||
pixel_n = candn;
|
||||
@@ -477,7 +478,8 @@ static void gma_init_vga(const struct northbridge_intel_gm45_config *info,
|
||||
u32 p = candp1 * pixel_p2;
|
||||
u32 vco = DIV_ROUND_CLOSEST(BASE_FREQUENCY * m, candn + 2);
|
||||
u32 dot = DIV_ROUND_CLOSEST(vco, p);
|
||||
u32 this_err = ABS(dot - target_frequency);
|
||||
u32 this_err = MAX(dot, target_frequency) -
|
||||
MIN(dot, target_frequency);
|
||||
if (this_err < smallest_err) {
|
||||
smallest_err= this_err;
|
||||
pixel_n = candn;
|
||||
|
Reference in New Issue
Block a user