Skip to content

Commit

Permalink
hwmon: (core) Avoid cyclic dependency between hwmon and thermal_sys
Browse files Browse the repository at this point in the history
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 <[email protected]>
Cc: Keerthy J <[email protected]>
Signed-off-by: Guenter Roeck <[email protected]>
  • Loading branch information
groeck committed Sep 9, 2016
1 parent aa18cc9 commit 86430c1
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions drivers/hwmon/hwmon.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 */

Expand Down

0 comments on commit 86430c1

Please sign in to comment.