]> git.sur5r.net Git - groeck-nct6775/blobdiff - compat.h
compat.h: define pr_warn and pr_warn_ratelimited macros if not already defined
[groeck-nct6775] / compat.h
index 0a46c0d8d998807c020be5e626dca72497b3c908..458caf4e61a9b9ea7a9afa235a4f4fd7d11dfed1 100644 (file)
--- a/compat.h
+++ b/compat.h
@@ -7,6 +7,18 @@
 #error This driver is for kernel versions 2.6.16 and later
 #endif
 
+#if !defined (CONFIG_HWMON_VID) && !defined(CONFIG_HWMON_VID_MODULE)
+int vid_from_reg(int val, u8 vrm)
+{
+       return 0;
+}
+
+u8 vid_which_vrm(void)
+{
+       return 0;
+}
+#endif
+
 #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 12, 0)
 static int sysfs_create_groups(struct kobject *kobj,
                               const struct attribute_group **groups)
@@ -49,6 +61,8 @@ static inline int __must_check PTR_ERR_OR_ZERO(__force const void *ptr)
 
 #endif
 
+#ifdef __NEED_I2C__
+
 #if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 21)
 #if !(defined RHEL_MAJOR && RHEL_MAJOR == 5 && RHEL_MINOR >= 6)
 /* Simplified version for compatibility */
@@ -79,6 +93,23 @@ static struct i2c_client_address_data addr_data = {
 };
 #endif
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 2, 0)
+static inline s32
+i2c_smbus_read_word_swapped(const struct i2c_client *client, u8 command)
+{
+       s32 value = i2c_smbus_read_word_data(client, command);
+
+       return (value < 0) ? value : swab16(value);
+}
+
+static inline s32
+i2c_smbus_write_word_swapped(const struct i2c_client *client,
+                            u8 command, u16 value)
+{
+       return i2c_smbus_write_word_data(client, command, swab16(value));
+}
+#endif
+
 /* Red Hat EL5 includes backports of these functions, so we can't redefine
  * our own. */
 #if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 24)
@@ -98,6 +129,8 @@ static inline int strict_strtol(const char *cp, unsigned int base, long *res)
 #endif
 #endif
 
+#endif /* __NEED_I2C__ */
+
 #if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 28)
 /*
  * Divide positive or negative dividend by positive divisor and round
@@ -116,23 +149,6 @@ static inline int strict_strtol(const char *cp, unsigned int base, long *res)
 )
 #endif
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 2, 0)
-static inline s32
-i2c_smbus_read_word_swapped(const struct i2c_client *client, u8 command)
-{
-       s32 value = i2c_smbus_read_word_data(client, command);
-
-       return (value < 0) ? value : swab16(value);
-}
-
-static inline s32
-i2c_smbus_write_word_swapped(const struct i2c_client *client,
-                            u8 command, u16 value)
-{
-       return i2c_smbus_write_word_data(client, command, swab16(value));
-}
-#endif
-
 #ifndef module_driver
 /**
  * module_driver() - Helper macro for drivers that don't do anything
@@ -161,6 +177,8 @@ static void __exit __driver##_exit(void) \
 module_exit(__driver##_exit);
 #endif
 
+#ifdef __NEED_I2C__
+
 #ifndef module_i2c_driver
 /**
  * module_i2c_driver() - Helper macro for registering a I2C driver
@@ -175,6 +193,8 @@ module_exit(__driver##_exit);
                        i2c_del_driver)
 #endif
 
+#endif /* __NEED_I2C__ */
+
 #ifndef clamp_val
 #define clamp_val SENSORS_LIMIT
 #endif
@@ -188,7 +208,17 @@ module_exit(__driver##_exit);
 
 #ifndef request_muxed_region
 #define request_muxed_region(a, b, c) (true)
+#endif
+#ifndef release_region
 #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
+
 #endif /* __COMPAT_H */