Skip to contentSkip to conversation

delay: s/#include <asm/delay.h>/#include <linux/delay.h>/

PATCH In review Denis Vlasenko 2 participants 5 messages Sep 22, 2006 1 message not in the archive

Subsystems (14)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 1/3 delay: s/#include <asm/delay.h>/#include <linux/delay.h>/

A few arch files won't see the definition of udelay() in asm/delay.h anymore. Prevent that from biting us later.

--
vda

arch/alpha/kernel/core_t2.c +1 -1
diff -urpN linux-2.6.18/arch/alpha/kernel/core_t2.c linux-2.6.18.new.1/arch/alpha/kernel/core_t2.c
@@ -18,9 +18,9 @@
 #include <linux/pci.h>
 #include <linux/sched.h>
 #include <linux/init.h>
+#include <linux/delay.h>
 
 #include <asm/ptrace.h>
-#include <asm/delay.h>
 
 #include "proto.h"
 #include "pci_impl.h"
arch/arm/mach-integrator/platsmp.c +1 -1
diff -urpN linux-2.6.18/arch/arm/mach-integrator/platsmp.c linux-2.6.18.new.1/arch/arm/mach-integrator/platsmp.c
@@ -13,10 +13,10 @@
 #include <linux/sched.h>
 #include <linux/errno.h>
 #include <linux/mm.h>
+#include <linux/delay.h>
 
 #include <asm/atomic.h>
 #include <asm/cacheflush.h>
-#include <asm/delay.h>
 #include <asm/mmu_context.h>
 #include <asm/procinfo.h>
 #include <asm/ptrace.h>
arch/arm/mach-omap2/board-h4.c +1 -1
diff -urpN linux-2.6.18/arch/arm/mach-omap2/board-h4.c linux-2.6.18.new.1/arch/arm/mach-omap2/board-h4.c
@@ -19,6 +19,7 @@
 #include <linux/delay.h>
 #include <linux/workqueue.h>
 #include <linux/input.h>
+#include <linux/delay.h>
 
 #include <asm/hardware.h>
 #include <asm/mach-types.h>
@@ -39,7 +40,6 @@
 #include "prcm-regs.h"
 
 #include <asm/io.h>
-#include <asm/delay.h>
 
 static unsigned int row_gpios[6] = { 88, 89, 124, 11, 6, 96 };
 static unsigned int col_gpios[7] = { 90, 91, 100, 36, 12, 97, 98 };
arch/arm/plat-omap/mcbsp.c +1 -1
diff -urpN linux-2.6.18/arch/arm/plat-omap/mcbsp.c linux-2.6.18.new.1/arch/arm/plat-omap/mcbsp.c
@@ -20,8 +20,8 @@
 #include <linux/interrupt.h>
 #include <linux/err.h>
 #include <linux/clk.h>
+#include <linux/delay.h>
 
-#include <asm/delay.h>
 #include <asm/io.h>
 #include <asm/irq.h>
 
arch/cris/arch-v10/drivers/i2c.c +1 -1
diff -urpN linux-2.6.18/arch/cris/arch-v10/drivers/i2c.c linux-2.6.18.new.1/arch/cris/arch-v10/drivers/i2c.c
@@ -96,13 +96,13 @@
 #include <linux/fs.h>
 #include <linux/string.h>
 #include <linux/init.h>
+#include <linux/delay.h>
 
 #include <asm/etraxi2c.h>
 
 #include <asm/system.h>
 #include <asm/arch/svinto.h>
 #include <asm/io.h>
-#include <asm/delay.h>
 #include <asm/arch/io_interface_mux.h>
 
 #include "i2c.h"
arch/cris/arch-v32/drivers/i2c.c +1 -1
diff -urpN linux-2.6.18/arch/cris/arch-v32/drivers/i2c.c linux-2.6.18.new.1/arch/cris/arch-v32/drivers/i2c.c
@@ -33,12 +33,12 @@
 #include <linux/fs.h>
 #include <linux/string.h>
 #include <linux/init.h>
+#include <linux/delay.h>
 
 #include <asm/etraxi2c.h>
 
 #include <asm/system.h>
 #include <asm/io.h>
-#include <asm/delay.h>
 
 #include "i2c.h"
 
arch/cris/arch-v32/kernel/smp.c +1 -1
diff -urpN linux-2.6.18/arch/cris/arch-v32/kernel/smp.c linux-2.6.18.new.1/arch/cris/arch-v32/kernel/smp.c
@@ -1,4 +1,3 @@
-#include <asm/delay.h>
 #include <asm/arch/irq.h>
 #include <asm/arch/hwregs/intr_vect.h>
 #include <asm/arch/hwregs/intr_vect_defs.h>
@@ -8,6 +7,7 @@
 #include <asm/arch/hwregs/supp_reg.h>
 #include <asm/atomic.h>
 
+#include <linux/delay.h>
 #include <linux/err.h>
 #include <linux/init.h>
 #include <linux/timex.h>
arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c +1 -1
diff -urpN linux-2.6.18/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c linux-2.6.18.new.1/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c
@@ -32,8 +32,8 @@
 #include <linux/seq_file.h>
 #include <linux/compiler.h>
 #include <linux/sched.h>	/* current */
+#include <linux/delay.h>
 #include <asm/io.h>
-#include <asm/delay.h>
 #include <asm/uaccess.h>
 
 #include <linux/acpi.h>
arch/i386/kernel/cpu/cpufreq/powernow-k8.c +1 -1
diff -urpN linux-2.6.18/arch/i386/kernel/cpu/cpufreq/powernow-k8.c linux-2.6.18.new.1/arch/i386/kernel/cpu/cpufreq/powernow-k8.c
@@ -33,10 +33,10 @@
 #include <linux/string.h>
 #include <linux/cpumask.h>
 #include <linux/sched.h>	/* for current / set_cpus_allowed() */
+#include <linux/delay.h>
 
 #include <asm/msr.h>
 #include <asm/io.h>
-#include <asm/delay.h>
 
 #ifdef CONFIG_X86_POWERNOW_K8_ACPI
 #include <linux/acpi.h>
arch/i386/kernel/i8259.c +1 -1
diff -urpN linux-2.6.18/arch/i386/kernel/i8259.c linux-2.6.18.new.1/arch/i386/kernel/i8259.c
@@ -10,6 +10,7 @@
 #include <linux/kernel_stat.h>
 #include <linux/sysdev.h>
 #include <linux/bitops.h>
+#include <linux/delay.h>
 
 #include <asm/8253pit.h>
 #include <asm/atomic.h>
@@ -17,7 +18,6 @@
 #include <asm/io.h>
 #include <asm/timer.h>
 #include <asm/pgtable.h>
-#include <asm/delay.h>
 #include <asm/desc.h>
 #include <asm/apic.h>
 #include <asm/arch_hooks.h>
arch/i386/kernel/reboot_fixups.c +1 -1
diff -urpN linux-2.6.18/arch/i386/kernel/reboot_fixups.c linux-2.6.18.new.1/arch/i386/kernel/reboot_fixups.c
@@ -8,7 +8,7 @@
  *
  */
 
-#include <asm/delay.h>
+#include <linux/delay.h>
 #include <linux/pci.h>
 #include <linux/reboot_fixups.h>
 
arch/i386/lib/delay.c +0 -1
diff -urpN linux-2.6.18/arch/i386/lib/delay.c linux-2.6.18.new.1/arch/i386/lib/delay.c
@@ -16,7 +16,6 @@
 #include <linux/delay.h>
 
 #include <asm/processor.h>
-#include <asm/delay.h>
 #include <asm/timer.h>
 
 #ifdef CONFIG_SMP
arch/ia64/kernel/mca.c +1 -1
diff -urpN linux-2.6.18/arch/ia64/kernel/mca.c linux-2.6.18.new.1/arch/ia64/kernel/mca.c
@@ -69,8 +69,8 @@
 #include <linux/smp.h>
 #include <linux/workqueue.h>
 #include <linux/cpumask.h>
