]> git.sur5r.net Git - groeck-it87/blob - compat.h
Provide vid_from_reg and vid_which_vrm if needed
[groeck-it87] / compat.h
1 /*---------------------------------------------------------------------------
2  * 
3  * compat.h 
4  *     Copyright (c) 2012 Guenter Roeck <linux@roeck-us.net>
5  *
6  *---------------------------------------------------------------------------
7  */
8
9 #ifndef COMPAT_H
10 #define COMPAT_H
11
12 #include <linux/version.h>
13
14 #if !defined (CONFIG_HWMON_VID) && !defined(CONFIG_HWMON_VID_MODULE)
15 int vid_from_reg(int val, u8 vrm)
16 {
17         return 0;
18 }
19
20 u8 vid_which_vrm(void)
21 {
22         return 0;
23 }
24 #endif
25
26 #ifndef clamp_val
27 #define clamp_val SENSORS_LIMIT
28 #endif
29
30 #ifndef request_muxed_region
31 #if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 28)
32 #define request_muxed_region(start,n,name)      __request_region(&ioport_resource, (start), (n), (name))
33 #else
34 #define IORESOURCE_MUXED        0x00400000
35 #define request_muxed_region(start,n,name)      __request_region(&ioport_resource, (start), (n), (name), IORESOURCE_MUXED)
36 #endif
37 #endif
38
39 /* Red Hat EL5 includes backports of these functions, so we can't redefine
40  * our own. */
41 #if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 24)
42 #if !(defined RHEL_MAJOR && RHEL_MAJOR == 5 && RHEL_MINOR >= 5)
43 static inline int strict_strtoul(const char *cp, unsigned int base,
44                                  unsigned long *res)
45 {
46         *res = simple_strtoul(cp, NULL, base);
47         return 0;
48 }
49
50 static inline int strict_strtol(const char *cp, unsigned int base, long *res)
51 {
52         *res = simple_strtol(cp, NULL, base);
53         return 0;
54 }
55 #endif
56 #endif
57
58 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 39)
59 #define kstrtoul strict_strtoul 
60 #define kstrtol strict_strtol
61 #endif
62
63 /*
64  * Some kernel configurations may have CONFIG_HWMON_VID disabled.
65  * We still have the functios declared as external, so we can not use
66  * static inline.
67  */
68 #if !defined(CONFIG_HWMON_VID) && !defined(CONFIG_HWMON_VID_MODULE)
69 int vid_from_reg(int val, u8 vrm)
70 {
71         return 0;
72 }
73
74 u8 vid_which_vrm(void)
75 {
76         return 0;
77 }
78 #endif
79
80 #endif /* COMPAT_H */