Strange arch/mips/delay.c

From: Loïc Grenié
Date: Sat Aug 01 2009 - 13:37:26 EST


I could not compile for mips without something similar to the
following patch. As far as I can say __udelay and __ndelay
are costly nops (with __ndelay not compiling at all) without
the patch.

At that point, it might be interesting to change
the 0x00000005uLL by 0x00000045uLL and the >> 32
by >> 36 (the precision is much better and the cost
should be the same -- obviously there is a slightly higher
risk of overlow).

Thanks,

Loïc Grenié

Signed-off-by: Loic Grenie <loic.grenie@xxxxxxxxx>

--- a/arch/mips/lib/delay.c
+++ b/arch/mips/lib/delay.c
@@ -43,7 +43,7 @@ void __udelay(unsigned long us)
{
unsigned int lpj = current_cpu_data.udelay_val;

- __delay((us * 0x000010c7 * HZ * lpj) >> 32);
+ __delay((us * 0x000010c7uLL * HZ * lpj) >> 32);
}
EXPORT_SYMBOL(__udelay);

@@ -51,6 +51,6 @@ void __ndelay(unsigned long ns)
{
unsigned int lpj = current_cpu_data.udelay_val;

- __delay((us * 0x00000005 * HZ * lpj) >> 32);
+ __delay((ns * 0x00000005uLL * HZ * lpj) >> 32);
}
EXPORT_SYMBOL(__ndelay);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/