* [PATCH] hwmon: (core) Avoid cyclic dependency between hwmon and thermal_sys
@ 2016-08-13  0:37 Guenter Roeck
  0 siblings, 0 replies; only message in thread
From: Guenter Roeck @ 2016-08-13  0:37 UTC (permalink / raw)
  To: Hardware Monitoring; +Cc: Jean Delvare, Guenter Roeck, Keerthy J
If both hwmon and thermal_sys are built as modules, and
CONFIG_THERMAL_HWMON is enabled, the following cyclic module dependency
is reported.
depmod: ERROR: Found 2 modules in dependency cycles!
depmod: ERROR: Cycle detected: hwmon -> thermal_sys -> hwmon
Fixes: e4bce763adb2 ("hwmon: (core) New hwmon registration API")
Reported-by: Vignesh R <vigneshr@ti.com>
Cc: Keerthy J <j-keerthy@ti.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
 drivers/hwmon/hwmon.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c
index fade170977e8..adae6848ffb2 100644
--- a/drivers/hwmon/hwmon.c
+++ b/drivers/hwmon/hwmon.c
@@ -108,7 +108,13 @@ static DEFINE_IDA(hwmon_ida);
 
 /* Thermal zone handling */
 
-#if IS_REACHABLE(CONFIG_THERMAL) && defined(CONFIG_THERMAL_OF)
+/*
+ * The complex conditional is necessary to avoid a cyclic dependency
+ * between hwmon and thermal_sys modules.
+ */
+#if IS_REACHABLE(CONFIG_THERMAL) && defined(CONFIG_THERMAL_OF) && \
+	(!defined(CONFIG_THERMAL_HWMON) || \
+	 !(defined(MODULE) && IS_MODULE(CONFIG_THERMAL)))
 static int hwmon_thermal_get_temp(void *data, int *temp)
 {
 	struct hwmon_thermal_data *tdata = data;
@@ -153,7 +159,7 @@ static int hwmon_thermal_add_sensor(struct device *dev,
 {
 	return 0;
 }
-#endif /* IS_REACHABLE(CONFIG_THERMAL) && defined(CONFIG_THERMAL_OF) */
+#endif /* IS_REACHABLE(CONFIG_THERMAL) && ... */
 
 /* sysfs attribute management */
 
-- 
2.5.0
^ permalink raw reply related	[flat|nested] only message in thread
only message in thread, other threads:[~2016-08-13  0:37 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-13  0:37 [PATCH] hwmon: (core) Avoid cyclic dependency between hwmon and thermal_sys Guenter Roeck
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).