~pmdj/ubuntu/trusty/qemu/2.9+applesmc+fadtv3

« back to all changes in this revision

Viewing changes to roms/u-boot/include/bcd.h

  • Committer: Phil Dennis-Jordan
  • Date: 2017-07-21 08:03:43 UTC
  • mfrom: (1.1.1)
  • Revision ID: phil@philjordan.eu-20170721080343-2yr2vdj7713czahv
New upstream release 2.9.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
 
6
/* inline functions to translate to/from binary and binary-coded decimal
 
7
 * (frequently found in RTC chips).
 
8
 */
 
9
 
 
10
#ifndef _BCD_H
 
11
#define _BCD_H
 
12
 
 
13
#include <linux/types.h>
 
14
 
 
15
static inline unsigned int bcd2bin(u8 val)
 
16
{
 
17
        return ((val) & 0x0f) + ((val) >> 4) * 10;
 
18
}
 
19
 
 
20
static inline u8 bin2bcd (unsigned int val)
 
21
{
 
22
        return (((val / 10) << 4) | (val % 10));
 
23
}
 
24
 
 
25
#endif /* _BCD_H */