lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220825214341.2743-2-W_Armin@gmx.de>
Date:   Thu, 25 Aug 2022 23:43:40 +0200
From:   Armin Wolf <W_Armin@....de>
To:     jdelvare@...e.com, linux@...ck-us.net
Cc:     linux-hwmon@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH 1/2] hwmon: Add include stubs

If CONFIG_HWMON/CONFIG_HWMON_VID was disabled during compile
time, driver using the hwmon subsystem might fail to compile.
Provide stubs for such cases.

Signed-off-by: Armin Wolf <W_Armin@....de>
---
 include/linux/hwmon-vid.h | 18 ++++++++++
 include/linux/hwmon.h     | 76 ++++++++++++++++++++++++++++++++++++++-
 2 files changed, 93 insertions(+), 1 deletion(-)

diff --git a/include/linux/hwmon-vid.h b/include/linux/hwmon-vid.h
index 9409e1d207ef..329151416c47 100644
--- a/include/linux/hwmon-vid.h
+++ b/include/linux/hwmon-vid.h
@@ -11,9 +11,27 @@
 #ifndef _LINUX_HWMON_VID_H
 #define _LINUX_HWMON_VID_H

+#include <linux/kconfig.h>
+
+#if IS_ENABLED(CONFIG_HWMON_VID)
+
 int vid_from_reg(int val, u8 vrm);
 u8 vid_which_vrm(void);

+#else
+
+static inline int vid_from_reg(int val, u8 vrm)
+{
+	return 0;
+}
+
+static inline u8 vid_which_vrm(void)
+{
+	return 0;
+}
+
+#endif /* CONFIG_HWMON_VID */
+
 /* vrm is the VRM/VRD document version multiplied by 10.
    val is in mV to avoid floating point in the kernel.
    Returned value is the 4-, 5- or 6-bit VID code.
diff --git a/include/linux/hwmon.h b/include/linux/hwmon.h
index 14325f93c6b2..281387ee03bc 100644
--- a/include/linux/hwmon.h
+++ b/include/linux/hwmon.h
@@ -13,6 +13,9 @@
 #define _HWMON_H_

 #include <linux/bitops.h>
+#include <linux/err.h>
+#include <linux/errno.h>
+#include <linux/kconfig.h>

 struct device;
 struct attribute_group;
@@ -433,6 +436,8 @@ struct hwmon_chip_info {
 	const struct hwmon_channel_info **info;
 };

+#if IS_ENABLED(CONFIG_HWMON)
+
 /* hwmon_device_register() is deprecated */
 struct device *hwmon_device_register(struct device *dev);

@@ -467,6 +472,75 @@ int hwmon_notify_event(struct device *dev, enum hwmon_sensor_types type,
 char *hwmon_sanitize_name(const char *name);
 char *devm_hwmon_sanitize_name(struct device *dev, const char *name);

+#else
+
+static inline struct device *hwmon_device_register(struct device *dev)
+{
+	return ERR_PTR(-ENODEV);
+}
+
+static inline struct device
+*hwmon_device_register_with_groups(struct device *dev, const char *name, void *drvdata,
+				   const struct attribute_group **groups)
+{
+	return ERR_PTR(-ENODEV);
+}
+
+static inline struct device
+*devm_hwmon_device_register_with_groups(struct device *dev, const char *name, void *drvdata,
+					const struct attribute_group **groups)
+{
+	return ERR_PTR(-ENODEV);
+}
+
+static inline struct device
+*hwmon_device_register_with_info(struct device *dev, const char *name, void *drvdata,
+				 const struct hwmon_chip_info *info,
+				 const struct attribute_group **extra_groups)
+{
+	return ERR_PTR(-ENODEV);
+}
+
+static inline struct device *hwmon_device_register_for_thermal(struct device *dev, const char *name,
+							       void *drvdata)
+{
+	return ERR_PTR(-ENODEV);
+}
+
+static inline struct device
+*devm_hwmon_device_register_with_info(struct device *dev, const char *name, void *drvdata,
+				      const struct hwmon_chip_info *info,
+				      const struct attribute_group **extra_groups)
+{
+	return ERR_PTR(-ENODEV);
+}
+
+static inline void hwmon_device_unregister(struct device *dev)
+{
+}
+
+static inline void devm_hwmon_device_unregister(struct device *dev)
+{
+}
+
+static inline int hwmon_notify_event(struct device *dev, enum hwmon_sensor_types type, u32 attr,
+				     int channel)
+{
+	return -ENODEV;
+}
+
+static inline char *hwmon_sanitize_name(const char *name)
+{
+	return ERR_PTR(-ENODEV);
+}
+
+static inline char *devm_hwmon_sanitize_name(struct device *dev, const char *name)
+{
+	return ERR_PTR(-ENODEV);
+}
+
+#endif /* CONFIG_HWMON */
+
 /**
  * hwmon_is_bad_char - Is the char invalid in a hwmon name
  * @ch: the char to be considered
@@ -490,4 +564,4 @@ static inline bool hwmon_is_bad_char(const char ch)
 	}
 }

-#endif
+#endif /* _HWMON_H_ */
--
2.30.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