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>
diff --git a/src/northbridge/intel/ironlake/quickpath.c b/src/northbridge/intel/ironlake/quickpath.c
index 8a0e01c..eb79347 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 @@
 	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);