From nobody Sat Nov 23 12:59:48 2024 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 D577113C661; Mon, 18 Nov 2024 06:16:03 +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=1731910567; cv=none; b=JRZQ55Vufy/eGNZo2BTh6h7xTPvQNMOry2K3JHe+hPX42tfdB8Csq6KVvrWn34lPxN7Er0bQzw9BAmmvu3QgYmNZ0F03DSdQ9e1IpS/XvbUTqmc9Qyx5+sSt+lOnH7o2hXob32pMqhERPbe/e/9czrTxwz0WWf7W5Kv4Uef0xrE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731910567; c=relaxed/simple; bh=8l9BbI5wmQ7Yg0khc+4YV+pJmUQSE6mzpNDquJJs/Iw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=jZyzKzsDI/X7e5jTnk1HTKZ5pAfkb9eEPnjrsUQQZn+Fa2BUHilaVG3bA1glT91EHXikl66Tss8hb4Z861m7wZD9i/Pf56Qpf305c4VRerVOJJ/nFELsjBX7Mwbfm3mgqcdGJ6L2HWVN99eslfLb/AEEx8zTInAWTKvxP8UKlMY= 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=tRsR6ChK; 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="tRsR6ChK" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1731910561; bh=8l9BbI5wmQ7Yg0khc+4YV+pJmUQSE6mzpNDquJJs/Iw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=tRsR6ChKaDQ5fmLTPv1Npm5C0+tIX36pWGXcALJxsSrn/HLK0ecLSCDteslIGXEdY Kb8BFOGFa85PXlQMAB90/hR7U6VyZdbIk7o7UO4bLNf146orWPKpUIFiAUvJBaRV4+ 3S+vcvwwWu9kYzufBf9femZulpoH4K7OzJ/qCLOw= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Mon, 18 Nov 2024 07:15:58 +0100 Subject: [PATCH v3 1/2] thermal: core: Add stub for thermal_zone_device_update() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241118-hwmon-thermal-v3-1-9c17973e7342@weissschuh.net> References: <20241118-hwmon-thermal-v3-0-9c17973e7342@weissschuh.net> In-Reply-To: <20241118-hwmon-thermal-v3-0-9c17973e7342@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=1731910561; l=1036; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=8l9BbI5wmQ7Yg0khc+4YV+pJmUQSE6mzpNDquJJs/Iw=; b=8sUbc9kO+kGIUbDCUM8i2ThbUYCshpKkJ6FQovZGVJXeM66tYi+q7DHbSLr7UDLhLcqW1BpiM y0s5vJq3nRTDcEl+KJcb/9GBjoM6z+1WR5wtCgaXOykk6XS+qPmz7yg 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=C3=9Fschuh 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..455e0814b9165dbb96d698e670f= 160136a017cc4 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -289,6 +289,10 @@ static inline struct thermal_zone_device *thermal_trip= less_zone_device_register( static inline void thermal_zone_device_unregister(struct thermal_zone_devi= ce *tz) { } =20 +static inline void thermal_zone_device_update(struct thermal_zone_device *= tz, + enum thermal_notify_event event) +{ } + static inline struct thermal_cooling_device * thermal_cooling_device_register(const char *type, void *devdata, const struct thermal_cooling_device_ops *ops) --=20 2.47.0 From nobody Sat Nov 23 12:59:48 2024 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 D56E680BFF; Mon, 18 Nov 2024 06:16:03 +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=1731910568; cv=none; b=S1wpn/ETvpHFQM3J9zhpPGQMi7Z6zt86lJBTVgNSwCIR6ORpSspJ/0DWWDfX5PLsMwkrniZIo0MKCZKl1jBCPARhMNWHMiecKPi71CLxCEswtbtgOd4NMGTLsX749SgQ2AFi85yD79CSFLr3qI9/Kss/9f+3vzg5ky6EFygS7Ko= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731910568; c=relaxed/simple; bh=XQgvZFznm/KTm80suFUAjYCJpg8vLqeuB0js8ihQD+w=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=pyEG12Y2RVEcMOVmQqRNCvhwmFNtf/bBUYszZjZc/kMGQQJmTSrtlSmFyj2m/V0uBBiF13CIScVbmyC6Ais2ICLmBVXS26Y3GJjG3CLJaBKFhlIrg5yMCsTbPwxppI6rkXgVW76q/9uLokyYKhlbDoDWU4EPg4cvqXPDpl3TCO4= 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=gvwt19Ie; 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="gvwt19Ie" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1731910561; bh=XQgvZFznm/KTm80suFUAjYCJpg8vLqeuB0js8ihQD+w=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=gvwt19Iel5AVInp6oXH5A1Cbzqlqs/6PDKtFpkkHaawZQ76C7Nk+o4TWPz5JQziyf Rhwm1WDvNdDuCcJKBpowoDZm/apEj6WTenoiUIkU8y6nTqzYOykzZLkP4Rkhg2SCoa 4Ko9Ie+xuSCCrc976ThnU50SfbjIBxEPbI9KbsrU= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Mon, 18 Nov 2024 07:15:59 +0100 Subject: [PATCH v3 2/2] hwmon: (core) Avoid ifdef CONFIG_THERMAL in C source file Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241118-hwmon-thermal-v3-2-9c17973e7342@weissschuh.net> References: <20241118-hwmon-thermal-v3-0-9c17973e7342@weissschuh.net> In-Reply-To: <20241118-hwmon-thermal-v3-0-9c17973e7342@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=1731910561; l=2293; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=XQgvZFznm/KTm80suFUAjYCJpg8vLqeuB0js8ihQD+w=; b=WEIs60uRkDtK8HMWMK5J2YA8reycwreYFxJTMjU5qXgPwOujG0KcQfIUaSPKnVj69BdehRPWa +e2AJ6tqDpRB4R6XrF9oM92haadQmnuBy957+ActuAPb7GiEM9lJWU4 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=C3=9Fschuh 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..86fb674c85d3f54d475be014c3f= d3dd74c815c57 100644 --- a/drivers/hwmon/hwmon.c +++ b/drivers/hwmon/hwmon.c @@ -147,11 +147,6 @@ static DEFINE_IDA(hwmon_ida); =20 /* Thermal zone handling */ =20 -/* - * 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 *tem= p) { struct hwmon_thermal_data *tdata =3D thermal_zone_device_priv(tz); @@ -257,6 +252,9 @@ static int hwmon_thermal_register_sensors(struct device= *dev) void *drvdata =3D dev_get_drvdata(dev); int i; =20 + if (!IS_ENABLED(CONFIG_THERMAL_OF)) + return 0; + for (i =3D 1; info[i]; i++) { int j; =20 @@ -285,6 +283,9 @@ static void hwmon_thermal_notify(struct device *dev, in= t index) struct hwmon_device *hwdev =3D to_hwmon_device(dev); struct hwmon_thermal_data *tzdata; =20 + if (!IS_ENABLED(CONFIG_THERMAL_OF)) + return; + list_for_each_entry(tzdata, &hwdev->tzdata, node) { if (tzdata->index =3D=3D index) { thermal_zone_device_update(tzdata->tzd, @@ -293,16 +294,6 @@ static void hwmon_thermal_notify(struct device *dev, i= nt index) } } =20 -#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 =3D=3D hwmon_in || type =3D=3D hwmon_intrusion) --=20 2.47.0