mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-27 03:10:12 +00:00
![David Brownell](/assets/img/avatar_default.png)
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>
14 lines
257 B
C
14 lines
257 B
C
#include <linux/bcd.h>
|
|
#include <linux/module.h>
|
|
|
|
unsigned bcd2bin(unsigned char val)
|
|
{
|
|
return (val & 0x0f) + (val >> 4) * 10;
|
|
}
|
|
EXPORT_SYMBOL(bcd2bin);
|
|
|
|
unsigned char bin2bcd(unsigned val)
|
|
{
|
|
return ((val / 10) << 4) + val % 10;
|
|
}
|
|
EXPORT_SYMBOL(bin2bcd);
|