mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-05 11:16:41 +07:00
d3de851a44
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>
26 lines
656 B
C
26 lines
656 B
C
/* Permission is hereby granted to copy, modify and redistribute this code
|
|
* in terms of the GNU Library General Public License, Version 2 or later,
|
|
* at your option.
|
|
*/
|
|
|
|
/* macros to translate to/from binary and binary-coded decimal (frequently
|
|
* found in RTC chips).
|
|
*/
|
|
|
|
#ifndef _BCD_H
|
|
#define _BCD_H
|
|
|
|
#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))
|
|
#define BIN_TO_BCD(val) ((val)=BIN2BCD(val))
|
|
|
|
#endif /* _BCD_H */
|