From patchwork Sat Aug 13 00:37:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 9278217 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C22EA60780 for ; Sat, 13 Aug 2016 00:37:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A7A6228AFB for ; Sat, 13 Aug 2016 00:37:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9908728B32; Sat, 13 Aug 2016 00:37:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 08D3028AFB for ; Sat, 13 Aug 2016 00:37:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752147AbcHMAhZ (ORCPT ); Fri, 12 Aug 2016 20:37:25 -0400 Received: from bh-25.webhostbox.net ([208.91.199.152]:55220 "EHLO bh-25.webhostbox.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752040AbcHMAhZ (ORCPT ); Fri, 12 Aug 2016 20:37:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=roeck-us.net; s=default; h=Message-Id:Date:Subject:Cc:To:From; bh=KQrn4PMhTd7Q+Q3xwzR1YLUwojfmN0P1XE265hyxQmU=; b=b6XuHH4dgoMA403JBOR3V8S8z/ DuSuYP9Cprr3W4ucmS+Hek9gjvypvfEU/dPH8zDwUSmYRcGcnPPSePk6hb72xKVIMEKwL80uSDYU8 rvHUE+fdLnNbxSjnnbyfVK7AFWRPL17ZIW6MLRQ8z9e4rZ7BN0CHwzLg0YhwZgJQ4sAR3iGM7q/1j cTLWeeQcYr3/DneVLFd+KsHtZ2N6scnjxOs0lS9QsynbZwhgD/jXhsIktetPvSKWhfK1usN3bwFb1 13mYXPo7u0WtuOueynOlgdNZXgJv3KAuw5ht500Yzb51h+AbWm+EVSwsyMn9O7nNGZiV8ACPry0pQ bKqXoA4w==; Received: from 108-223-40-66.lightspeed.sntcca.sbcglobal.net ([108.223.40.66]:44946 helo=localhost) by bh-25.webhostbox.net with esmtpa (Exim 4.86_1) (envelope-from ) id 1bYMx0-0041ud-Ef; Sat, 13 Aug 2016 00:37:22 +0000 From: Guenter Roeck To: Hardware Monitoring Cc: Jean Delvare , Guenter Roeck , Keerthy J Subject: [PATCH] hwmon: (core) Avoid cyclic dependency between hwmon and thermal_sys Date: Fri, 12 Aug 2016 17:37:19 -0700 Message-Id: <1471048639-9792-1-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.5.0 X-Authenticated_sender: guenter@roeck-us.net X-OutGoing-Spam-Status: No, score=-1.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - bh-25.webhostbox.net X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - roeck-us.net X-Get-Message-Sender-Via: bh-25.webhostbox.net: authenticated_id: guenter@roeck-us.net X-Authenticated-Sender: bh-25.webhostbox.net: guenter@roeck-us.net X-Source: X-Source-Args: X-Source-Dir: Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Cc: Keerthy J Signed-off-by: Guenter Roeck --- 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 */