From 2751d2922f7c87a6acf901a0008ac131bf7245db Mon Sep 17 00:00:00 2001 From: Yidi Lin Date: Tue, 31 Oct 2023 17:15:50 +0800 Subject: Use common GCD function Change-Id: I30e4b02a9ca6a15c9bc4edcf4143ffa13a21a732 Signed-off-by: Yidi Lin Reviewed-on: https://review.coreboot.org/c/coreboot/+/78799 Reviewed-by: Yu-Ping Wu Reviewed-by: Julius Werner Tested-by: build bot (Jenkins) Reviewed-by: Eric Lai --- src/northbridge/intel/ironlake/quickpath.c | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) (limited to 'src/northbridge') diff --git a/src/northbridge/intel/ironlake/quickpath.c b/src/northbridge/intel/ironlake/quickpath.c index 8a0e01cab7..eb79347875 100644 --- a/src/northbridge/intel/ironlake/quickpath.c +++ b/src/northbridge/intel/ironlake/quickpath.c @@ -1,5 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-only */ +#include #include #include #include @@ -11,31 +12,14 @@ #define NORTHBRIDGE PCI_DEV(0, 0, 0) -static unsigned int gcd(unsigned int a, unsigned int b) -{ - unsigned int t; - if (a > b) { - t = a; - a = b; - b = t; - } - /* invariant a < b. */ - while (a) { - t = b % a; - b = a; - a = t; - } - return b; -} - static inline int div_roundup(int a, int b) { return DIV_ROUND_UP(a, b); } -static unsigned int lcm(unsigned int a, unsigned int b) +static u32 lcm(u32 a, u32 b) { - return (a * b) / gcd(a, b); + return (a * b) / gcd32(a, b); } struct stru1 { @@ -65,7 +49,7 @@ compute_frequence_ratios(struct raminfo *info, u16 freq1, u16 freq2, int freq_max_reduced; int freq3, freq4; - g = gcd(freq1, freq2); + g = gcd32(freq1, freq2); freq1_reduced = freq1 / g; freq2_reduced = freq2 / g; freq_min_reduced = MIN(freq1_reduced, freq2_reduced); -- cgit v1.2.3