aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux
diff options
context:
space:
mode:
authorNicolas Thill <nico@openwrt.org>2007-09-04 10:44:45 +0000
committerNicolas Thill <nico@openwrt.org>2007-09-04 10:44:45 +0000
commit21580d89a5668568d407af7a728b31bf0d73907d (patch)
tree4ab929dcd4e1d3ecb68e00c1c9de4c0d4ba2991d /target/linux
parent10a876e21d34b2bd114d19f364fa1d738325ceac (diff)
downloadupstream-21580d89a5668568d407af7a728b31bf0d73907d.tar.gz
upstream-21580d89a5668568d407af7a728b31bf0d73907d.tar.bz2
upstream-21580d89a5668568d407af7a728b31bf0d73907d.zip
use kernel abs(), remove recursion in gcd() (closes: #2307)
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@8608 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target/linux')
-rw-r--r--target/linux/ar7-2.6/files/arch/mips/ar7/clock.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/target/linux/ar7-2.6/files/arch/mips/ar7/clock.c b/target/linux/ar7-2.6/files/arch/mips/ar7/clock.c
index f51c641a3d..c7ae09ecd7 100644
--- a/target/linux/ar7-2.6/files/arch/mips/ar7/clock.c
+++ b/target/linux/ar7-2.6/files/arch/mips/ar7/clock.c
@@ -99,16 +99,20 @@ EXPORT_SYMBOL(ar7_bus_clock);
int ar7_dsp_clock = 0;
EXPORT_SYMBOL(ar7_dsp_clock);
-static int gcd(int x, int y)
+static int gcd(int a, int b)
{
- if (x > y)
- return (x % y) ? gcd(y, x % y) : y;
- return (y % x) ? gcd(x, y % x) : x;
-}
+ int c;
-static inline int ABS(int x)
-{
- return (x >= 0) ? x : -x;
+ if ( a < b) {
+ c = a;
+ a = b;
+ b = c;
+ }
+ while (c = (a % b)) {
+ a = b;
+ b = c;
+ }
+ return b;
}
static void approximate(int base, int target, int *prediv,
@@ -118,7 +122,7 @@ static void approximate(int base, int target, int *prediv,
for (i = 1; i <= 16; i++) {
for (j = 1; j <= 32; j++) {
for (k = 1; k <= 32; k++) {
- freq = ABS(base / j * i / k - target);
+ freq = abs(base / j * i / k - target);
if (freq < res) {
res = freq;
*mul = i;