diff options
-rw-r--r-- | drivers/usb/core/hcd.c | 6 | ||||
-rw-r--r-- | include/linux/bcd.h | 17 | ||||
-rw-r--r-- | lib/bcd.c | 8 |
3 files changed, 22 insertions, 9 deletions
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index bc84106ac057..6e4fd28bc242 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c | |||
@@ -22,6 +22,7 @@ | |||
22 | * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 22 | * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include <linux/bcd.h> | ||
25 | #include <linux/module.h> | 26 | #include <linux/module.h> |
26 | #include <linux/version.h> | 27 | #include <linux/version.h> |
27 | #include <linux/kernel.h> | 28 | #include <linux/kernel.h> |
@@ -123,9 +124,8 @@ static inline int is_root_hub(struct usb_device *udev) | |||
123 | */ | 124 | */ |
124 | 125 | ||
125 | /*-------------------------------------------------------------------------*/ | 126 | /*-------------------------------------------------------------------------*/ |
126 | 127 | #define KERNEL_REL bin2bcd(((LINUX_VERSION_CODE >> 16) & 0x0ff)) | |
127 | #define KERNEL_REL ((LINUX_VERSION_CODE >> 16) & 0x0ff) | 128 | #define KERNEL_VER bin2bcd(((LINUX_VERSION_CODE >> 8) & 0x0ff)) |
128 | #define KERNEL_VER ((LINUX_VERSION_CODE >> 8) & 0x0ff) | ||
129 | 129 | ||
130 | /* usb 3.0 root hub device descriptor */ | 130 | /* usb 3.0 root hub device descriptor */ |
131 | static const u8 usb3_rh_dev_descriptor[18] = { | 131 | static const u8 usb3_rh_dev_descriptor[18] = { |
diff --git a/include/linux/bcd.h b/include/linux/bcd.h index 22ea563ba3eb..18fff11fb3ea 100644 --- a/include/linux/bcd.h +++ b/include/linux/bcd.h | |||
@@ -3,7 +3,20 @@ | |||
3 | 3 | ||
4 | #include <linux/compiler.h> | 4 | #include <linux/compiler.h> |
5 | 5 | ||
6 | unsigned bcd2bin(unsigned char val) __attribute_const__; | 6 | #define bcd2bin(x) \ |
7 | unsigned char bin2bcd(unsigned val) __attribute_const__; | 7 | (__builtin_constant_p((u8 )(x)) ? \ |
8 | const_bcd2bin(x) : \ | ||
9 | _bcd2bin(x)) | ||
10 | |||
11 | #define bin2bcd(x) \ | ||
12 | (__builtin_constant_p((u8 )(x)) ? \ | ||
13 | const_bin2bcd(x) : \ | ||
14 | _bin2bcd(x)) | ||
15 | |||
16 | #define const_bcd2bin(x) (((x) & 0x0f) + ((x) >> 4) * 10) | ||
17 | #define const_bin2bcd(x) ((((x) / 10) << 4) + (x) % 10) | ||
18 | |||
19 | unsigned _bcd2bin(unsigned char val) __attribute_const__; | ||
20 | unsigned char _bin2bcd(unsigned val) __attribute_const__; | ||
8 | 21 | ||
9 | #endif /* _BCD_H */ | 22 | #endif /* _BCD_H */ |
@@ -1,14 +1,14 @@ | |||
1 | #include <linux/bcd.h> | 1 | #include <linux/bcd.h> |
2 | #include <linux/export.h> | 2 | #include <linux/export.h> |
3 | 3 | ||
4 | unsigned bcd2bin(unsigned char val) | 4 | unsigned _bcd2bin(unsigned char val) |
5 | { | 5 | { |
6 | return (val & 0x0f) + (val >> 4) * 10; | 6 | return (val & 0x0f) + (val >> 4) * 10; |
7 | } | 7 | } |
8 | EXPORT_SYMBOL(bcd2bin); | 8 | EXPORT_SYMBOL(_bcd2bin); |
9 | 9 | ||
10 | unsigned char bin2bcd(unsigned val) | 10 | unsigned char _bin2bcd(unsigned val) |
11 | { | 11 | { |
12 | return ((val / 10) << 4) + val % 10; | 12 | return ((val / 10) << 4) + val % 10; |
13 | } | 13 | } |
14 | EXPORT_SYMBOL(bin2bcd); | 14 | EXPORT_SYMBOL(_bin2bcd); |