+#include <linux/delay.h>
 
-#include <asm/delay.h>
 #include <asm/kdebug.h>
 #include <asm/machvec.h>
 #include <asm/meminit.h>
arch/ia64/kernel/smpboot.c +1 -1
diff -urpN linux-2.6.18/arch/ia64/kernel/smpboot.c linux-2.6.18.new.1/arch/ia64/kernel/smpboot.c
@@ -40,11 +40,11 @@
 #include <linux/efi.h>
 #include <linux/percpu.h>
 #include <linux/bitops.h>
+#include <linux/delay.h>
 
 #include <asm/atomic.h>
 #include <asm/cache.h>
 #include <asm/current.h>
-#include <asm/delay.h>
 #include <asm/ia32.h>
 #include <asm/io.h>
 #include <asm/irq.h>
arch/mips/galileo-boards/ev96100/setup.c +1 -1
diff -urpN linux-2.6.18/arch/mips/galileo-boards/ev96100/setup.c linux-2.6.18.new.1/arch/mips/galileo-boards/ev96100/setup.c
@@ -38,12 +38,12 @@
 #include <linux/string.h>
 #include <linux/ctype.h>
 #include <linux/pci.h>
+#include <linux/delay.h>
 
 #include <asm/cpu.h>
 #include <asm/bootinfo.h>
 #include <asm/mipsregs.h>
 #include <asm/irq.h>
-#include <asm/delay.h>
 #include <asm/gt64120.h>
 #include <asm/galileo-boards/ev96100int.h>
 
arch/mips/pci/ops-gt96100.c +1 -1
diff -urpN linux-2.6.18/arch/mips/pci/ops-gt96100.c linux-2.6.18.new.1/arch/mips/pci/ops-gt96100.c
@@ -37,8 +37,8 @@
 #include <linux/pci.h>
 #include <linux/kernel.h>
 #include <linux/init.h>
+#include <linux/delay.h>
 
-#include <asm/delay.h>
 #include <asm/gt64120.h>
 #include <asm/galileo-boards/ev96100.h>
 
arch/parisc/kernel/smp.c +1 -1
diff -urpN linux-2.6.18/arch/parisc/kernel/smp.c linux-2.6.18.new.1/arch/parisc/kernel/smp.c
@@ -33,11 +33,11 @@
 #include <linux/mm.h>
 #include <linux/delay.h>
 #include <linux/bitops.h>
+#include <linux/delay.h>
 
 #include <asm/system.h>
 #include <asm/atomic.h>
 #include <asm/current.h>
-#include <asm/delay.h>
 #include <asm/tlbflush.h>
 
 #include <asm/io.h>
arch/powerpc/kernel/rtas.c +0 -1
diff -urpN linux-2.6.18/arch/powerpc/kernel/rtas.c linux-2.6.18.new.1/arch/powerpc/kernel/rtas.c
@@ -29,7 +29,6 @@
 #include <asm/page.h>
 #include <asm/param.h>
 #include <asm/system.h>
-#include <asm/delay.h>
 #include <asm/uaccess.h>
 #include <asm/lmb.h>
 #include <asm/udbg.h>
arch/powerpc/kernel/rtas_flash.c +1 -1
diff -urpN linux-2.6.18/arch/powerpc/kernel/rtas_flash.c linux-2.6.18.new.1/arch/powerpc/kernel/rtas_flash.c
@@ -16,7 +16,7 @@
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/proc_fs.h>
-#include <asm/delay.h>
+#include <linux/delay.h>
 #include <asm/uaccess.h>
 #include <asm/rtas.h>
 #include <asm/abs_addr.h>
arch/ppc/platforms/mpc885ads_setup.c +1 -1
diff -urpN linux-2.6.18/arch/ppc/platforms/mpc885ads_setup.c linux-2.6.18.new.1/arch/ppc/platforms/mpc885ads_setup.c
@@ -17,12 +17,12 @@
 #include <linux/string.h>
 #include <linux/ioport.h>
 #include <linux/device.h>
+#include <linux/delay.h>
 
 #include <linux/fs_enet_pd.h>
 #include <linux/fs_uart_pd.h>
 #include <linux/mii.h>
 
-#include <asm/delay.h>
 #include <asm/io.h>
 #include <asm/machdep.h>
 #include <asm/page.h>
arch/ppc/syslib/mpc52xx_pci.c +1 -1
diff -urpN linux-2.6.18/arch/ppc/syslib/mpc52xx_pci.c linux-2.6.18.new.1/arch/ppc/syslib/mpc52xx_pci.c
@@ -11,13 +11,13 @@
  * kind, whether express or implied.
  */
 
+#include <linux/delay.h>
 
 #include <asm/pci.h>
 
 #include <asm/mpc52xx.h>
 #include "mpc52xx_pci.h"
 
-#include <asm/delay.h>
 #include <asm/machdep.h>
 
 
arch/ppc/syslib/mv64x60_dbg.c +1 -1
diff -urpN linux-2.6.18/arch/ppc/syslib/mv64x60_dbg.c linux-2.6.18.new.1/arch/ppc/syslib/mv64x60_dbg.c
@@ -19,7 +19,7 @@
 
 
 #include <linux/irq.h>
-#include <asm/delay.h>
+#include <linux/delay.h>
 #include <asm/mv64x60.h>
 #include <asm/machdep.h>
 
arch/ppc/syslib/ppc83xx_setup.c +1 -1
diff -urpN linux-2.6.18/arch/ppc/syslib/ppc83xx_setup.c linux-2.6.18.new.1/arch/ppc/syslib/ppc83xx_setup.c
@@ -30,13 +30,13 @@
 #include <linux/tty.h>	/* for linux/serial_core.h */
 #include <linux/serial_core.h>
 #include <linux/serial_8250.h>
+#include <linux/delay.h>
 
 #include <asm/time.h>
 #include <asm/mpc83xx.h>
 #include <asm/mmu.h>
 #include <asm/ppc_sys.h>
 #include <asm/kgdb.h>
-#include <asm/delay.h>
 #include <asm/machdep.h>
 
 #include <syslib/ppc83xx_setup.h>
arch/sparc/kernel/process.c +1 -1
diff -urpN linux-2.6.18/arch/sparc/kernel/process.c linux-2.6.18.new.1/arch/sparc/kernel/process.c
@@ -28,6 +28,7 @@
 #include <linux/delay.h>
 #include <linux/pm.h>
 #include <linux/init.h>
+#include <linux/delay.h>
 
 #include <asm/auxio.h>
 #include <asm/oplib.h>
@@ -36,7 +37,6 @@
 #include <asm/page.h>
 #include <asm/pgalloc.h>
 #include <asm/pgtable.h>
-#include <asm/delay.h>
 #include <asm/processor.h>
 #include <asm/psr.h>
 #include <asm/elf.h>
arch/sparc/kernel/sun4d_smp.c +1 -1
diff -urpN linux-2.6.18/arch/sparc/kernel/sun4d_smp.c linux-2.6.18.new.1/arch/sparc/kernel/sun4d_smp.c
@@ -20,11 +20,11 @@
 #include <linux/mm.h>
 #include <linux/swap.h>
 #include <linux/profile.h>
+#include <linux/delay.h>
 
 #include <asm/ptrace.h>
 #include <asm/atomic.h>
 
-#include <asm/delay.h>
 #include <asm/irq.h>
 #include <asm/page.h>
 #include <asm/pgalloc.h>
arch/sparc/kernel/sun4m_smp.c +1 -1
diff -urpN linux-2.6.18/arch/sparc/kernel/sun4m_smp.c linux-2.6.18.new.1/arch/sparc/kernel/sun4m_smp.c
@@ -17,13 +17,13 @@
 #include <linux/mm.h>
 #include <linux/swap.h>
 #include <linux/profile.h>
