bcd.c 257 B

123456789101112131415
  1. #include <linux/bcd.h>
  2. #include <linux/module.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);