bcd.c 261 B

123456789101112131415
  1. #include <linux/bcd.h>
  2. #include <linux/export.h>
  3. unsigned _bcd2bin(unsigned char val)
  4. {
  5. return (val & 0x0f) + (val >> 4) * 10;
  6. }
  7. EXPORT_SYMBOL(_bcd2bin);
  8. unsigned char _bin2bcd(unsigned val)
  9. {
  10. return ((val / 10) << 4) + val % 10;
  11. }
  12. EXPORT_SYMBOL(_bin2bcd);