+#include <linux/delay.h>
 #include <asm/cacheflush.h>
 #include <asm/tlbflush.h>
 
 #include <asm/ptrace.h>
 #include <asm/atomic.h>
 
-#include <asm/delay.h>
 #include <asm/irq.h>
 #include <asm/page.h>
 #include <asm/pgalloc.h>
arch/x86_64/kernel/i8259.c +1 -1
diff -urpN linux-2.6.18/arch/x86_64/kernel/i8259.c linux-2.6.18.new.1/arch/x86_64/kernel/i8259.c
@@ -12,6 +12,7 @@
 #include <linux/kernel_stat.h>
 #include <linux/sysdev.h>
 #include <linux/bitops.h>
+#include <linux/delay.h>
 
 #include <asm/acpi.h>
 #include <asm/atomic.h>
@@ -19,7 +20,6 @@
 #include <asm/io.h>
 #include <asm/hw_irq.h>
 #include <asm/pgtable.h>
-#include <asm/delay.h>
 #include <asm/desc.h>
 #include <asm/apic.h>
 
arch/x86_64/kernel/reboot.c +1 -1
diff -urpN linux-2.6.18/arch/x86_64/kernel/reboot.c linux-2.6.18.new.1/arch/x86_64/kernel/reboot.c
@@ -7,9 +7,9 @@
 #include <linux/ctype.h>
 #include <linux/string.h>
 #include <linux/pm.h>
+#include <linux/delay.h>
 #include <asm/io.h>
 #include <asm/kdebug.h>
-#include <asm/delay.h>
 #include <asm/hw_irq.h>
 #include <asm/system.h>
 #include <asm/pgtable.h>
arch/x86_64/lib/delay.c +1 -1
diff -urpN linux-2.6.18/arch/x86_64/lib/delay.c linux-2.6.18.new.1/arch/x86_64/lib/delay.c
@@ -12,7 +12,7 @@
 #include <linux/module.h>
 #include <linux/sched.h>
 #include <linux/delay.h>
-#include <asm/delay.h>
+#include <linux/delay.h>
 #include <asm/msr.h>
 
 #ifdef CONFIG_SMP
#2 lore raw

PATCH 2/3 delay: remove references to MAX_UDELAY_MS; fix comment

We are going to kill MAX_UDELAY_MS, so replace it in common code with 1. Also fix a buglet on the way:
mpc83xx_spi->nsecs > MAX_UDELAY_MS * 1000 was comparing nanoseconds to microseconds.

--
vda

drivers/scsi/ipr.c +1 -5
diff -urpN linux-2.6.18.new.1/drivers/scsi/ipr.c linux-2.6.18.new.2/drivers/scsi/ipr.c
@@ -1596,11 +1596,7 @@ static int ipr_wait_iodbg_ack(struct ipr
 		if (pcii_reg & IPR_PCII_IO_DEBUG_ACKNOWLEDGE)
 			return 0;
 
-		/* udelay cannot be used if delay is more than a few milliseconds */
-		if ((delay / 1000) > MAX_UDELAY_MS)
-			mdelay(delay / 1000);
-		else
-			udelay(delay);
+		udelay(delay);
 
 		delay += delay;
 	}
