linux-stable/arch/x86
Carlos R. Mafra 6fd592daae x86: clean up computation of HPET .mult variables
While reading through the HPET code I realized that the
computation of .mult variables could be done with less
lines of code, resulting in a 1.6% text size saving
for hpet.o

So I propose the following patch, which applies against
today's Linus -git tree.

>From 0c6507e400e9ca5f7f14331e18f8c12baf75a9d3 Mon Sep 17 00:00:00 2001
From: Carlos R. Mafra <crmafra@ift.unesp.br>
Date: Mon, 5 May 2008 19:38:53 -0300

The computation of clocksource_hpet.mult

       tmp = (u64)hpet_period << HPET_SHIFT;
       do_div(tmp, FSEC_PER_NSEC);
       clocksource_hpet.mult = (u32)tmp;

can be streamlined if we note that it is equal to

       clocksource_hpet.mult = div_sc(hpet_period, FSEC_PER_NSEC, HPET_SHIFT);

Furthermore, the computation of hpet_clockevent.mult

       uint64_t hpet_freq;

       hpet_freq = 1000000000000000ULL;
       do_div(hpet_freq, hpet_period);
       hpet_clockevent.mult = div_sc((unsigned long) hpet_freq,
                                     NSEC_PER_SEC, hpet_clockevent.shift);

can also be streamlined with the observation that hpet_period and hpet_freq are
inverse to each other (in proper units).

So instead of computing hpet_freq and using (schematically)
div_sc(hpet_freq, 10^9, shift) we use the trick of calling with the
arguments in reverse order, div_sc(10^6, hpet_period, shift).

The different power of ten is due to frequency being in Hertz (1/sec)
and the period being in units of femtosecond. Explicitly,

mult = (hpet_freq * 2^shift)/10^9    (before)
mult = (10^6 * 2^shift)/hpet_period  (after)

because hpet_freq = 10^15/hpet_period.

The comments in the code are also updated to reflect the changes.

As a result,

   text    data     bss     dec     hex filename
   2957     425      92    3474     d92 arch/x86/kernel/hpet.o
   3006     425      92    3523     dc3 arch/x86/kernel/hpet.o.old

a 1.6% reduction in text size.

Signed-off-by: Carlos R. Mafra <crmafra@ift.unesp.br>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
2008-05-12 21:27:54 +02:00
..
boot x86: relocs ELF handling - use SELFMAG instead of numeric constant 2008-05-04 20:04:45 +02:00
configs x86: add optimized inlining 2008-04-26 17:44:55 +02:00
crypto [CRYPTO] aes-x86-32: Remove unused return code 2008-04-21 10:19:21 +08:00
ia32 signals: x86 TS_RESTORE_SIGMASK 2008-04-30 08:29:37 -07:00
kernel x86: clean up computation of HPET .mult variables 2008-05-12 21:27:54 +02:00
kvm KVM: MMU: Allow more than PAGES_PER_HPAGE write protections per large page 2008-05-04 14:44:49 +03:00
lguest x86: replace remaining __FUNCTION__ occurances 2008-04-17 17:40:57 +02:00
lib x86, UML: remove x86-specific implementations of find_first_bit 2008-04-26 19:21:17 +02:00
mach-default
mach-es7000
mach-generic x86: coding style fixes to arch/x86/mach-generic/bigsmp.c 2008-04-17 17:40:48 +02:00
mach-rdc321x x86, rdc321x: remove watchdog file 2008-04-17 17:40:50 +02:00
mach-visws x86: fix compilation error in VisWS 2008-04-24 23:15:44 +02:00
mach-voyager x86, voyager: fix ioremap_nocache() 2008-04-30 23:15:34 +02:00
math-emu x86, fpu: split FPU state from task struct - v5 2008-04-19 19:19:55 +02:00
mm x86: cleanup PAT cpu validation 2008-05-08 15:43:51 +02:00
oprofile x86: oprofile: remove NR_CPUS arrays in arch/x86/oprofile/nmi_int.c 2008-04-19 19:44:58 +02:00
pci Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/x86/linux-2.6-x86 2008-05-10 21:10:48 -07:00
power x86: coding style fixes to arch/x86/power/cpu_32.c 2008-04-17 17:40:50 +02:00
vdso x86: vdso ELF handling - use SELFMAG instead of numeric constant 2008-05-04 20:04:45 +02:00
video x86: video/fbdev.c: add MODULE_LICENSE 2008-05-04 20:04:46 +02:00
xen pageflags: use proper page flag functions in Xen 2008-04-28 08:58:22 -07:00
Kconfig x86: rdc: leds build/config fix 2008-05-10 19:31:45 +02:00
Kconfig.cpu x86: CONFIG_X86_ELAN fix 2008-04-30 23:15:35 +02:00
Kconfig.debug x86: Mark OPTIMIZE_INLINING broken 2008-04-30 20:07:22 -07:00
Makefile x86: add subarch support (for headers) to x86_64 2008-04-17 17:41:01 +02:00
Makefile_32.cpu