linux-stable/arch
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
..
alpha [PATCH] make osf_select() use core_sys_select() 2008-05-01 13:07:28 -04:00
arm Merge branch 'for-rmk' of git://git.kernel.org/pub/scm/linux/kernel/git/nico/orion into fixes 2008-05-09 23:24:09 +01:00
avr32 unified (weak) sys_pipe implementation 2008-05-03 13:50:33 -07:00
blackfin [Blackfin] arch: protect linux/usb/musb.h include until the driver gets mainlined 2008-05-10 00:08:12 +08:00
cris cris: kill sys_pipe implementation 2008-05-09 08:03:03 -07:00
frv unified (weak) sys_pipe implementation 2008-05-03 13:50:33 -07:00
h8300 unified (weak) sys_pipe implementation 2008-05-03 13:50:33 -07:00
ia64 Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/aegl/linux-2.6 2008-05-02 08:17:58 -07:00
m32r m32r: use generic sys_pipe 2008-05-09 08:04:56 -07:00
m68k m68k: remove old mac_esp cruft 2008-05-05 12:38:50 -07:00
m68knommu unified (weak) sys_pipe implementation 2008-05-03 13:50:33 -07:00
mips Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs-2.6 2008-05-02 11:23:14 -07:00
mn10300 BKL: revert back to the old spinlock implementation 2008-05-10 20:58:02 -07:00
parisc unified (weak) sys_pipe implementation 2008-05-03 13:50:33 -07:00
powerpc Merge branch 'merge' of git://git.kernel.org/pub/scm/linux/kernel/git/paulus/powerpc 2008-05-09 08:06:31 -07:00
ppc Merge branch 'for-2.6.26' of git://git.farnsworth.org/dale/linux-2.6-mv643xx_eth into upstream 2008-05-06 12:22:03 -04:00
s390 [S390] guest page hinting light 2008-05-07 09:23:02 +02:00
sh SH: catch negative denormal_subf1() retval in denormal_add() 2008-05-09 20:05:10 +09:00
sparc sparc: Fix debugger syscall restart interactions. 2008-05-11 02:07:19 -07:00
sparc64 sparc: Fix debugger syscall restart interactions. 2008-05-11 02:07:19 -07:00
um uml: fix inconsistence due to tty_operation change 2008-05-08 10:46:55 -07:00
v850 unified (weak) sys_pipe implementation 2008-05-03 13:50:33 -07:00
x86 x86: clean up computation of HPET .mult variables 2008-05-12 21:27:54 +02:00
xtensa xtensa: use kbuild.h macros instead of defining them in asm-offsets.c 2008-04-29 08:06:29 -07:00
.gitignore arch: Ignore arch/i386 and arch/x86_64 2008-01-19 21:29:39 -08:00
Kconfig dma: add dma_*map*_attrs() interfaces 2008-04-29 08:06:11 -07:00