drivers/spi/spi_bitbang.c +1 -1
diff -urpN linux-2.6.18.new.1/drivers/spi/spi_bitbang.c linux-2.6.18.new.2/drivers/spi/spi_bitbang.c
@@ -168,7 +168,7 @@ int spi_bitbang_setup_transfer(struct sp
 		hz = spi->max_speed_hz;
 	if (hz) {
 		cs->nsecs = (1000000000/2) / hz;
-		if (cs->nsecs > (MAX_UDELAY_MS * 1000 * 1000))
+		if (cs->nsecs > (1000 * 1000))
 			return -EINVAL;
 	}
 
drivers/spi/spi_mpc83xx.c +1 -1
diff -urpN linux-2.6.18.new.1/drivers/spi/spi_mpc83xx.c linux-2.6.18.new.2/drivers/spi/spi_mpc83xx.c
@@ -211,7 +211,7 @@ int mpc83xx_spi_setup_transfer(struct sp
 	if (!hz)
 		hz = spi->max_speed_hz;
 	mpc83xx_spi->nsecs = (1000000000 / 2) / hz;
-	if (mpc83xx_spi->nsecs > MAX_UDELAY_MS * 1000)
+	if (mpc83xx_spi->nsecs > (1000 * 1000))
 		return -EINVAL;
 
 	if (bits_per_word == 32)
include/asm-parisc/delay.h +2 -3
diff -urpN linux-2.6.18.new.1/include/asm-parisc/delay.h linux-2.6.18.new.2/include/asm-parisc/delay.h
@@ -24,9 +24,8 @@ static __inline__ void __cr16_delay(unsi
 
 	/*
 	 * Note: Due to unsigned math, cr16 rollovers shouldn't be
-	 * a problem here. However, on 32 bit, we need to make sure
-	 * we don't pass in too big a value. The current default
-	 * value of MAX_UDELAY_MS should help prevent this.
+	 * a problem here. On 32 bit, we are protected in udelay()
+	 * from passing in too big a value.
 	 */
 
 	start = mfctl(16);
#3 lore raw

PATCH 3/3 delay: add generic udelay(), mdelay() and ssleep()

This patch does the following:
* make it so than asm/delay.h does not define udelay(), only __udelay(), to be used in generic udelay()
* add generic udelay() which calls __udelay() repeatedly as needed. Protect against overflow in udelay() argument.
* similarly for mdelay() and ssleep()
* __const_udelay for all arches is removed or renamed to __const_delay (it did not do microsecond delays anyway) if still used by arch ndelay() function/macro
* remove EXPORT_SYMBOL(__udelay). It is not used in modules anymore
* remove MAX_UDELAY_MS

We specifically do not touch ndelay() in these patches.

--
vda

arch/arm/kernel/armksyms.c +0 -4
diff -urpN linux-2.6.18.new.2/arch/arm/kernel/armksyms.c linux-2.6.18.new.3/arch/arm/kernel/armksyms.c
@@ -70,10 +70,6 @@ EXPORT_SYMBOL_ALIAS(fp_send_sig,send_sig
 
 EXPORT_SYMBOL(__backtrace);
 
-	/* platform dependent support */
-EXPORT_SYMBOL(__udelay);
-EXPORT_SYMBOL(__const_udelay);
-
 	/* networking */
 EXPORT_SYMBOL(csum_partial);
 EXPORT_SYMBOL(csum_partial_copy_nocheck);
arch/arm/lib/delay.S +1 -1
diff -urpN linux-2.6.18.new.2/arch/arm/lib/delay.S linux-2.6.18.new.3/arch/arm/lib/delay.S
@@ -24,7 +24,7 @@
 ENTRY(__udelay)
 		ldr	r2, .LC1
 		mul	r0, r2, r0
-ENTRY(__const_udelay)				@ 0 <= r0 <= 0x7fffff06
+						@ 0 <= r0 <= 0x7fffff06
 		ldr	r2, .LC0
 		ldr	r2, [r2]		@ max = 0x01ffffff
 		mov	r0, r0, lsr #14		@ max = 0x0001ffff
arch/i386/lib/delay.c +5 -5
diff -urpN linux-2.6.18.new.2/arch/i386/lib/delay.c linux-2.6.18.new.3/arch/i386/lib/delay.c
@@ -74,7 +74,8 @@ void __delay(unsigned long loops)
 	delay_fn(loops);
 }
 
-inline void __const_udelay(unsigned long xloops)
+/* cannot be static: ndelay macro needs it */
+inline void __const_delay(unsigned long xloops)
 {
 	int d0;
 
@@ -89,15 +90,14 @@ inline void __const_udelay(unsigned long
 
 void __udelay(unsigned long usecs)
 {
-	__const_udelay(usecs * 0x000010c7); /* 2**32 / 1000000 (rounded up) */
+	__const_delay(usecs * 0x000010c7); /* 2**32 / 1000000 (rounded up) */
 }
 
 void __ndelay(unsigned long nsecs)
 {
-	__const_udelay(nsecs * 0x00005); /* 2**32 / 1000000000 (rounded up) */
+	__const_delay(nsecs * 0x00005); /* 2**32 / 1000000000 (rounded up) */
 }
 
 EXPORT_SYMBOL(__delay);
-EXPORT_SYMBOL(__const_udelay);
-EXPORT_SYMBOL(__udelay);
+EXPORT_SYMBOL(__const_delay);
 EXPORT_SYMBOL(__ndelay);
arch/m32r/kernel/m32r_ksyms.c +0 -2
diff -urpN linux-2.6.18.new.2/arch/m32r/kernel/m32r_ksyms.c linux-2.6.18.new.3/arch/m32r/kernel/m32r_ksyms.c
@@ -30,9 +30,7 @@ EXPORT_SYMBOL(__down_trylock);
 
 /* Networking helper routines. */
 /* Delay loops */
-EXPORT_SYMBOL(__udelay);
 EXPORT_SYMBOL(__delay);
-EXPORT_SYMBOL(__const_udelay);
 
 EXPORT_SYMBOL(strncpy_from_user);
 EXPORT_SYMBOL(__strncpy_from_user);
arch/m32r/lib/delay.c +3 -3
diff -urpN linux-2.6.18.new.2/arch/m32r/lib/delay.c linux-2.6.18.new.3/arch/m32r/lib/delay.c
@@ -57,7 +57,7 @@ void __delay(unsigned long loops)
 #endif
 }
 
-void __const_udelay(unsigned long xloops)
+void __const_delay(unsigned long xloops)
 {
 #if defined(CONFIG_ISA_M32R2) && defined(CONFIG_ISA_DSP_LEVEL2)
 	/*
@@ -116,10 +116,10 @@ void __const_udelay(unsigned long xloops
 
 void __udelay(unsigned long usecs)
 {
-	__const_udelay(usecs * 0x000010c7);  /* 2**32 / 1000000 (rounded up) */
+	__const_delay(usecs * 0x000010c7);  /* 2**32 / 1000000 (rounded up) */
 }
 
 void __ndelay(unsigned long nsecs)
 {
-	__const_udelay(nsecs * 0x00005);  /* 2**32 / 1000000000 (rounded up) */
+	__const_delay(nsecs * 0x00005);  /* 2**32 / 1000000000 (rounded up) */
 }
arch/m68knommu/lib/delay.c +0 -21
diff -urpN linux-2.6.18.new.2/arch/m68knommu/lib/delay.c linux-2.6.18.new.3/arch/m68knommu/lib/delay.c
@@ -1,21 +0,0 @@
-/*
- *	arch/m68knommu/lib/delay.c
- *
- *	(C) Copyright 2004, Greg Ungerer <[email protected]>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-#include <linux/module.h>
-#include <asm/param.h>
-#include <asm/delay.h>
-
-EXPORT_SYMBOL(udelay);
-
-void udelay(unsigned long usecs)
-{
-	_udelay(usecs);
-}
-
arch/m68knommu/lib/Makefile +1 -1
diff -urpN linux-2.6.18.new.2/arch/m68knommu/lib/Makefile linux-2.6.18.new.3/arch/m68knommu/lib/Makefile
@@ -4,4 +4,4 @@
 
 lib-y	:= ashldi3.o ashrdi3.o lshrdi3.o \
 	   muldi3.o mulsi3.o divsi3.o udivsi3.o modsi3.o umodsi3.o \
-	   checksum.o semaphore.o memcpy.o memset.o delay.o
+	   checksum.o semaphore.o memcpy.o memset.o
arch/powerpc/kernel/time.c +2 -2
diff -urpN linux-2.6.18.new.2/arch/powerpc/kernel/time.c linux-2.6.18.new.3/arch/powerpc/kernel/time.c
@@ -368,11 +368,11 @@ void __delay(unsigned long loops)
 }
 EXPORT_SYMBOL(__delay);
 
-void udelay(unsigned long usecs)
+void __udelay(unsigned long usecs)
 {
 	__delay(tb_ticks_per_usec * usecs);
 }
-EXPORT_SYMBOL(udelay);
+EXPORT_SYMBOL(__udelay);
 
 static __inline__ void timer_check_rtc(void)
 {
arch/sh/kernel/sh_ksyms.c +1 -2
diff -urpN linux-2.6.18.new.2/arch/sh/kernel/sh_ksyms.c linux-2.6.18.new.3/arch/sh/kernel/sh_ksyms.c
@@ -71,9 +71,8 @@ EXPORT_SYMBOL(__up);
 EXPORT_SYMBOL(__down);
 EXPORT_SYMBOL(__down_interruptible);
 
-EXPORT_SYMBOL(__udelay);
 EXPORT_SYMBOL(__ndelay);
-EXPORT_SYMBOL(__const_udelay);
+EXPORT_SYMBOL(__const_delay);
 
 EXPORT_SYMBOL(__div64_32);
 
arch/sh/lib/delay.c +4 -4
diff -urpN linux-2.6.18.new.2/arch/sh/lib/delay.c linux-2.6.18.new.3/arch/sh/lib/delay.c
@@ -19,7 +19,8 @@ void __delay(unsigned long loops)
 		: "t");
 }
 
-inline void __const_udelay(unsigned long xloops)
+/* cannot be static: ndelay macro needs it */
+inline void __const_delay(unsigned long xloops)
 {
 	__asm__("dmulu.l	%0, %2\n\t"
 		"sts	mach, %0"
@@ -31,11 +32,10 @@ inline void __const_udelay(unsigned long
 
 void __udelay(unsigned long usecs)
 {
-	__const_udelay(usecs * 0x000010c6);  /* 2**32 / 1000000 */
+	__const_delay(usecs * 0x000010c6);  /* 2**32 / 1000000 */
 }
 
 void __ndelay(unsigned long nsecs)
 {
-	__const_udelay(nsecs * 0x00000005);
+	__const_delay(nsecs * 0x00000005);
 }
-
arch/sh64/lib/udelay.c +5 -6
diff -urpN linux-2.6.18.new.2/arch/sh64/lib/udelay.c linux-2.6.18.new.3/arch/sh64/lib/udelay.c
@@ -35,25 +35,24 @@ void __delay(int loops)
 			     :"0"(loops));
 }
 
-void __udelay(unsigned long long usecs, unsigned long lpj)
+static inline void __arch_udelay(unsigned long long usecs, unsigned long lpj)
 {
 	usecs *= (((unsigned long long) HZ << 32) / 1000000) * lpj;
 	__delay((long long) usecs >> 32);
 }
 
-void __ndelay(unsigned long long nsecs, unsigned long lpj)
+static inline void __arch_ndelay(unsigned long long nsecs, unsigned long lpj)
 {
 	nsecs *= (((unsigned long long) HZ << 32) / 1000000000) * lpj;
 	__delay((long long) nsecs >> 32);
 }
 
-void udelay(unsigned long usecs)
+void __udelay(unsigned long usecs)
 {
-	__udelay(usecs, loops_per_jiffy);
+	__arch_udelay(usecs, loops_per_jiffy);
 }
 
 void ndelay(unsigned long nsecs)
 {
-	__ndelay(nsecs, loops_per_jiffy);
+	__arch_ndelay(nsecs, loops_per_jiffy);
 }
-
arch/sparc64/kernel/sparc64_ksyms.c +1 -1
diff -urpN linux-2.6.18.new.2/arch/sparc64/kernel/sparc64_ksyms.c linux-2.6.18.new.3/arch/sparc64/kernel/sparc64_ksyms.c
@@ -334,7 +334,7 @@ EXPORT_SYMBOL(strncmp);
 /* Delay routines. */
 EXPORT_SYMBOL(__udelay);
 EXPORT_SYMBOL(__ndelay);
-EXPORT_SYMBOL(__const_udelay);
+EXPORT_SYMBOL(__const_delay);
 EXPORT_SYMBOL(__delay);
 
 void VISenter(void);
arch/sparc64/lib/delay.c +3 -3
diff -urpN linux-2.6.18.new.2/arch/sparc64/lib/delay.c linux-2.6.18.new.3/arch/sparc64/lib/delay.c
@@ -24,7 +24,7 @@ void __delay(unsigned long loops)
  * but that runs into problems for higher values of HZ and
  * slow cpus.
  */
-void __const_udelay(unsigned long n)
+void __const_delay(unsigned long n)
 {
 	n *= 4;
 
@@ -36,11 +36,11 @@ void __const_udelay(unsigned long n)
 
 void __udelay(unsigned long n)
 {
-	__const_udelay(n * 0x10c7UL);
+	__const_delay(n * 0x10c7UL);
 }
 
 
 void __ndelay(unsigned long n)
 {
-	__const_udelay(n * 0x5UL);
+	__const_delay(n * 0x5UL);
 }
arch/um/sys-i386/delay.c +0 -13
diff -urpN linux-2.6.18.new.2/arch/um/sys-i386/delay.c linux-2.6.18.new.3/arch/um/sys-i386/delay.c
@@ -25,16 +25,3 @@ void __udelay(unsigned long usecs)
         for(i=0;i<n;i++)
                 cpu_relax();
 }
-
-EXPORT_SYMBOL(__udelay);
-
-void __const_udelay(unsigned long usecs)
-{
-	int i, n;
-
-	n = (loops_per_jiffy * HZ * usecs) / MILLION;
-        for(i=0;i<n;i++)
-                cpu_relax();
-}
-
-EXPORT_SYMBOL(__const_udelay);
arch/um/sys-x86_64/delay.c +0 -13
diff -urpN linux-2.6.18.new.2/arch/um/sys-x86_64/delay.c linux-2.6.18.new.3/arch/um/sys-x86_64/delay.c
@@ -26,16 +26,3 @@ void __udelay(unsigned long usecs)
         for(i=0;i<n;i++)
                 cpu_relax();
 }
-
-EXPORT_SYMBOL(__udelay);
-
-void __const_udelay(unsigned long usecs)
-{
-	unsigned long i, n;
-
-	n = (loops_per_jiffy * HZ * usecs) / MILLION;
-        for(i=0;i<n;i++)
-                cpu_relax();
-}
-
-EXPORT_SYMBOL(__const_udelay);
arch/x86_64/kernel/functionlist +1 -1
diff -urpN linux-2.6.18.new.2/arch/x86_64/kernel/functionlist linux-2.6.18.new.3/arch/x86_64/kernel/functionlist
@@ -494,7 +494,7 @@
 *(.text.do_setitimer)
 *(.text.dev_queue_xmit_nit)
 *(.text.copy_from_read_buf)
-*(.text.__const_udelay)
+*(.text.__const_delay)
 *(.text.console_conditional_schedule)
 *(.text.wake_up_new_task)
 *(.text.wait_for_completion_interruptible)
arch/x86_64/lib/delay.c +5 -4
diff -urpN linux-2.6.18.new.2/arch/x86_64/lib/delay.c linux-2.6.18.new.3/arch/x86_64/lib/delay.c
@@ -39,20 +39,21 @@ void __delay(unsigned long loops)
 }
 EXPORT_SYMBOL(__delay);
 
-inline void __const_udelay(unsigned long xloops)
+/* cannot be static: ndelay macro needs it */
+inline void __const_delay(unsigned long xloops)
 {
 	__delay((xloops * HZ * cpu_data[raw_smp_processor_id()].loops_per_jiffy) >> 32);
 }
-EXPORT_SYMBOL(__const_udelay);
+EXPORT_SYMBOL(__const_delay);
 
 void __udelay(unsigned long usecs)
 {
-	__const_udelay(usecs * 0x000010c6);  /* 2**32 / 1000000 */
+	__const_delay(usecs * 0x000010c6);  /* 2**32 / 1000000 */
 }
 EXPORT_SYMBOL(__udelay);
 
 void __ndelay(unsigned long nsecs)
 {
-	__const_udelay(nsecs * 0x00005);  /* 2**32 / 1000000000 (rounded up) */
+	__const_delay(nsecs * 0x00005);  /* 2**32 / 1000000000 (rounded up) */
 }
 EXPORT_SYMBOL(__ndelay);
include/asm-arm/delay.h +0 -30
diff -urpN linux-2.6.18.new.2/include/asm-arm/delay.h linux-2.6.18.new.3/include/asm-arm/delay.h
@@ -9,36 +9,6 @@
 #include <asm/param.h>	/* HZ */
 
 extern void __delay(int loops);
-
-/*
- * This function intentionally does not exist; if you see references to
- * it, it means that you're calling udelay() with an out of range value.
- *
- * With currently imposed limits, this means that we support a max delay
- * of 2000us. Further limits: HZ<=1000 and bogomips<=3355
- */
-extern void __bad_udelay(void);
-
-/*
- * division by multiplication: you don't have to worry about
- * loss of precision.
- *
- * Use only for very small delays ( < 1 msec).  Should probably use a
- * lookup table, really, as the multiplications take much too long with
- * short delays.  This is a "reasonable" implementation, though (and the
- * first constant multiplications gets optimized away if the delay is
- * a constant)
- */
 extern void __udelay(unsigned long usecs);
-extern void __const_udelay(unsigned long);
-
-#define MAX_UDELAY_MS 2
-
-#define udelay(n)							\
-	(__builtin_constant_p(n) ?					\
-	  ((n) > (MAX_UDELAY_MS * 1000) ? __bad_udelay() :		\
-			__const_udelay((n) * ((2199023U*HZ)>>11))) :	\
-	  __udelay(n))
 
 #endif /* defined(_ARM_DELAY_H) */
-
include/asm-arm26/delay.h +0 -4
diff -urpN linux-2.6.18.new.2/include/asm-arm26/delay.h linux-2.6.18.new.3/include/asm-arm26/delay.h
@@ -21,14 +21,10 @@ extern void __delay(int loops);
  *
  * FIXME - lets improve it then...
  */
-extern void udelay(unsigned long usecs);
-
 static inline unsigned long muldiv(unsigned long a, unsigned long b, unsigned long c)
 {
 	return a * b / c;
 }
 
-	
-
 #endif /* defined(_ARM_DELAY_H) */
 
include/asm-cris/delay.h +1 -4
diff -urpN linux-2.6.18.new.2/include/asm-cris/delay.h linux-2.6.18.new.3/include/asm-cris/delay.h
@@ -13,12 +13,9 @@
 
 extern unsigned long loops_per_usec; /* arch/cris/mm/init.c */
 
-static inline void udelay(unsigned long usecs)
+static inline void __udelay(unsigned long usecs)
 {
 	__delay(usecs * loops_per_usec);
 }
 
 #endif /* defined(_CRIS_DELAY_H) */
-
-
-
include/asm-frv/delay.h +2 -1
diff -urpN linux-2.6.18.new.2/include/asm-frv/delay.h linux-2.6.18.new.3/include/asm-frv/delay.h
@@ -40,11 +40,12 @@ static inline void __delay(unsigned long
 
 extern unsigned long loops_per_jiffy;
 
-static inline void udelay(unsigned long usecs)
+static inline void __udelay(unsigned long usecs)
 {
 	__delay(usecs * __delay_loops_MHz);
 }
 
+/* FIXME: looks like bug to me: */
 #define ndelay(n)	udelay((n) * 5)
 
 #endif /* _ASM_DELAY_H */
include/asm-h8300/delay.h +1 -1
diff -urpN linux-2.6.18.new.2/include/asm-h8300/delay.h linux-2.6.18.new.3/include/asm-h8300/delay.h
@@ -27,7 +27,7 @@ extern __inline__ void __delay(unsigned 
 
 extern unsigned long loops_per_jiffy;
 
-extern __inline__ void udelay(unsigned long usecs)
+extern __inline__ void __udelay(unsigned long usecs)
 {
 	usecs *= 4295;		/* 2**32 / 1000000 */
 	usecs /= (loops_per_jiffy*HZ);
include/asm-i386/delay.h +2 -7
diff -urpN linux-2.6.18.new.2/include/asm-i386/delay.h linux-2.6.18.new.3/include/asm-i386/delay.h
@@ -7,20 +7,15 @@
  * Delay routines calling functions in arch/i386/lib/delay.c
  */
  
-extern void __bad_udelay(void);
 extern void __bad_ndelay(void);
 
 extern void __udelay(unsigned long usecs);
 extern void __ndelay(unsigned long nsecs);
-extern void __const_udelay(unsigned long usecs);
+extern void __const_delay(unsigned long usecs);
 extern void __delay(unsigned long loops);
 
-#define udelay(n) (__builtin_constant_p(n) ? \
-	((n) > 20000 ? __bad_udelay() : __const_udelay((n) * 0x10c7ul)) : \
-	__udelay(n))
-	
 #define ndelay(n) (__builtin_constant_p(n) ? \
-	((n) > 20000 ? __bad_ndelay() : __const_udelay((n) * 5ul)) : \
+	((n) > 20000 ? __bad_ndelay() : __const_delay((n) * 5ul)) : \
 	__ndelay(n))
 
 void use_tsc_delay(void);
include/asm-ia64/delay.h +0 -2
diff -urpN linux-2.6.18.new.2/include/asm-ia64/delay.h linux-2.6.18.new.3/include/asm-ia64/delay.h
@@ -83,6 +83,4 @@ __delay (unsigned long loops)
 	ia64_delay_loop (loops - 1);
 }
 
-extern void udelay (unsigned long usecs);
-
 #endif /* _ASM_IA64_DELAY_H */
include/asm-m32r/delay.h +2 -7
diff -urpN linux-2.6.18.new.2/include/asm-m32r/delay.h linux-2.6.18.new.3/include/asm-m32r/delay.h
@@ -9,20 +9,15 @@
  * Delay routines calling functions in arch/m32r/lib/delay.c
  */
 
-extern void __bad_udelay(void);
 extern void __bad_ndelay(void);
 
 extern void __udelay(unsigned long usecs);
 extern void __ndelay(unsigned long nsecs);
-extern void __const_udelay(unsigned long usecs);
+extern void __const_delay(unsigned long usecs);
 extern void __delay(unsigned long loops);
 
-#define udelay(n) (__builtin_constant_p(n) ? \
-	((n) > 20000 ? __bad_udelay() : __const_udelay((n) * 0x10c7ul)) : \
-	__udelay(n))
-
 #define ndelay(n) (__builtin_constant_p(n) ? \
-	((n) > 20000 ? __bad_ndelay() : __const_udelay((n) * 5ul)) : \
+	((n) > 20000 ? __bad_ndelay() : __const_delay((n) * 5ul)) : \
 	__ndelay(n))
 
 #endif /* _ASM_M32R_DELAY_H */
include/asm-m68k/delay.h +2 -8
diff -urpN linux-2.6.18.new.2/include/asm-m68k/delay.h linux-2.6.18.new.3/include/asm-m68k/delay.h
@@ -15,8 +15,6 @@ static inline void __delay(unsigned long
 		: "=d" (loops) : "0" (loops));
 }
 
