blob: 7e4750b6e801425dd1c3a68402607b189ca6b99d [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001// SPDX-License-Identifier: GPL-2.0
David Brownelld3de8512008-07-23 21:30:37 -07002#include <linux/bcd.h>
Paul Gortmaker8bc3bcc2011-11-16 21:29:17 -05003#include <linux/export.h>
David Brownelld3de8512008-07-23 21:30:37 -07004
Sebastian Andrzej Siewiorb53d6572012-09-07 14:31:45 +02005unsigned _bcd2bin(unsigned char val)
David Brownelld3de8512008-07-23 21:30:37 -07006{
7 return (val & 0x0f) + (val >> 4) * 10;
8}
Sebastian Andrzej Siewiorb53d6572012-09-07 14:31:45 +02009EXPORT_SYMBOL(_bcd2bin);
David Brownelld3de8512008-07-23 21:30:37 -070010
Sebastian Andrzej Siewiorb53d6572012-09-07 14:31:45 +020011unsigned char _bin2bcd(unsigned val)
David Brownelld3de8512008-07-23 21:30:37 -070012{
13 return ((val / 10) << 4) + val % 10;
14}
Sebastian Andrzej Siewiorb53d6572012-09-07 14:31:45 +020015EXPORT_SYMBOL(_bin2bcd);