diff options
author | Yidi Lin <yidilin@chromium.org> | 2023-10-31 17:15:50 +0800 |
---|---|---|
committer | Martin L Roth <gaumless@gmail.com> | 2023-11-04 17:06:42 +0000 |
commit | 2751d2922f7c87a6acf901a0008ac131bf7245db (patch) | |
tree | 283504f4bf98e0b2331c8d8c501dd0abfe280369 /src/northbridge | |
parent | 909c317b2deb184d95c7d289cbe6603e209ed72d (diff) |
Use common GCD function
Change-Id: I30e4b02a9ca6a15c9bc4edcf4143ffa13a21a732
Signed-off-by: Yidi Lin <yidilin@chromium.org>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/78799
Reviewed-by: Yu-Ping Wu <yupingso@google.com>
Reviewed-by: Julius Werner <jwerner@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Eric Lai <ericllai@google.com>
Diffstat (limited to 'src/northbridge')
-rw-r--r-- | src/northbridge/intel/ironlake/quickpath.c | 24 |
1 files changed, 4 insertions, 20 deletions
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 <commonlib/bsd/gcd.h> #include <console/console.h> #include <cpu/intel/model_2065x/model_2065x.h> #include <cpu/x86/msr.h> @@ -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); |