X-Git-Url: https://git.sur5r.net/?p=groeck-nct6775;a=blobdiff_plain;f=compat.h;h=de03ccbc560c4a434d5927c174f1d80e1b302207;hp=a697a6299678a21ae80f657394bbce51ca8b8566;hb=HEAD;hpb=f361ce9049e115e479fd0fb79a76e1ace1365b2f diff --git a/compat.h b/compat.h index a697a62..de03ccb 100644 --- a/compat.h +++ b/compat.h @@ -3,8 +3,8 @@ #include -#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 16) -#error This driver is for kernel versions 2.6.16 and later +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 32) +#error This driver is for kernel versions 2.6.32 and later #endif #if !defined (CONFIG_HWMON_VID) && !defined(CONFIG_HWMON_VID_MODULE) @@ -20,6 +20,8 @@ u8 vid_which_vrm(void) #endif #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 12, 0) +#if !(defined RHEL_MAJOR && RHEL_MAJOR == 7) +#if !(defined RHEL_MAJOR && RHEL_MAJOR == 6 && RHEL_MINOR >= 7) static int sysfs_create_groups(struct kobject *kobj, const struct attribute_group **groups) { @@ -39,6 +41,7 @@ static int sysfs_create_groups(struct kobject *kobj, } return error; } +#endif static void sysfs_remove_groups(struct kobject *kobj, const struct attribute_group **groups) @@ -50,7 +53,10 @@ static void sysfs_remove_groups(struct kobject *kobj, for (i = 0; groups[i]; i++) sysfs_remove_group(kobj, groups[i]); } +#endif +#if !(defined RHEL_MAJOR && RHEL_MAJOR == 7) +#if !(defined RHEL_MAJOR && RHEL_MAJOR == 6 && RHEL_MINOR >= 7) static inline int __must_check PTR_ERR_OR_ZERO(__force const void *ptr) { if (IS_ERR(ptr)) @@ -58,7 +64,8 @@ static inline int __must_check PTR_ERR_OR_ZERO(__force const void *ptr) else return 0; } - +#endif +#endif #endif #ifdef __NEED_I2C__ @@ -199,12 +206,14 @@ module_exit(__driver##_exit); #define clamp_val SENSORS_LIMIT #endif +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 12, 0) #ifndef kstrtol #define kstrtol strict_strtol #endif #ifndef kstrtoul #define kstrtoul strict_strtoul #endif +#endif #ifndef request_muxed_region #define request_muxed_region(a, b, c) (true) @@ -213,4 +222,28 @@ module_exit(__driver##_exit); #define release_region(a, b) #endif +#ifndef pr_warn +/* pr_warn macro not introduced until 2.6.35 */ +#define pr_warn pr_warning +#endif +#ifndef pr_warn_ratelimited +#define pr_warn_ratelimited pr_warning_ratelimited +#endif + +#ifndef sysfs_attr_init +#define sysfs_attr_init(attr) do {} while (0) +#endif + +#ifndef __ATTR_RO +#define __ATTR_RO(_name) { \ + .attr = { .name = __stringify(_name), .mode = 0444 }, \ + .show = _name##_show, \ +} +#endif + +#ifndef DEVICE_ATTR_RO +#define DEVICE_ATTR_RO(_name) \ + struct device_attribute dev_attr_##_name = __ATTR_RO(_name) +#endif + #endif /* __COMPAT_H */