Merge tag 'clk-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[linux-stable.git] / lib / bcd.c
blobc5e79ba9cd7b722d782c990d5f9f61b1cd661524
1 // SPDX-License-Identifier: GPL-2.0
2 #include <linux/bcd.h>
3 #include <linux/export.h>
5 unsigned _bcd2bin(unsigned char val)
7 return (val & 0x0f) + (val >> 4) * 10;
9 EXPORT_SYMBOL(_bcd2bin);
11 unsigned char _bin2bcd(unsigned val)
13 const unsigned int t = (val * 103) >> 10;
15 return (t << 4) | (val - t * 10);
17 EXPORT_SYMBOL(_bin2bcd);