summaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorDavid Brownell <david-b@pacbell.net>2008-07-23 21:30:37 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2008-07-24 10:47:33 -0700
commitd3de851a445123f24ad8ece18662014b5e8a8b4e (patch)
tree44ef8b43208ba8a071fcd4d4b22e76c55881836d /include/linux
parent53e84b672c1a8190af2b376c35c7a39cf1214f59 (diff)
downloadop-kernel-dev-d3de851a445123f24ad8ece18662014b5e8a8b4e.zip
op-kernel-dev-d3de851a445123f24ad8ece18662014b5e8a8b4e.tar.gz
rtc: BCD codeshrink
This updates <linux/bcd.h> to define the key routines as constant functions, which the macros will then call. Newer code can now call bcd2bin() instead of SCREAMING BCD2BIN() TO THE FOUR WINDS. This lets each driver shrink their codespace by using N function calls to a single (global) copy of those routines, instead of N inlined copies of these functions per driver. These routines aren't used in speed-critical code. Almost all callers are in the RTC framework. Typical per-driver savings is near 300 bytes. Signed-off-by: David Brownell <dbrownell@users.sourceforge.net> Acked-by: Adrian Bunk <bunk@kernel.org> Cc: Alessandro Zummo <a.zummo@towertech.it> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/bcd.h9
1 files changed, 7 insertions, 2 deletions
diff --git a/include/linux/bcd.h b/include/linux/bcd.h
index c545308..7ac518e 100644
--- a/include/linux/bcd.h
+++ b/include/linux/bcd.h
@@ -10,8 +10,13 @@
#ifndef _BCD_H
#define _BCD_H
-#define BCD2BIN(val) (((val) & 0x0f) + ((val)>>4)*10)
-#define BIN2BCD(val) ((((val)/10)<<4) + (val)%10)
+#include <linux/compiler.h>
+
+unsigned bcd2bin(unsigned char val) __attribute_const__;
+unsigned char bin2bcd(unsigned val) __attribute_const__;
+
+#define BCD2BIN(val) bcd2bin(val)
+#define BIN2BCD(val) bin2bcd(val)
/* backwards compat */
#define BCD_TO_BIN(val) ((val)=BCD2BIN(val))
OpenPOWER on IntegriCloud