bcd.h 656 B

12345678910111213141516171819202122232425
  1. /* Permission is hereby granted to copy, modify and redistribute this code
  2. * in terms of the GNU Library General Public License, Version 2 or later,
  3. * at your option.
  4. */
  5. /* macros to translate to/from binary and binary-coded decimal (frequently
  6. * found in RTC chips).
  7. */
  8. #ifndef _BCD_H
  9. #define _BCD_H
  10. #include <linux/compiler.h>
  11. unsigned bcd2bin(unsigned char val) __attribute_const__;
  12. unsigned char bin2bcd(unsigned val) __attribute_const__;
  13. #define BCD2BIN(val) bcd2bin(val)
  14. #define BIN2BCD(val) bin2bcd(val)
  15. /* backwards compat */
  16. #define BCD_TO_BIN(val) ((val)=BCD2BIN(val))
  17. #define BIN_TO_BCD(val) ((val)=BIN2BCD(val))
  18. #endif /* _BCD_H */