use kernel abs(), remove recursion in gcd() (closes: #2307)
SVN-Revision: 8608
This commit is contained in:
parent
5956d4bfc2
commit
f0715bbde9
@ -99,16 +99,20 @@ EXPORT_SYMBOL(ar7_bus_clock);
|
|||||||
int ar7_dsp_clock = 0;
|
int ar7_dsp_clock = 0;
|
||||||
EXPORT_SYMBOL(ar7_dsp_clock);
|
EXPORT_SYMBOL(ar7_dsp_clock);
|
||||||
|
|
||||||
static int gcd(int x, int y)
|
static int gcd(int a, int b)
|
||||||
{
|
{
|
||||||
if (x > y)
|
int c;
|
||||||
return (x % y) ? gcd(y, x % y) : y;
|
|
||||||
return (y % x) ? gcd(x, y % x) : x;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline int ABS(int x)
|
if ( a < b) {
|
||||||
{
|
c = a;
|
||||||
return (x >= 0) ? x : -x;
|
a = b;
|
||||||
|
b = c;
|
||||||
|
}
|
||||||
|
while (c = (a % b)) {
|
||||||
|
a = b;
|
||||||
|
b = c;
|
||||||
|
}
|
||||||
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void approximate(int base, int target, int *prediv,
|
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 (i = 1; i <= 16; i++) {
|
||||||
for (j = 1; j <= 32; j++) {
|
for (j = 1; j <= 32; j++) {
|
||||||
for (k = 1; k <= 32; k++) {
|
for (k = 1; k <= 32; k++) {
|
||||||
freq = ABS(base / j * i / k - target);
|
freq = abs(base / j * i / k - target);
|
||||||
if (freq < res) {
|
if (freq < res) {
|
||||||
res = freq;
|
res = freq;
|
||||||
*mul = i;
|
*mul = i;
|
||||||
|
Loading…
Reference in New Issue
Block a user