From patchwork Tue Apr 7 17:49:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Pietrasiewicz X-Patchwork-Id: 11478495 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2EA5B913 for ; Tue, 7 Apr 2020 17:49:50 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 055662075E for ; Tue, 7 Apr 2020 17:49:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="PWw6Foip" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 055662075E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=collabora.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=r3X9s9jZp3eaxTSinOeSFJhy9+xUbpa9Rd0xX6MGg90=; b=PWw6FoipMUQqZXwOGBmWWSzCdB p4eglKK9QXg0rw4bso3QB1Uew8FAJzEHBZiXVpM2yGR5qKULTUV2VkhPqSVFLF/Ypu11GWy4QM3RV ZCqizEPG9Xvqct9W+r2Dpl6HX9U9r2TR3Zs1B1Akh4hwjUNOxHFoyB7d7QRPYpxniTggXEFQmZak1 xocRKbe4+J3/8ynh6J5+lqpMhGOu3OqCZcd5JtI9XD0cBZjqFWU2QCeY6TA4SXqE4r1Py4fz0nin2 wyqp9ewbkVzNRbVH0l4JCuIvJrBxX9eUypeu0jmVKSIDX92Cfj1XbzEcrMpxdEznzCuwNWiB4nR3w Px6o61YA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jLsM6-0007b9-Sq; Tue, 07 Apr 2020 17:49:47 +0000 Received: from bhuna.collabora.co.uk ([2a00:1098:0:82:1000:25:2eeb:e3e3]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jLsLz-0007T4-BP for linux-arm-kernel@lists.infradead.org; Tue, 07 Apr 2020 17:49:40 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: andrzej.p) with ESMTPSA id 6EFCE2972A9 From: Andrzej Pietrasiewicz To: linux-pm@vger.kernel.org Subject: [RFC 1/8] thermal: int3400_thermal: Statically initialize .get_mode()/.set_mode() ops Date: Tue, 7 Apr 2020 19:49:19 +0200 Message-Id: <20200407174926.23971-2-andrzej.p@collabora.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200407174926.23971-1-andrzej.p@collabora.com> References: <20200407174926.23971-1-andrzej.p@collabora.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200407_104939_513641_A235AA1F X-CRM114-Status: UNSURE ( 9.27 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 0.0 UNPARSEABLE_RELAY Informational: message has unparseable relay lines X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Rafael J . Wysocki" , platform-driver-x86@vger.kernel.org, kernel@collabora.com, Fabio Estevam , Amit Kucheria , Daniel Lezcano , linux-acpi@vger.kernel.org, NXP Linux Team , Darren Hart , Zhang Rui , Gayatri Kammela , Len Brown , Sascha Hauer , Ido Schimmel , Jiri Pirko , Thomas Gleixner , Allison Randal , linux-arm-kernel@lists.infradead.org, Support Opensource , Shawn Guo , Peter Kaestle , Andrzej Pietrasiewicz , Pengutronix Kernel Team , netdev@vger.kernel.org, Enrico Weigelt , "David S . Miller" , Andy Shevchenko MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org int3400_thermal_ops is used inside int3400_thermal_probe() only after the assignments, which can just as well be made statically at struct's initizer. Signed-off-by: Andrzej Pietrasiewicz Reviewed-by: Bartlomiej Zolnierkiewicz --- drivers/thermal/intel/int340x_thermal/int3400_thermal.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/thermal/intel/int340x_thermal/int3400_thermal.c b/drivers/thermal/intel/int340x_thermal/int3400_thermal.c index efae0c02d898..634b943e9e3d 100644 --- a/drivers/thermal/intel/int340x_thermal/int3400_thermal.c +++ b/drivers/thermal/intel/int340x_thermal/int3400_thermal.c @@ -271,6 +271,8 @@ static int int3400_thermal_set_mode(struct thermal_zone_device *thermal, static struct thermal_zone_device_ops int3400_thermal_ops = { .get_temp = int3400_thermal_get_temp, + .get_mode = int3400_thermal_get_mode, + .set_mode = int3400_thermal_set_mode, }; static struct thermal_zone_params int3400_thermal_params = { @@ -309,9 +311,6 @@ static int int3400_thermal_probe(struct platform_device *pdev) platform_set_drvdata(pdev, priv); - int3400_thermal_ops.get_mode = int3400_thermal_get_mode; - int3400_thermal_ops.set_mode = int3400_thermal_set_mode; - priv->thermal = thermal_zone_device_register("INT3400 Thermal", 0, 0, priv, &int3400_thermal_ops, &int3400_thermal_params, 0, 0); From patchwork Tue Apr 7 17:49:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Pietrasiewicz X-Patchwork-Id: 11478527 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A5E8E913 for ; Tue, 7 Apr 2020 17:50:18 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 835F02075E for ; Tue, 7 Apr 2020 17:50:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="YUkKL1Mk" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 835F02075E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=collabora.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=H05K95XFs8BRjczSG9fLzoAPSCuT7ktfQQmWfu2sqxM=; b=YUkKL1MkZIOpRedrFvLHQYB+f1 XQjfjpLo5CoEQmUszQ4rDW3SYLnt+iHszp3dfQEWvsiNZIb5GV5TlE3rVQ3pgz8xWcQM/nh9+EvXL Lz+gtvSJePktiGT04YCYgIJQFp40GdugAFiv0hdg9JaTNNTb85WUh90J0/ot8F99cqmR/YmuQsE3n vclRC3maIXG4hfzcH9P1b3g8j378NaEMWEPautQvWbUxfm0tdNIrUWlrlmXb08G+/+hpzi2WLUc1K Kf5PN151mc1CudBvMdDz/N3XhuH0C8qDaQplEFQ9W4BnBtLnUrMU62dpjzKBiTiRpoB0bH9nNbWQr 2jA4RgLA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jLsMb-0001aH-Gc; Tue, 07 Apr 2020 17:50:17 +0000 Received: from bhuna.collabora.co.uk ([2a00:1098:0:82:1000:25:2eeb:e3e3]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jLsM2-0007U2-D2 for linux-arm-kernel@lists.infradead.org; Tue, 07 Apr 2020 17:49:44 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: andrzej.p) with ESMTPSA id 202672972AA From: Andrzej Pietrasiewicz To: linux-pm@vger.kernel.org Subject: [RFC 2/8] thermal: Properly handle mode values in .set_mode() Date: Tue, 7 Apr 2020 19:49:20 +0200 Message-Id: <20200407174926.23971-3-andrzej.p@collabora.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200407174926.23971-1-andrzej.p@collabora.com> References: <20200407174926.23971-1-andrzej.p@collabora.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200407_104942_612154_B830038A X-CRM114-Status: GOOD ( 11.19 ) X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 0.0 UNPARSEABLE_RELAY Informational: message has unparseable relay lines X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Rafael J . Wysocki" , platform-driver-x86@vger.kernel.org, kernel@collabora.com, Fabio Estevam , Amit Kucheria , Daniel Lezcano , linux-acpi@vger.kernel.org, NXP Linux Team , Darren Hart , Zhang Rui , Gayatri Kammela , Len Brown , Sascha Hauer , Ido Schimmel , Jiri Pirko , Thomas Gleixner , Allison Randal , linux-arm-kernel@lists.infradead.org, Support Opensource , Shawn Guo , Peter Kaestle , Andrzej Pietrasiewicz , Pengutronix Kernel Team , netdev@vger.kernel.org, Enrico Weigelt , "David S . Miller" , Andy Shevchenko MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Allow only THERMAL_DEVICE_ENABLED and THERMAL_DEVICE_DISABLED as valid states to transition to. Signed-off-by: Andrzej Pietrasiewicz --- drivers/net/ethernet/mellanox/mlxsw/core_thermal.c | 8 ++++++-- drivers/platform/x86/acerhdf.c | 4 ++++ drivers/thermal/imx_thermal.c | 4 +++- drivers/thermal/intel/intel_quark_dts_thermal.c | 5 ++++- drivers/thermal/of-thermal.c | 4 +++- 5 files changed, 20 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c index ce0a6837daa3..cd435ca7adbe 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c +++ b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c @@ -296,8 +296,10 @@ static int mlxsw_thermal_set_mode(struct thermal_zone_device *tzdev, if (mode == THERMAL_DEVICE_ENABLED) tzdev->polling_delay = thermal->polling_delay; - else + else if (mode == THERMAL_DEVICE_DISABLED) tzdev->polling_delay = 0; + else + return -EINVAL; mutex_unlock(&tzdev->lock); @@ -486,8 +488,10 @@ static int mlxsw_thermal_module_mode_set(struct thermal_zone_device *tzdev, if (mode == THERMAL_DEVICE_ENABLED) tzdev->polling_delay = thermal->polling_delay; - else + else if (mode == THERMAL_DEVICE_DISABLED) tzdev->polling_delay = 0; + else + return -EINVAL; mutex_unlock(&tzdev->lock); diff --git a/drivers/platform/x86/acerhdf.c b/drivers/platform/x86/acerhdf.c index 8cc86f4e3ac1..d5188c1d688b 100644 --- a/drivers/platform/x86/acerhdf.c +++ b/drivers/platform/x86/acerhdf.c @@ -431,6 +431,10 @@ static int acerhdf_get_mode(struct thermal_zone_device *thermal, static int acerhdf_set_mode(struct thermal_zone_device *thermal, enum thermal_device_mode mode) { + if (mode != THERMAL_DEVICE_DISABLED && + mode != THERMAL_DEVICE_ENABLED) + return -EINVAL; + if (mode == THERMAL_DEVICE_DISABLED && kernelmode) acerhdf_revert_to_bios_mode(); else if (mode == THERMAL_DEVICE_ENABLED && !kernelmode) diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c index bb6754a5342c..014512581918 100644 --- a/drivers/thermal/imx_thermal.c +++ b/drivers/thermal/imx_thermal.c @@ -368,7 +368,7 @@ static int imx_set_mode(struct thermal_zone_device *tz, data->irq_enabled = true; enable_irq(data->irq); } - } else { + } else if (mode == THERMAL_DEVICE_DISABLED) { regmap_write(map, soc_data->sensor_ctrl + REG_CLR, soc_data->measure_temp_mask); regmap_write(map, soc_data->sensor_ctrl + REG_SET, @@ -381,6 +381,8 @@ static int imx_set_mode(struct thermal_zone_device *tz, disable_irq(data->irq); data->irq_enabled = false; } + } else { + return -EINVAL; } data->mode = mode; diff --git a/drivers/thermal/intel/intel_quark_dts_thermal.c b/drivers/thermal/intel/intel_quark_dts_thermal.c index 5d33b350da1c..5f4bcc0e4fd3 100644 --- a/drivers/thermal/intel/intel_quark_dts_thermal.c +++ b/drivers/thermal/intel/intel_quark_dts_thermal.c @@ -328,8 +328,11 @@ static int sys_set_mode(struct thermal_zone_device *tzd, mutex_lock(&dts_update_mutex); if (mode == THERMAL_DEVICE_ENABLED) ret = soc_dts_enable(tzd); - else + else if (mode == THERMAL_DEVICE_DISABLED) ret = soc_dts_disable(tzd); + else + return -EINVAL; + mutex_unlock(&dts_update_mutex); return ret; diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c index ef0baa954ff0..b7621dfab17c 100644 --- a/drivers/thermal/of-thermal.c +++ b/drivers/thermal/of-thermal.c @@ -289,9 +289,11 @@ static int of_thermal_set_mode(struct thermal_zone_device *tz, if (mode == THERMAL_DEVICE_ENABLED) { tz->polling_delay = data->polling_delay; tz->passive_delay = data->passive_delay; - } else { + } else if (mode == THERMAL_DEVICE_DISABLED) { tz->polling_delay = 0; tz->passive_delay = 0; + } else { + return -EINVAL; } mutex_unlock(&tz->lock); From patchwork Tue Apr 7 17:49:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Pietrasiewicz X-Patchwork-Id: 11478529 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4C9EE15AB for ; Tue, 7 Apr 2020 17:50:32 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 29DBE2075E for ; Tue, 7 Apr 2020 17:50:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="nXz2Fi7H" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 29DBE2075E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=collabora.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=kyNS1Fmxuf5CpqM05qfjLMhfgNKea9EbX0/8ejxAQUM=; b=nXz2Fi7HuxzmMNYn8rnEfeeONu hwMbMjXXzJ5dChbX1WgVVGJOv0WzIQBbtLP7huLsXwmeWUtXBbc8y+ulf0H1V/oxfbJA+p31gqbid MvmlpSge5/X2xaV71ig85pehsE3YbtOXJqZn8PzR1bh8/QFvzVzwzeY54B3g6CTuxwHIGZjujMog9 JSTrhewke6ZOUAvrCSz5ZiqMq3uBL9oajTSoX+1baEwYuJZ20063tvEvng7nXDRYz4XTh0y+ZJN5J 0yGuxKDwUGiGhbnoDua3xVx0PphqklPJ8maLDcNxCj2ulnOf2yYtZxcXEJr62TI1ZitCI4cAA2nfg h7SbQt3A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jLsMn-0002G0-Lh; Tue, 07 Apr 2020 17:50:29 +0000 Received: from bhuna.collabora.co.uk ([2a00:1098:0:82:1000:25:2eeb:e3e3]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jLsM4-0007XX-Fq for linux-arm-kernel@lists.infradead.org; Tue, 07 Apr 2020 17:49:46 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: andrzej.p) with ESMTPSA id F094F2972AE From: Andrzej Pietrasiewicz To: linux-pm@vger.kernel.org Subject: [RFC 3/8] thermal: Store thermal mode in a dedicated enum Date: Tue, 7 Apr 2020 19:49:21 +0200 Message-Id: <20200407174926.23971-4-andrzej.p@collabora.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200407174926.23971-1-andrzej.p@collabora.com> References: <20200407174926.23971-1-andrzej.p@collabora.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200407_104944_800120_10FCA80C X-CRM114-Status: GOOD ( 12.58 ) X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 0.0 UNPARSEABLE_RELAY Informational: message has unparseable relay lines X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Rafael J . Wysocki" , platform-driver-x86@vger.kernel.org, kernel@collabora.com, Fabio Estevam , Amit Kucheria , Daniel Lezcano , linux-acpi@vger.kernel.org, NXP Linux Team , Darren Hart , Zhang Rui , Gayatri Kammela , Len Brown , Sascha Hauer , Ido Schimmel , Jiri Pirko , Thomas Gleixner , Allison Randal , linux-arm-kernel@lists.infradead.org, Support Opensource , Shawn Guo , Peter Kaestle , Andrzej Pietrasiewicz , Pengutronix Kernel Team , netdev@vger.kernel.org, Enrico Weigelt , "David S . Miller" , Andy Shevchenko MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Prepare for adding THERMAL_DEVICE_INITIAL mode. Signed-off-by: Andrzej Pietrasiewicz --- drivers/acpi/thermal.c | 27 +++++++++---------- drivers/platform/x86/acerhdf.c | 12 ++++++--- .../intel/int340x_thermal/int3400_thermal.c | 18 +++++-------- 3 files changed, 27 insertions(+), 30 deletions(-) diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c index 19067a5e5293..a93b0412dd6b 100644 --- a/drivers/acpi/thermal.c +++ b/drivers/acpi/thermal.c @@ -172,7 +172,7 @@ struct acpi_thermal { struct acpi_thermal_trips trips; struct acpi_handle_list devices; struct thermal_zone_device *thermal_zone; - int tz_enabled; + enum thermal_device_mode mode; int kelvin_offset; /* in millidegrees */ struct work_struct thermal_check_work; }; @@ -500,7 +500,7 @@ static void acpi_thermal_check(void *data) { struct acpi_thermal *tz = data; - if (!tz->tz_enabled) + if (tz->mode != THERMAL_DEVICE_ENABLED) return; thermal_zone_device_update(tz->thermal_zone, @@ -534,8 +534,7 @@ static int thermal_get_mode(struct thermal_zone_device *thermal, if (!tz) return -EINVAL; - *mode = tz->tz_enabled ? THERMAL_DEVICE_ENABLED : - THERMAL_DEVICE_DISABLED; + *mode = tz->mode; return 0; } @@ -544,27 +543,25 @@ static int thermal_set_mode(struct thermal_zone_device *thermal, enum thermal_device_mode mode) { struct acpi_thermal *tz = thermal->devdata; - int enable; if (!tz) return -EINVAL; + if (mode != THERMAL_DEVICE_DISABLED && + mode != THERMAL_DEVICE_ENABLED) + return -EINVAL; /* * enable/disable thermal management from ACPI thermal driver */ - if (mode == THERMAL_DEVICE_ENABLED) - enable = 1; - else if (mode == THERMAL_DEVICE_DISABLED) { - enable = 0; + if (mode == THERMAL_DEVICE_DISABLED) pr_warn("thermal zone will be disabled\n"); - } else - return -EINVAL; - if (enable != tz->tz_enabled) { - tz->tz_enabled = enable; + if (mode != tz->mode) { + tz->mode = mode; ACPI_DEBUG_PRINT((ACPI_DB_INFO, "%s kernel ACPI thermal control\n", - tz->tz_enabled ? "Enable" : "Disable")); + tz->mode == THERMAL_DEVICE_ENABLED ? + "Enable" : "Disable")); acpi_thermal_check(tz); } return 0; @@ -913,7 +910,7 @@ static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz) if (ACPI_FAILURE(status)) return -ENODEV; - tz->tz_enabled = 1; + tz->mode = THERMAL_DEVICE_ENABLED; dev_info(&tz->device->dev, "registered as thermal_zone%d\n", tz->thermal_zone->id); diff --git a/drivers/platform/x86/acerhdf.c b/drivers/platform/x86/acerhdf.c index d5188c1d688b..87e357017d4a 100644 --- a/drivers/platform/x86/acerhdf.c +++ b/drivers/platform/x86/acerhdf.c @@ -65,8 +65,10 @@ #ifdef START_IN_KERNEL_MODE static int kernelmode = 1; +static enum thermal_device_mode thermal_mode = THERMAL_DEVICE_ENABLED; #else static int kernelmode; +static enum thermal_device_mode thermal_mode = THERMAL_DEVICE_DISABLED; #endif static unsigned int interval = 10; @@ -416,8 +418,7 @@ static int acerhdf_get_mode(struct thermal_zone_device *thermal, if (verbose) pr_notice("kernel mode fan control %d\n", kernelmode); - *mode = (kernelmode) ? THERMAL_DEVICE_ENABLED - : THERMAL_DEVICE_DISABLED; + *mode = thermal_mode; return 0; } @@ -435,10 +436,13 @@ static int acerhdf_set_mode(struct thermal_zone_device *thermal, mode != THERMAL_DEVICE_ENABLED) return -EINVAL; - if (mode == THERMAL_DEVICE_DISABLED && kernelmode) + if (mode == THERMAL_DEVICE_DISABLED && kernelmode) { acerhdf_revert_to_bios_mode(); - else if (mode == THERMAL_DEVICE_ENABLED && !kernelmode) + thermal_mode = THERMAL_DEVICE_DISABLED; + } else if (mode == THERMAL_DEVICE_ENABLED && !kernelmode) { acerhdf_enable_kernelmode(); + thermal_mode = THERMAL_DEVICE_ENABLED; + } return 0; } diff --git a/drivers/thermal/intel/int340x_thermal/int3400_thermal.c b/drivers/thermal/intel/int340x_thermal/int3400_thermal.c index 634b943e9e3d..fcbd1b14fa74 100644 --- a/drivers/thermal/intel/int340x_thermal/int3400_thermal.c +++ b/drivers/thermal/intel/int340x_thermal/int3400_thermal.c @@ -44,7 +44,7 @@ static char *int3400_thermal_uuids[INT3400_THERMAL_MAXIMUM_UUID] = { struct int3400_thermal_priv { struct acpi_device *adev; struct thermal_zone_device *thermal; - int mode; + enum thermal_device_mode mode; int art_count; struct art *arts; int trt_count; @@ -247,24 +247,20 @@ static int int3400_thermal_set_mode(struct thermal_zone_device *thermal, enum thermal_device_mode mode) { struct int3400_thermal_priv *priv = thermal->devdata; - bool enable; int result = 0; if (!priv) return -EINVAL; - if (mode == THERMAL_DEVICE_ENABLED) - enable = true; - else if (mode == THERMAL_DEVICE_DISABLED) - enable = false; - else + if (mode != THERMAL_DEVICE_ENABLED && + mode != THERMAL_DEVICE_DISABLED) return -EINVAL; - if (enable != priv->mode) { - priv->mode = enable; + if (mode != priv->mode) { + priv->mode = mode; result = int3400_thermal_run_osc(priv->adev->handle, - priv->current_uuid_index, - enable); + priv->current_uuid_index, + mode == THERMAL_DEVICE_ENABLED); } return result; } From patchwork Tue Apr 7 17:49:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Pietrasiewicz X-Patchwork-Id: 11478531 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BFD3F913 for ; Tue, 7 Apr 2020 17:50:46 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9A7A42075E for ; Tue, 7 Apr 2020 17:50:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="noyjiOBH" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9A7A42075E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=collabora.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=n8Cd0UbZnClA83Dj2HA2Zd5Qcv0A3rZLMT3mGRIaoJU=; b=noyjiOBHK/lIJBUw+lSvN4HowN wP85sQcUWpmhcaUK/1aXFPWOHaZSJ8CcAYdcIJNCEdoPh8Z9qqJZOYLzfiz5v1ewONPTTe2Zikc6V Klt1sxWVli5PTuC1e0Mzr0OmuJAvLYETjBvlxK4si4y9ZxVtauOlHPEY6w6hmqetuD85r4sg5twua ebtT4H1+73Co/q2i3zl/5FrznBov/wf6dVnQKEi0KDVWqOMcDB2Hff1a8/JG8YTh8iO8AdbKbDosl iKHtq0izOsJH2wYhvMoZIldRcoU4/Mm0wkdLXc9gTLSHmF/9K4yAvVuqr2wnMx8M2c7B64IHvoXjo niKJKSDg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jLsN1-0002XX-7S; Tue, 07 Apr 2020 17:50:43 +0000 Received: from bhuna.collabora.co.uk ([46.235.227.227]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jLsM6-0007at-Io for linux-arm-kernel@lists.infradead.org; Tue, 07 Apr 2020 17:49:48 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: andrzej.p) with ESMTPSA id 53C822972A7 From: Andrzej Pietrasiewicz To: linux-pm@vger.kernel.org Subject: [RFC 4/8] thermal: core: Introduce THERMAL_DEVICE_INITIAL Date: Tue, 7 Apr 2020 19:49:22 +0200 Message-Id: <20200407174926.23971-5-andrzej.p@collabora.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200407174926.23971-1-andrzej.p@collabora.com> References: <20200407174926.23971-1-andrzej.p@collabora.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200407_104946_779220_D2D92D72 X-CRM114-Status: UNSURE ( 9.61 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [46.235.227.227 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 0.0 UNPARSEABLE_RELAY Informational: message has unparseable relay lines X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Rafael J . Wysocki" , platform-driver-x86@vger.kernel.org, kernel@collabora.com, Fabio Estevam , Amit Kucheria , Daniel Lezcano , linux-acpi@vger.kernel.org, NXP Linux Team , Darren Hart , Zhang Rui , Gayatri Kammela , Len Brown , Sascha Hauer , Ido Schimmel , Jiri Pirko , Thomas Gleixner , Allison Randal , linux-arm-kernel@lists.infradead.org, Support Opensource , Shawn Guo , Peter Kaestle , Andrzej Pietrasiewicz , Pengutronix Kernel Team , netdev@vger.kernel.org, Enrico Weigelt , "David S . Miller" , Andy Shevchenko MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Add a new mode: THERMAL_DEVICE_INITIAL. It is dedicated to handle devices which must be initially DISABLED, but which are polled at startup nonetheless. THERMAL_DEVICE_INITIAL shall be reported as "enabled" in sysfs to keep the userspace interface intact. Signed-off-by: Andrzej Pietrasiewicz --- drivers/thermal/thermal_sysfs.c | 4 ++-- include/linux/thermal.h | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/thermal/thermal_sysfs.c b/drivers/thermal/thermal_sysfs.c index aa99edb4dff7..6bfef21abce4 100644 --- a/drivers/thermal/thermal_sysfs.c +++ b/drivers/thermal/thermal_sysfs.c @@ -59,8 +59,8 @@ mode_show(struct device *dev, struct device_attribute *attr, char *buf) if (result) return result; - return sprintf(buf, "%s\n", mode == THERMAL_DEVICE_ENABLED ? "enabled" - : "disabled"); + return sprintf(buf, "%s\n", mode == THERMAL_DEVICE_DISABLED ? "disabled" + : "enabled"); } static ssize_t diff --git a/include/linux/thermal.h b/include/linux/thermal.h index 126913c6a53b..1bc6b7998093 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -48,8 +48,9 @@ struct thermal_cooling_device; struct thermal_instance; enum thermal_device_mode { - THERMAL_DEVICE_DISABLED = 0, + THERMAL_DEVICE_INITIAL = 0, THERMAL_DEVICE_ENABLED, + THERMAL_DEVICE_DISABLED, }; enum thermal_trip_type { From patchwork Tue Apr 7 17:49:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Pietrasiewicz X-Patchwork-Id: 11478533 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DD7C815AB for ; Tue, 7 Apr 2020 17:51:01 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A8B292076E for ; Tue, 7 Apr 2020 17:51:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="rGLGJmWl" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A8B292076E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=collabora.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=20drDTdFnJWKsHctAhfXKou2LlVvWLrYm72odEDglN4=; b=rGLGJmWl1YxtiX9hFfeSriwZV2 DNbr3M7Y+l7i3lexhOyURnxMQ6MtaMUd4VIFr+6P+3UHGuPIQH30bQkl5CvuC0J5YyMsduPgTRooT qrq5AyOghXJ3cQG5zT71XPVxhJuFvrjR+TRWSyYhk6pYjIyqBTqfr/Thm6XHNwy0hf9HUM+lkrSgs poyDOohrQjoBa8Qo7Y3IAJj+3/XdcqE42lp2BNuckTy9nrPRNxYoRt5YNwp5tdOqZkFXh26uJeu5J g2V/MLP8d5BWhDpaES/OYX+dUil2vo0eP/2b6AhztJNP2n3tGwHRhqon0/yKuqmhFA9hln4MypP/X E5up31ag==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jLsNI-0002n4-A1; Tue, 07 Apr 2020 17:51:00 +0000 Received: from bhuna.collabora.co.uk ([2a00:1098:0:82:1000:25:2eeb:e3e3]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jLsM9-0007dE-3v for linux-arm-kernel@lists.infradead.org; Tue, 07 Apr 2020 17:49:50 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: andrzej.p) with ESMTPSA id 8C9132972AA From: Andrzej Pietrasiewicz To: linux-pm@vger.kernel.org Subject: [RFC 5/8] thermal: core: Monitor thermal zone after mode change Date: Tue, 7 Apr 2020 19:49:23 +0200 Message-Id: <20200407174926.23971-6-andrzej.p@collabora.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200407174926.23971-1-andrzej.p@collabora.com> References: <20200407174926.23971-1-andrzej.p@collabora.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200407_104949_308614_3EEBAD95 X-CRM114-Status: GOOD ( 10.70 ) X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 0.0 UNPARSEABLE_RELAY Informational: message has unparseable relay lines X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Rafael J . Wysocki" , platform-driver-x86@vger.kernel.org, kernel@collabora.com, Fabio Estevam , Amit Kucheria , Daniel Lezcano , linux-acpi@vger.kernel.org, NXP Linux Team , Darren Hart , Zhang Rui , Gayatri Kammela , Len Brown , Sascha Hauer , Ido Schimmel , Jiri Pirko , Thomas Gleixner , Allison Randal , linux-arm-kernel@lists.infradead.org, Support Opensource , Shawn Guo , Peter Kaestle , Andrzej Pietrasiewicz , Pengutronix Kernel Team , netdev@vger.kernel.org, Enrico Weigelt , "David S . Miller" , Andy Shevchenko MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Mode changing might imply a need to stop/start polling the device. monitor_thermal_zone() when mode changes or if previous mode is unknown. Signed-off-by: Andrzej Pietrasiewicz --- drivers/thermal/thermal_core.c | 26 ++++++++++++++++++++++++++ drivers/thermal/thermal_core.h | 2 ++ drivers/thermal/thermal_sysfs.c | 8 +++++--- 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 9a321dc548c8..aae2b049d45c 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -469,6 +469,32 @@ static void thermal_zone_device_reset(struct thermal_zone_device *tz) thermal_zone_device_init(tz); } +int thermal_zone_set_mode(struct thermal_zone_device *tz, + enum thermal_device_mode mode) +{ + enum thermal_device_mode old_mode; + int result; + + if (!tz->ops->set_mode) + return -EPERM; + + if (tz->ops->get_mode) { + result = tz->ops->get_mode(tz, &old_mode); + if (result) + return result; + } + + result = tz->ops->set_mode(tz, mode); + if (result) + return result; + + /* old mode unknown or mode changed */ + if (!tz->ops->get_mode || mode != old_mode) + monitor_thermal_zone(tz); + + return 0; +} + void thermal_zone_device_update(struct thermal_zone_device *tz, enum thermal_notify_event event) { diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h index a9bf00e91d64..1ed0bdb812d8 100644 --- a/drivers/thermal/thermal_core.h +++ b/drivers/thermal/thermal_core.h @@ -74,6 +74,8 @@ int thermal_zone_create_device_groups(struct thermal_zone_device *, int); void thermal_zone_destroy_device_groups(struct thermal_zone_device *); void thermal_cooling_device_setup_sysfs(struct thermal_cooling_device *); void thermal_cooling_device_destroy_sysfs(struct thermal_cooling_device *cdev); +int thermal_zone_set_mode(struct thermal_zone_device *tz, + enum thermal_device_mode mode); /* used only at binding time */ ssize_t trip_point_show(struct device *, struct device_attribute *, char *); ssize_t weight_show(struct device *, struct device_attribute *, char *); diff --git a/drivers/thermal/thermal_sysfs.c b/drivers/thermal/thermal_sysfs.c index 6bfef21abce4..cc1f808b48b3 100644 --- a/drivers/thermal/thermal_sysfs.c +++ b/drivers/thermal/thermal_sysfs.c @@ -68,18 +68,20 @@ mode_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct thermal_zone_device *tz = to_thermal_zone(dev); + enum thermal_device_mode mode; int result; if (!tz->ops->set_mode) return -EPERM; if (!strncmp(buf, "enabled", sizeof("enabled") - 1)) - result = tz->ops->set_mode(tz, THERMAL_DEVICE_ENABLED); + mode = THERMAL_DEVICE_ENABLED; else if (!strncmp(buf, "disabled", sizeof("disabled") - 1)) - result = tz->ops->set_mode(tz, THERMAL_DEVICE_DISABLED); + mode = THERMAL_DEVICE_DISABLED; else - result = -EINVAL; + return -EINVAL; + result = thermal_zone_set_mode(tz, mode); if (result) return result; From patchwork Tue Apr 7 17:49:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Pietrasiewicz X-Patchwork-Id: 11478537 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4A81D913 for ; Tue, 7 Apr 2020 17:51:36 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 275052075E for ; Tue, 7 Apr 2020 17:51:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="PJYYm78e" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 275052075E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=collabora.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=rpEw7CPRvUXihsl8oQzm21mM7+KxzYt94/MHCYh2K/4=; b=PJYYm78ecwTqZjWh7KGo1T6DJp EngVgdoB7s15gy699KNaMS2qmMHIlf8g4tGE3aYi8o4jtx8I4Lr5vDdMuunriB7xs3PI77avuvfnk S4wxxtiQUkxsjXuwan+Kp/nmsz/pyql1r6BP8QoOLRWENUKRL53Um8dDWNJObauo7KrQxfgmDGgO7 mbxUbV45ETu6Xyu3j2EhdVjpXti/99A98mYaJ2MPclqWClOLK3/DVWNa22n2S8ewtPLgvXe9SHXk5 UgP1F2r32iuu2idsKUz+trrHyuIh6/W3YHn7Lgpn7zSXpmdPmkxAoKW+dQUMZn8pJBbwYF3HUpchW SqZCMKDA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jLsNo-0003Gv-JL; Tue, 07 Apr 2020 17:51:32 +0000 Received: from bhuna.collabora.co.uk ([2a00:1098:0:82:1000:25:2eeb:e3e3]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jLsMB-0007gs-AK for linux-arm-kernel@lists.infradead.org; Tue, 07 Apr 2020 17:49:53 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: andrzej.p) with ESMTPSA id A39BC2972AE From: Andrzej Pietrasiewicz To: linux-pm@vger.kernel.org Subject: [RFC 6/8] thermal: Set initial state to THERMAL_DEVICE_INITIAL Date: Tue, 7 Apr 2020 19:49:24 +0200 Message-Id: <20200407174926.23971-7-andrzej.p@collabora.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200407174926.23971-1-andrzej.p@collabora.com> References: <20200407174926.23971-1-andrzej.p@collabora.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200407_104951_701182_03A9D813 X-CRM114-Status: GOOD ( 10.94 ) X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 0.0 UNPARSEABLE_RELAY Informational: message has unparseable relay lines X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Rafael J . Wysocki" , platform-driver-x86@vger.kernel.org, kernel@collabora.com, Fabio Estevam , Amit Kucheria , Daniel Lezcano , linux-acpi@vger.kernel.org, NXP Linux Team , Darren Hart , Zhang Rui , Gayatri Kammela , Len Brown , Sascha Hauer , Ido Schimmel , Jiri Pirko , Thomas Gleixner , Allison Randal , linux-arm-kernel@lists.infradead.org, Support Opensource , Shawn Guo , Peter Kaestle , Andrzej Pietrasiewicz , Pengutronix Kernel Team , netdev@vger.kernel.org, Enrico Weigelt , "David S . Miller" , Andy Shevchenko MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Now that THERMAL_DEVICE_INITIAL is available use it. Signed-off-by: Andrzej Pietrasiewicz --- drivers/acpi/thermal.c | 1 + drivers/net/ethernet/mellanox/mlxsw/core_thermal.c | 3 +++ drivers/platform/x86/acerhdf.c | 1 + drivers/thermal/da9062-thermal.c | 2 +- drivers/thermal/imx_thermal.c | 1 + drivers/thermal/intel/int340x_thermal/int3400_thermal.c | 1 + drivers/thermal/intel/intel_quark_dts_thermal.c | 1 + 7 files changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c index a93b0412dd6b..0f352cef4898 100644 --- a/drivers/acpi/thermal.c +++ b/drivers/acpi/thermal.c @@ -881,6 +881,7 @@ static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz) for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE && tz->trips.active[i].flags.valid; i++, trips++); + tz->mode = THERMAL_DEVICE_INITIAL; if (tz->trips.passive.flags.valid) tz->thermal_zone = thermal_zone_device_register("acpitz", trips, 0, tz, diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c index cd435ca7adbe..a58ab4d18331 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c +++ b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c @@ -758,6 +758,7 @@ mlxsw_thermal_module_tz_init(struct mlxsw_thermal_module *module_tz) snprintf(tz_name, sizeof(tz_name), "mlxsw-module%d", module_tz->module + 1); + module_tz->mode = THERMAL_DEVICE_INITIAL; module_tz->tzdev = thermal_zone_device_register(tz_name, MLXSW_THERMAL_NUM_TRIPS, MLXSW_THERMAL_TRIP_MASK, @@ -876,6 +877,7 @@ mlxsw_thermal_gearbox_tz_init(struct mlxsw_thermal_module *gearbox_tz) snprintf(tz_name, sizeof(tz_name), "mlxsw-gearbox%d", gearbox_tz->module + 1); + gearbox_tz->mode = THERMAL_DEVICE_INITIAL; gearbox_tz->tzdev = thermal_zone_device_register(tz_name, MLXSW_THERMAL_NUM_TRIPS, MLXSW_THERMAL_TRIP_MASK, @@ -1033,6 +1035,7 @@ int mlxsw_thermal_init(struct mlxsw_core *core, MLXSW_THERMAL_SLOW_POLL_INT : MLXSW_THERMAL_POLL_INT; + thermal->mode = THERMAL_DEVICE_INITIAL; thermal->tzdev = thermal_zone_device_register("mlxsw", MLXSW_THERMAL_NUM_TRIPS, MLXSW_THERMAL_TRIP_MASK, diff --git a/drivers/platform/x86/acerhdf.c b/drivers/platform/x86/acerhdf.c index 87e357017d4a..00751a0f5312 100644 --- a/drivers/platform/x86/acerhdf.c +++ b/drivers/platform/x86/acerhdf.c @@ -747,6 +747,7 @@ static int __init acerhdf_register_thermal(void) if (IS_ERR(cl_dev)) return -EINVAL; + thermal_mode = THERMAL_DEVICE_INITIAL; thz_dev = thermal_zone_device_register("acerhdf", 2, 0, NULL, &acerhdf_dev_ops, &acerhdf_zone_params, 0, diff --git a/drivers/thermal/da9062-thermal.c b/drivers/thermal/da9062-thermal.c index c32709badeda..2f876760d667 100644 --- a/drivers/thermal/da9062-thermal.c +++ b/drivers/thermal/da9062-thermal.c @@ -233,7 +233,7 @@ static int da9062_thermal_probe(struct platform_device *pdev) thermal->config = match->data; thermal->hw = chip; - thermal->mode = THERMAL_DEVICE_ENABLED; + thermal->mode = THERMAL_DEVICE_INITIAL; thermal->dev = &pdev->dev; INIT_DELAYED_WORK(&thermal->work, da9062_thermal_poll_on); diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c index 014512581918..1e8fd56c2568 100644 --- a/drivers/thermal/imx_thermal.c +++ b/drivers/thermal/imx_thermal.c @@ -805,6 +805,7 @@ static int imx_thermal_probe(struct platform_device *pdev) goto legacy_cleanup; } + data->mode = THERMAL_DEVICE_INITIAL; data->tz = thermal_zone_device_register("imx_thermal_zone", IMX_TRIP_NUM, BIT(IMX_TRIP_PASSIVE), data, diff --git a/drivers/thermal/intel/int340x_thermal/int3400_thermal.c b/drivers/thermal/intel/int340x_thermal/int3400_thermal.c index fcbd1b14fa74..9c8caa37ed13 100644 --- a/drivers/thermal/intel/int340x_thermal/int3400_thermal.c +++ b/drivers/thermal/intel/int340x_thermal/int3400_thermal.c @@ -307,6 +307,7 @@ static int int3400_thermal_probe(struct platform_device *pdev) platform_set_drvdata(pdev, priv); + priv->mode = THERMAL_DEVICE_INITIAL; priv->thermal = thermal_zone_device_register("INT3400 Thermal", 0, 0, priv, &int3400_thermal_ops, &int3400_thermal_params, 0, 0); diff --git a/drivers/thermal/intel/intel_quark_dts_thermal.c b/drivers/thermal/intel/intel_quark_dts_thermal.c index 5f4bcc0e4fd3..af588ff9aa76 100644 --- a/drivers/thermal/intel/intel_quark_dts_thermal.c +++ b/drivers/thermal/intel/intel_quark_dts_thermal.c @@ -411,6 +411,7 @@ static struct soc_sensor_entry *alloc_soc_dts(void) goto err_ret; } + aux_entry->mode = THERMAL_DEVICE_INITIAL; aux_entry->tzone = thermal_zone_device_register("quark_dts", QRK_MAX_DTS_TRIPS, wr_mask, From patchwork Tue Apr 7 17:49:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Pietrasiewicz X-Patchwork-Id: 11478535 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 17D6315AB for ; Tue, 7 Apr 2020 17:51:20 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DA1B92075E for ; Tue, 7 Apr 2020 17:51:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="jmoNhLvo" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DA1B92075E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=collabora.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=/2n5EXp8vp07byZoLQV/f83l4XAycsVlZNaRt6MOI/Q=; b=jmoNhLvoL4awKHk4mxpPYxBgcY VGsSroSSO4d03OLOLWb5+FgBPxn8Fj6wflokjpGckarGf9CTnv8zjB+aLf31vPA+Ok79JGuWfj/kh oyHn3RGinaX/ioyKi16gyPbQXd0OQN+yFH4wKefoe7phiw/tebR956p4iHyymGmVqOx/t+B3Mxjts vxOcrv8iHorbVCaM9AejHzMBNOqY3FTujHxRCgaf2zrYEKMG1ZiG550Au2pzxS5zIiXHPhdPJd2Pn WDghZfu9rtry6gEHAWCSGA+syS9Uijjd5O2xSszixD+uq6KXpVPI5DKMTC+wOegdLRZFjFwPiJZvD dI0kNP+A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jLsNY-00032d-OD; Tue, 07 Apr 2020 17:51:16 +0000 Received: from bhuna.collabora.co.uk ([2a00:1098:0:82:1000:25:2eeb:e3e3]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jLsMD-0007jL-ID for linux-arm-kernel@lists.infradead.org; Tue, 07 Apr 2020 17:49:54 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: andrzej.p) with ESMTPSA id E5F502972B0 From: Andrzej Pietrasiewicz To: linux-pm@vger.kernel.org Subject: [RFC 7/8] thermal: of: Monitor thermal zone after enabling it Date: Tue, 7 Apr 2020 19:49:25 +0200 Message-Id: <20200407174926.23971-8-andrzej.p@collabora.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200407174926.23971-1-andrzej.p@collabora.com> References: <20200407174926.23971-1-andrzej.p@collabora.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200407_104953_742666_7874C53A X-CRM114-Status: UNSURE ( 8.75 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 0.0 UNPARSEABLE_RELAY Informational: message has unparseable relay lines X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Rafael J . Wysocki" , platform-driver-x86@vger.kernel.org, kernel@collabora.com, Fabio Estevam , Amit Kucheria , Daniel Lezcano , linux-acpi@vger.kernel.org, NXP Linux Team , Darren Hart , Zhang Rui , Gayatri Kammela , Len Brown , Sascha Hauer , Ido Schimmel , Jiri Pirko , Thomas Gleixner , Allison Randal , linux-arm-kernel@lists.infradead.org, Support Opensource , Shawn Guo , Peter Kaestle , Andrzej Pietrasiewicz , Pengutronix Kernel Team , netdev@vger.kernel.org, Enrico Weigelt , "David S . Miller" , Andy Shevchenko MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org thermal/of calls its own ->set_mode() method, so monitor thermal zone afterwards. This is needed for the DISABLED->ENABLED transition. Signed-off-by: Andrzej Pietrasiewicz --- drivers/thermal/of-thermal.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c index b7621dfab17c..cf2c43ebcb78 100644 --- a/drivers/thermal/of-thermal.c +++ b/drivers/thermal/of-thermal.c @@ -523,8 +523,11 @@ thermal_zone_of_sensor_register(struct device *dev, int sensor_id, void *data, if (sensor_specs.np == sensor_np && id == sensor_id) { tzd = thermal_zone_of_add_sensor(child, sensor_np, data, ops); - if (!IS_ERR(tzd)) + if (!IS_ERR(tzd)) { tzd->ops->set_mode(tzd, THERMAL_DEVICE_ENABLED); + thermal_zone_device_update(tzd, + THERMAL_EVENT_UNSPECIFIED); + } of_node_put(sensor_specs.np); of_node_put(child); From patchwork Tue Apr 7 17:49:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Pietrasiewicz X-Patchwork-Id: 11478539 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9AC64913 for ; Tue, 7 Apr 2020 17:51:52 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1F3622075E for ; Tue, 7 Apr 2020 17:51:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="h+C6o0rY" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1F3622075E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=collabora.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=PL3U/fq5K4V4JTe6DoH0SnqQoVoOIG/xwLFhdYrT2co=; b=h+C6o0rYP+dlT2W8MVc/HoS8aX nkuEDSXIEIxgoyU5SwRAsaujrAzCw0SG7ZgvwXmK48j3rPeCSksr029IzBI/kOiSskF36bBKg9YhF DSPVK0Zd8HmcDGTgb3mt5ev2MQPB4WiauLWD99IF2+symKylOlaXfCiDtVhSl5Sp+7JilWfClwzMb o1RqdJ7//yEXDJ0BAHC+5vaO32pF+BWNRlAFGPUd18h21IfsSWjyCHsG6XxXi6bwFMcD859/9IqJD sFuD/cZJ72gkT/BRabYc8gunAKY5KgeIN9ZxRTQV+mnXZDT1RuadmK+ik86OhGqRCGlrEsn9rkYmH wSgDzvQg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jLsO4-0003Ut-FK; Tue, 07 Apr 2020 17:51:48 +0000 Received: from bhuna.collabora.co.uk ([46.235.227.227]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jLsMG-0007mu-4Z for linux-arm-kernel@lists.infradead.org; Tue, 07 Apr 2020 17:49:57 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: andrzej.p) with ESMTPSA id 326AA2972B4 From: Andrzej Pietrasiewicz To: linux-pm@vger.kernel.org Subject: [RFC 8/8] thermal: Stop polling DISABLED thermal devices Date: Tue, 7 Apr 2020 19:49:26 +0200 Message-Id: <20200407174926.23971-9-andrzej.p@collabora.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200407174926.23971-1-andrzej.p@collabora.com> References: <20200407174926.23971-1-andrzej.p@collabora.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200407_104956_327193_5D85C789 X-CRM114-Status: GOOD ( 10.29 ) X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.4.4 on bombadil.infradead.org summary: Content analysis details: (-0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [46.235.227.227 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 0.0 UNPARSEABLE_RELAY Informational: message has unparseable relay lines X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Rafael J . Wysocki" , platform-driver-x86@vger.kernel.org, kernel@collabora.com, Fabio Estevam , Amit Kucheria , Daniel Lezcano , linux-acpi@vger.kernel.org, NXP Linux Team , Darren Hart , Zhang Rui , Gayatri Kammela , Len Brown , Sascha Hauer , Ido Schimmel , Jiri Pirko , Thomas Gleixner , Allison Randal , linux-arm-kernel@lists.infradead.org, Support Opensource , Shawn Guo , Peter Kaestle , Andrzej Pietrasiewicz , Pengutronix Kernel Team , netdev@vger.kernel.org, Enrico Weigelt , "David S . Miller" , Andy Shevchenko MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Polling DISABLED devices is not desired, as all such "disabled" devices are meant to be handled by userspace. Signed-off-by: Andrzej Pietrasiewicz --- drivers/thermal/thermal_core.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index aae2b049d45c..f74b7a792be7 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -305,13 +305,32 @@ static void thermal_zone_device_set_polling(struct thermal_zone_device *tz, cancel_delayed_work(&tz->poll_queue); } +static bool should_stop_polling(struct thermal_zone_device *tz) +{ + enum thermal_device_mode mode; + int result; + + if (!tz->ops->get_mode) + return false; + + result = tz->ops->get_mode(tz, &mode); + if (result) + return false; + + return mode == THERMAL_DEVICE_DISABLED; +} + static void monitor_thermal_zone(struct thermal_zone_device *tz) { + bool stop; + + stop = should_stop_polling(tz); + mutex_lock(&tz->lock); - if (tz->passive) + if (!stop && tz->passive) thermal_zone_device_set_polling(tz, tz->passive_delay); - else if (tz->polling_delay) + else if (!stop && tz->polling_delay) thermal_zone_device_set_polling(tz, tz->polling_delay); else thermal_zone_device_set_polling(tz, 0); @@ -500,6 +519,9 @@ void thermal_zone_device_update(struct thermal_zone_device *tz, { int count; + if (should_stop_polling(tz)) + return; + if (atomic_read(&in_suspend)) return;