-extern void __bad_udelay(void);
-
 /*
  * Use only for very small delays ( < 1 msec).  Should probably use a
  * lookup table, really, as the multiplications take much too long with
@@ -24,7 +22,7 @@ extern void __bad_udelay(void);
  * first constant multiplications gets optimized away if the delay is
  * a constant)
  */
-static inline void __const_udelay(unsigned long xloops)
+static inline void __const_delay(unsigned long xloops)
 {
 	unsigned long tmp;
 
@@ -36,13 +34,9 @@ static inline void __const_udelay(unsign
 
 static inline void __udelay(unsigned long usecs)
 {
-	__const_udelay(usecs * 4295);	/* 2**32 / 1000000 */
+	__const_delay(usecs * 4295);	/* 2**32 / 1000000 */
 }
 
-#define udelay(n) (__builtin_constant_p(n) ? \
-	((n) > 20000 ? __bad_udelay() : __const_udelay((n) * 4295)) : \
-	__udelay(n))
-
 static inline unsigned long muldiv(unsigned long a, unsigned long b,
 				   unsigned long c)
 {
include/asm-m68knommu/delay.h +1 -9
diff -urpN linux-2.6.18.new.2/include/asm-m68knommu/delay.h linux-2.6.18.new.3/include/asm-m68knommu/delay.h
@@ -48,7 +48,7 @@ static inline void __delay(unsigned long
 
 extern unsigned long loops_per_jiffy;
 
-static inline void _udelay(unsigned long usecs)
+static inline void __udelay(unsigned long usecs)
 {
 #if defined(CONFIG_M68328) || defined(CONFIG_M68EZ328) || \
     defined(CONFIG_M68VZ328) || defined(CONFIG_M68360) || \
@@ -65,12 +65,4 @@ static inline void _udelay(unsigned long
 #endif
 }
 
-/*
- *	Moved the udelay() function into library code, no longer inlined.
- *	I had to change the algorithm because we are overflowing now on
- *	the faster ColdFire parts. The code is a little biger, so it makes
- *	sense to library it.
- */
-extern void udelay(unsigned long usecs);
-
 #endif /* defined(_M68KNOMMU_DELAY_H) */
include/asm-mips/delay.h +2 -11
diff -urpN linux-2.6.18.new.2/include/asm-mips/delay.h linux-2.6.18.new.3/include/asm-mips/delay.h
@@ -48,7 +48,7 @@ static inline void __delay(unsigned long
  * a constant)
  */
 
-static inline void __udelay(unsigned long usecs, unsigned long lpj)
+static inline void __arch_udelay(unsigned long usecs, unsigned long lpj)
 {
 	unsigned long lo;
 
@@ -81,15 +81,6 @@ static inline void __udelay(unsigned lon
 
 #define __udelay_val cpu_data[smp_processor_id()].udelay_val
 
-#define udelay(usecs) __udelay((usecs),__udelay_val)
-
-/* make sure "usecs *= ..." in udelay do not overflow. */
-#if HZ >= 1000
-#define MAX_UDELAY_MS	1
-#elif HZ <= 200
-#define MAX_UDELAY_MS	5
-#else
-#define MAX_UDELAY_MS	(1000 / HZ)
-#endif
+#define __udelay(usecs) __arch_udelay((usecs),__udelay_val)
 
 #endif /* _ASM_DELAY_H */
include/asm-parisc/delay.h +0 -2
diff -urpN linux-2.6.18.new.2/include/asm-parisc/delay.h linux-2.6.18.new.3/include/asm-parisc/delay.h
@@ -37,6 +37,4 @@ static __inline__ void __udelay(unsigned
 	__cr16_delay(usecs * ((unsigned long)boot_cpu_data.cpu_hz / 1000000UL));
 }
 
-#define udelay(n) __udelay(n)
-
 #endif /* defined(_PARISC_DELAY_H) */
include/asm-powerpc/delay.h +1 -1
diff -urpN linux-2.6.18.new.2/include/asm-powerpc/delay.h linux-2.6.18.new.3/include/asm-powerpc/delay.h
@@ -15,7 +15,7 @@
  */
 
 extern void __delay(unsigned long loops);
-extern void udelay(unsigned long usecs);
+extern void __udelay(unsigned long usecs);
 
 /*
  * On shared processor machines the generic implementation of mdelay can
include/asm-ppc/delay.h +5 -9
diff -urpN linux-2.6.18.new.2/include/asm-ppc/delay.h linux-2.6.18.new.3/include/asm-ppc/delay.h
@@ -30,10 +30,9 @@ extern void __delay(unsigned int loops);
  * (which corresponds to ~3800 bogomips at HZ = 100).
  *  -- paulus
  */
-#define __MAX_UDELAY	(226050910UL/HZ)	/* maximum udelay argument */
 #define __MAX_NDELAY	(4294967295UL/HZ)	/* maximum ndelay argument */
 
-extern __inline__ void __udelay(unsigned int x)
+extern __inline__ void __arch_udelay(unsigned int x)
 {
 	unsigned int loops;
 
@@ -42,7 +41,7 @@ extern __inline__ void __udelay(unsigned
 	__delay(loops);
 }
 
-extern __inline__ void __ndelay(unsigned int x)
+extern __inline__ void __arch_ndelay(unsigned int x)
 {
 	unsigned int loops;
 
@@ -51,16 +50,13 @@ extern __inline__ void __ndelay(unsigned
 	__delay(loops);
 }
 
-extern void __bad_udelay(void);		/* deliberately undefined */
 extern void __bad_ndelay(void);		/* deliberately undefined */
 
-#define udelay(n) (__builtin_constant_p(n)? \
-	((n) > __MAX_UDELAY? __bad_udelay(): __udelay((n) * (19 * HZ))) : \
-	__udelay((n) * (19 * HZ)))
+#define __udelay(n) __arch_udelay((n) * (19 * HZ))
 
 #define ndelay(n) (__builtin_constant_p(n)? \
-	((n) > __MAX_NDELAY? __bad_ndelay(): __ndelay((n) * HZ)) : \
-	__ndelay((n) * HZ))
+	((n) > __MAX_NDELAY? __bad_ndelay(): __arch_ndelay((n) * HZ)) : \
+	__arch_ndelay((n) * HZ))
 
 #endif /* defined(_PPC_DELAY_H) */
 #endif /* __KERNEL__ */
include/asm-s390/delay.h +0 -2
diff -urpN linux-2.6.18.new.2/include/asm-s390/delay.h linux-2.6.18.new.3/include/asm-s390/delay.h
@@ -17,6 +17,4 @@
 extern void __udelay(unsigned long usecs);
 extern void __delay(unsigned long loops);
 
-#define udelay(n) __udelay(n)
-
 #endif /* defined(_S390_DELAY_H) */
include/asm-sh/delay.h +2 -8
diff -urpN linux-2.6.18.new.2/include/asm-sh/delay.h linux-2.6.18.new.3/include/asm-sh/delay.h
@@ -7,21 +7,15 @@
  * Delay routines calling functions in arch/sh/lib/delay.c
  */
  
-extern void __bad_udelay(void);
 extern void __bad_ndelay(void);
 
 extern void __udelay(unsigned long usecs);
 extern void __ndelay(unsigned long nsecs);
-extern void __const_udelay(unsigned long usecs);
+extern void __const_delay(unsigned long usecs);
 extern void __delay(unsigned long loops);
 
-#define udelay(n) (__builtin_constant_p(n) ? \
-	((n) > 20000 ? __bad_udelay() : __const_udelay((n) * 0x10c6ul)) : \
-	__udelay(n))
-
-
 #define ndelay(n) (__builtin_constant_p(n) ? \
-	((n) > 20000 ? __bad_ndelay() : __const_udelay((n) * 5ul)) : \
+	((n) > 20000 ? __bad_ndelay() : __const_delay((n) * 5ul)) : \
 	__ndelay(n))
 
 #endif /* __ASM_SH_DELAY_H */
include/asm-sh64/delay.h +3 -3
diff -urpN linux-2.6.18.new.2/include/asm-sh64/delay.h linux-2.6.18.new.3/include/asm-sh64/delay.h
@@ -2,10 +2,10 @@
 #define __ASM_SH64_DELAY_H
 
 extern void __delay(int loops);
-extern void __udelay(unsigned long long usecs, unsigned long lpj);
-extern void __ndelay(unsigned long long nsecs, unsigned long lpj);
-extern void udelay(unsigned long usecs);
+extern void __udelay(unsigned long usecs);
 extern void ndelay(unsigned long nsecs);
+/* for linux/delay.h: */
+#define ndelay ndelay
 
 #endif /* __ASM_SH64_DELAY_H */
 
include/asm-sparc/delay.h +0 -1
diff -urpN linux-2.6.18.new.2/include/asm-sparc/delay.h linux-2.6.18.new.3/include/asm-sparc/delay.h
@@ -28,7 +28,6 @@ extern void __ndelay(unsigned long nsecs
 #else /* SMP */
 #define __udelay_val	loops_per_jiffy
 #endif /* SMP */
-#define udelay(__usecs)	__udelay(__usecs, __udelay_val)
 #define ndelay(__nsecs)	__ndelay(__nsecs, __udelay_val)
 
 #endif /* defined(__SPARC_DELAY_H) */
include/asm-sparc64/delay.h +2 -6
diff -urpN linux-2.6.18.new.2/include/asm-sparc64/delay.h linux-2.6.18.new.3/include/asm-sparc64/delay.h
@@ -21,15 +21,11 @@ extern void __bad_ndelay(void);
 
 extern void __udelay(unsigned long usecs);
 extern void __ndelay(unsigned long nsecs);
-extern void __const_udelay(unsigned long usecs);
+extern void __const_delay(unsigned long usecs);
 extern void __delay(unsigned long loops);
 
-#define udelay(n) (__builtin_constant_p(n) ? \
-	((n) > 20000 ? __bad_udelay() : __const_udelay((n) * 0x10c7ul)) : \
-	__udelay(n))
-	
 #define ndelay(n) (__builtin_constant_p(n) ? \
-	((n) > 20000 ? __bad_ndelay() : __const_udelay((n) * 5ul)) : \
+	((n) > 20000 ? __bad_ndelay() : __const_delay((n) * 5ul)) : \
 	__ndelay(n))
 
 #endif /* !__ASSEMBLY__ */
include/asm-v850/delay.h +1 -1
diff -urpN linux-2.6.18.new.2/include/asm-v850/delay.h linux-2.6.18.new.3/include/asm-v850/delay.h
@@ -33,7 +33,7 @@ static inline void __delay(unsigned long
 
 extern unsigned long loops_per_jiffy;
 
-static inline void udelay(unsigned long usecs)
+static inline void __udelay(unsigned long usecs)
 {
 	register unsigned long full_loops, part_loops;
 
include/asm-x86_64/delay.h +2 -7
diff -urpN linux-2.6.18.new.2/include/asm-x86_64/delay.h linux-2.6.18.new.3/include/asm-x86_64/delay.h
@@ -7,20 +7,15 @@
  * Delay routines calling functions in arch/x86_64/lib/delay.c
  */
  
-extern void __bad_udelay(void);
 extern void __bad_ndelay(void);
 
 extern void __udelay(unsigned long usecs);
 extern void __ndelay(unsigned long usecs);
-extern void __const_udelay(unsigned long usecs);
+extern void __const_delay(unsigned long usecs);
 extern void __delay(unsigned long loops);
 
-#define udelay(n) (__builtin_constant_p(n) ? \
-	((n) > 20000 ? __bad_udelay() : __const_udelay((n) * 0x10c6ul)) : \
-	__udelay(n))
-
 #define ndelay(n) (__builtin_constant_p(n) ? \
-       ((n) > 20000 ? __bad_ndelay() : __const_udelay((n) * 5ul)) : \
+       ((n) > 20000 ? __bad_ndelay() : __const_delay((n) * 5ul)) : \
        __ndelay(n))
 
 
include/asm-xtensa/delay.h +1 -1
diff -urpN linux-2.6.18.new.2/include/asm-xtensa/delay.h linux-2.6.18.new.3/include/asm-xtensa/delay.h
@@ -35,7 +35,7 @@ static __inline__ u32 xtensa_get_ccount(
  * local_cpu_data->... where local_cpu_data points to the current
  * cpu. */
 
-static __inline__ void udelay (unsigned long usecs)
+static __inline__ void __udelay (unsigned long usecs)
 {
 	unsigned long start = xtensa_get_ccount();
 	unsigned long cycles = usecs * (loops_per_jiffy / (1000000UL / HZ));
include/linux/delay.h +4 -26
diff -urpN linux-2.6.18.new.2/include/linux/delay.h linux-2.6.18.new.3/include/linux/delay.h
@@ -11,37 +11,15 @@ extern unsigned long loops_per_jiffy;
 
 #include <asm/delay.h>
 
-/*
- * Using udelay() for intervals greater than a few milliseconds can
- * risk overflow for high loops_per_jiffy (high bogomips) machines. The
- * mdelay() provides a wrapper to prevent this.  For delays greater
- * than MAX_UDELAY_MS milliseconds, the wrapper is used.  Architecture
- * specific values can be defined in asm-???/delay.h as an override.
- * The 2nd mdelay() definition ensures GCC will optimize away the 
- * while loop for the common cases where n <= MAX_UDELAY_MS  --  Paul G.
- */
-
-#ifndef MAX_UDELAY_MS
-#define MAX_UDELAY_MS	5
-#endif
-
-#ifndef mdelay
-#define mdelay(n) (\
-	(__builtin_constant_p(n) && (n)<=MAX_UDELAY_MS) ? udelay((n)*1000) : \
-	({unsigned long __ms=(n); while (__ms--) udelay(1000);}))
-#endif
-
+void calibrate_delay(void);
+void udelay(unsigned int usecs);
+void mdelay(unsigned int msecs);
 #ifndef ndelay
 #define ndelay(x)	udelay(((x)+999)/1000)
 #endif
 
-void calibrate_delay(void);
 void msleep(unsigned int msecs);
+void ssleep(unsigned int secs);
 unsigned long msleep_interruptible(unsigned int msecs);
 
-static inline void ssleep(unsigned int seconds)
-{
-	msleep(seconds * 1000);
-}
-
 #endif /* defined(_LINUX_DELAY_H) */
kernel/timer.c +37 -0
diff -urpN linux-2.6.18.new.2/kernel/timer.c linux-2.6.18.new.3/kernel/timer.c
@@ -1882,6 +1882,36 @@ unregister_time_interpolator(struct time
 }
 #endif /* CONFIG_TIME_INTERPOLATION */
 
+/*
+ * Not inlined because we do not optimize delays for speed. ;)
+ */
+void udelay(unsigned int usecs)
+{
+	unsigned int k;
+	if (unlikely(usecs > 200*1000)) {
+		printk("BUG: delay too large: udelay(%u)\n", usecs);
+		dump_stack();
+		usecs = 200*1000;
+	}
+	k = usecs / 1024;
+	usecs %= 1024;
+	while (k) {
+		__udelay(1024);
+		k--;
+	}
+	__udelay(usecs);
+}
+
+EXPORT_SYMBOL(udelay);
+
+void mdelay(unsigned int msecs)
+{
+	while (msecs--)
+		__udelay(1000);
+}
+
+EXPORT_SYMBOL(mdelay);
+
 /**
  * msleep - sleep safely even with waitqueue interruptions
  * @msecs: Time in milliseconds to sleep for
@@ -1896,6 +1926,13 @@ void msleep(unsigned int msecs)
 
 EXPORT_SYMBOL(msleep);
 
+void ssleep(unsigned int secs)
+{
+        msleep(secs * 1000);
+}
+
+EXPORT_SYMBOL(ssleep);
+
 /**
  * msleep_interruptible - sleep waiting for signals
  * @msecs: Time in milliseconds to sleep for
#4 lore raw

Re: [PATCH 3/3] delay: add generic udelay(), mdelay() and ssleep()

Quoted 2 lines · Denis Vlasenko

* __const_udelay for all arches is removed or renamed to ? __const_delay (it did not do microsecond delays anyway)

You never explained this properly - in fact I think your logic is reversed. Let me remind you of my reply (which afaics never got a response):

Quoted 16 lines · Russell King
Quoted 8 lines · Denis Vlasenko
Quoted 1 line · Russell King

Please keep a "const" version in ARM. Thanks.

Are you talking about this hunk? Why do you want to keep it?

I mean, without it udelay(n) will become slower by the time needed for one extra multiply. So we will have maybe udelay(n) ==> udelay(n+0.1).

Why do you think that? With the constant version, the additional unnecessary multiply is optimised away by the compiler (since constant * constant = constant), so it's actually slightly faster, not sligntly slower as you seem to think.

Since the multiply is pure overhead, it's better to get rid of it.

Signature · 3 lines
Russell King
 Linux kernel    2.6 ARM Linux   - http://www.arm.linux.org.uk/
 maintainer of:  2.6 Serial core
#5 lore raw

Re: [PATCH 3/3] delay: add generic udelay(), mdelay() and ssleep()

Quoted 6 lines · Russell King
Quoted 2 lines · Denis Vlasenko

* __const_udelay for all arches is removed or renamed to ? __const_delay (it did not do microsecond delays anyway)

You never explained this properly - in fact I think your logic is reversed.

linux-2.6.18/arch/i386/lib/delay.c:

void __udelay(unsigned long usecs)

{
       __const_udelay(usecs * 0x000010c7); /* 2**32 / 1000000 (rounded up) */
}

__udelay(n) is meant to busy loop for N microseconds, and it is easy to see from above code that __udelay(n) == __const_udelay(n*0x10c7).
So __const_udelay(x) doesn not delay for x microseconds. It's a bad name.

Quoted 20 lines

Let me remind you of my reply (which afaics never got a response):

Quoted 16 lines · Russell King
Quoted 8 lines · Denis Vlasenko
Quoted 1 line · Russell King

Please keep a "const" version in ARM. Thanks.

Are you talking about this hunk? Why do you want to keep it?

I mean, without it udelay(n) will become slower by the time needed for one extra multiply. So we will have maybe udelay(n) ==> udelay(n+0.1).

Why do you think that? With the constant version, the additional unnecessary multiply is optimised away by the compiler (since constant * constant = constant), so it's actually slightly faster, not sligntly slower as you seem to think.

Since the multiply is pure overhead, it's better to get rid of it.

I did send a reply. Maybe the problem was that I removed l-k from CC...

Quoted 15 lines · Denis Vlasenko
Quoted 4 lines

Why do you think that? With the constant version, the additional unnecessary multiply is optimised away by the compiler (since constant * constant = constant), so it's actually slightly faster, not sligntly slower as you seem to think.

We are not disagreeind. I said it wrong way. I meant "with this #define removed, udelay(n) will become slower...".

And I am saying that it is _100% okay_ for it to become slower:

Quoted 1 line

Since the multiply is pure overhead, it's better to get rid of it.

You do not need to optimize delay for speed. If you really want to, then you can do:

Quoted 7 lines

#define udelay(n) do {} while(0)

Makes sense? No it does not. That's what I'm trying to say. You WANT to pause for thousands of cycles. Why you are trying to shave off ~10 cycles at the very same time?

Hope it makes things clearer.

So, to reiterate, optimizing udelay(N) for speed makes no sense. --
vda