From patchwork Fri Nov 15 16:40:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 13876609 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9B37C1D63ED; Fri, 15 Nov 2024 16:40:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731688838; cv=none; b=aDKQZouT2wCJHfLgE4Bn3SfAicc7u/66Y38NpZeoKHcbzN3sSTdz4+7JwQUKi6I34XpVbBBKAKVMwztdW4gnoQJYGwC+mBLNXu5z06+UTIDsD4nbIYBtGESY9J5xmxPKeJDj7oSVP832WKtyJj0IPG0R1fvM9Zjqd6TEwKgO2Ac= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731688838; c=relaxed/simple; bh=ReJ9dLJkmJ51yM3qtvDgNGGTzsQWCETDqLee/2ZGECU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=QfviTu993UlkGHM8jX5lJH8JhYZLvYP844NqLE0lXfI8OXzney75WUJ15xue8uCaUNrwBnotj4+zAfUW1yQFIlPVQBZKM+9J7G/QbhUTGCsgcOuF+muX76u5vd9rodvDZilG7jFAt9WwB/TUagi0IN0D4n7llstYn9MoZAnltnw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=slEGHZr3; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="slEGHZr3" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1731688833; bh=ReJ9dLJkmJ51yM3qtvDgNGGTzsQWCETDqLee/2ZGECU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=slEGHZr3q5L3EQXl9KA6zoJ0gygaovxX3gl9AQ9v7dhqZNuBRGodaiFT0QReAqa81 fkdsNyC6mDKjTt7UepodSw1tmiDFqmmmd+ybxPwM6mLYf+UG1woSp5YzcLOwreI+YA o7oFigGABVMwEqAabgXKblItwGs7jTVJ9TgUFPz0= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Fri, 15 Nov 2024 17:40:21 +0100 Subject: [PATCH v2 1/2] thermal: core: Add stub for thermal_zone_device_update() Precedence: bulk X-Mailing-List: linux-hwmon@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241115-hwmon-thermal-v2-1-c96f0c0984b2@weissschuh.net> References: <20241115-hwmon-thermal-v2-0-c96f0c0984b2@weissschuh.net> In-Reply-To: <20241115-hwmon-thermal-v2-0-c96f0c0984b2@weissschuh.net> To: Jean Delvare , Guenter Roeck , "Rafael J. Wysocki" , Daniel Lezcano , Zhang Rui , Lukasz Luba Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1731688832; l=979; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=ReJ9dLJkmJ51yM3qtvDgNGGTzsQWCETDqLee/2ZGECU=; b=2cRIq3RMhZMNSp+W/2tI2ZAdtQSuWltRIMZ43F5qnGgb3jPt6HKBTKeqgAat97HQ4pU5ne5bv xQJN6T4RnQkB4rlhuIogobSfYvQlpFXu0KjV9JpieFyARKvBCsw6DqF X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= To simplify the !CONFIG_THERMAL case in the hwmon core, add a !CONFIG_THERMAL stub for thermal_zone_device_update(). Signed-off-by: Thomas Weißschuh Reviewed-by: Guenter Roeck --- include/linux/thermal.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/linux/thermal.h b/include/linux/thermal.h index 25ea8fe2313e6d0a53192974a80d92f50f0ff03e..93880b7bd7d92df5a631f297664b9ba37146fd6a 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -289,6 +289,10 @@ static inline struct thermal_zone_device *thermal_tripless_zone_device_register( static inline void thermal_zone_device_unregister(struct thermal_zone_device *tz) { } +static inline void thermal_zone_device_update(struct thermal_zone_device *, + enum thermal_notify_event) +{ } + static inline struct thermal_cooling_device * thermal_cooling_device_register(const char *type, void *devdata, const struct thermal_cooling_device_ops *ops) From patchwork Fri Nov 15 16:40:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 13876610 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9B3291D54E2; Fri, 15 Nov 2024 16:40:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731688839; cv=none; b=BOGfuNcZK9P0eVsX2wXvyt9psaGF3wjjbHg1ZmhdD7eo8gs8PnpN7nsNXsIyg9wLQMdx+I1OkRL+04s4mT4FTEUb7J3sSfU3t4LTSPfcoN2dF0R+zps9db68VeUGS2vRaOWCLtY/0CAb6r1ZiTrH594hD2VcyxKN7i4i8Dbh/YE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731688839; c=relaxed/simple; bh=1e2MdMIpanCLg0wxHT99JjjTP4bqY2r+O1WXkWJfGM0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=lWRy8hRwq8dxPVpnbtGo+oOpTxbIoxCB1+iktLmR//dQ+zAz4+Jnn1qMpOKBjMmD4sG/m4S/L5yyfSYz9C1Dkqza3L7gd/2uFpl5r9Wtqhz01KBk2wTYxdBCBY+19nhD0VviOWtF4gJNNFvU210y3LPyfLvukbYUORnsjDSYAOc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=hzX50RV9; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="hzX50RV9" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1731688833; bh=1e2MdMIpanCLg0wxHT99JjjTP4bqY2r+O1WXkWJfGM0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=hzX50RV9Mlyu+kL5m3zfsA+HW9SwxNkHzt942adCrq1GQYiniiTHeQ6U22aNyI1eS orzGNGHslb5B4CuJHaFE0pp4s9BJEG11q/hxYOljB3/ZtnNoSqbU75nB7KztIjRxtd RNza95arS4Y6CbcwqdoOVTFUN2IEdTzTSsSbFVnA= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Fri, 15 Nov 2024 17:40:22 +0100 Subject: [PATCH v2 2/2] hwmon: (core) Avoid ifdef CONFIG_THERMAL in C source file Precedence: bulk X-Mailing-List: linux-hwmon@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241115-hwmon-thermal-v2-2-c96f0c0984b2@weissschuh.net> References: <20241115-hwmon-thermal-v2-0-c96f0c0984b2@weissschuh.net> In-Reply-To: <20241115-hwmon-thermal-v2-0-c96f0c0984b2@weissschuh.net> To: Jean Delvare , Guenter Roeck , "Rafael J. Wysocki" , Daniel Lezcano , Zhang Rui , Lukasz Luba Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1731688832; l=2244; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=1e2MdMIpanCLg0wxHT99JjjTP4bqY2r+O1WXkWJfGM0=; b=CudI3w6szC9y5R/Bn6Zz1jMnejHVaSy3O0VTsdGs4nmc6S7eTJoeJcDpVv6I/RgdmVad9LzLt QxZseQvTvZTAchZ6+bRkeB4UmEh9+DEFn65zAGLjmK6LTU5nBmd04Ho X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= Using an #ifdef in a C source files to have different definitions of the same symbol makes the code harder to read and understand. Furthermore it makes it harder to test compilation of the different branches. Replace the ifdeffery with IS_ENABLED() which is just a normal conditional. The resulting binary is still the same as before as the compiler optimizes away all the unused code and definitions. Signed-off-by: Thomas Weißschuh Reviewed-by: Guenter Roeck --- drivers/hwmon/hwmon.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c index 9c35c4d0369d7aad7ea61ccd25f4f63fc98b9e02..86fb674c85d3f54d475be014c3fd3dd74c815c57 100644 --- a/drivers/hwmon/hwmon.c +++ b/drivers/hwmon/hwmon.c @@ -147,11 +147,6 @@ static DEFINE_IDA(hwmon_ida); /* Thermal zone handling */ -/* - * The complex conditional is necessary to avoid a cyclic dependency - * between hwmon and thermal_sys modules. - */ -#ifdef CONFIG_THERMAL_OF static int hwmon_thermal_get_temp(struct thermal_zone_device *tz, int *temp) { struct hwmon_thermal_data *tdata = thermal_zone_device_priv(tz); @@ -257,6 +252,9 @@ static int hwmon_thermal_register_sensors(struct device *dev) void *drvdata = dev_get_drvdata(dev); int i; + if (!IS_ENABLED(CONFIG_THERMAL_OF)) + return 0; + for (i = 1; info[i]; i++) { int j; @@ -285,6 +283,9 @@ static void hwmon_thermal_notify(struct device *dev, int index) struct hwmon_device *hwdev = to_hwmon_device(dev); struct hwmon_thermal_data *tzdata; + if (!IS_ENABLED(CONFIG_THERMAL_OF)) + return; + list_for_each_entry(tzdata, &hwdev->tzdata, node) { if (tzdata->index == index) { thermal_zone_device_update(tzdata->tzd, @@ -293,16 +294,6 @@ static void hwmon_thermal_notify(struct device *dev, int index) } } -#else -static int hwmon_thermal_register_sensors(struct device *dev) -{ - return 0; -} - -static void hwmon_thermal_notify(struct device *dev, int index) { } - -#endif /* IS_REACHABLE(CONFIG_THERMAL) && ... */ - static int hwmon_attr_base(enum hwmon_sensor_types type) { if (type == hwmon_in || type == hwmon_intrusion)