Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp679947ybm; Thu, 28 May 2020 12:25:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy3LVuEnVO8VGmhHr2LARia0Qpkl+OYieS7puhSVmDXpDhlif7PnITdQVgSrF4mEOAnm7Mn X-Received: by 2002:a05:6402:22d1:: with SMTP id dm17mr4615731edb.299.1590693912601; Thu, 28 May 2020 12:25:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590693912; cv=none; d=google.com; s=arc-20160816; b=DuRNs4MyjQSjRKa1Sk76mtoirwbezXJTQJw1CoC1HbFRvi1EL8KB3dZw2UranORSdy J+yNvKiV1AEHv0Juc2Jgcaazt2QIG0BD3H/y6KDupQGYuVqGoU7bqPlP6DMHmxyGPTSp +yN/4MzqPZv1JnWgjpQNwXTz30kbAcD5Vw4rvfBSYrEIktoUGocY+Ed1Snr/Ibt6hByb lS6FZ7PQVukuxxF9vr/TcOtaZf3ahV3zp7XSdcxlDnxZoKNFM1d+KA0oc/VRWu6CxEPJ HpAZyvsapGrNMnsvCwCj3GgypaqA0AgSdAobiwI1Ig72MtQ6v/2Gy5H7bAqt/HvD8Y1w wnSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=bw1YkU8jzVCtdCJDrFXRhGwEQO6+bYAkwQfgxZrQ2aM=; b=qxoh60visBc496wEjLwp3BT4DDu3vLTsJaepXRxitWKvm4355zRtDvK1gFg70T3Mkg al1cQl+m3uxN7CsrdsaRm2fmSSUOnzj/oTbznued0o2Yp5YWuW3EltPIdJyWZKjWWG6o 9R7ympButb4tPG/NVZJO6bnl9Rc0uunWKgPerkmP1v+fR64MpI4jIavcwfHBHxTiEq1T yxgwOyys8D6wBtukjUTPHd39R3wt5UhVyWct1cJxbQRmGYegYVrRpfOh928Loj1UfRfN T/N05xCpky1TSANW9AU5EAWCoIW5IgobRt5sUZ81T1CtsCxPOEA/igyZT57bnm7CUuSA WC3w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b13si4468079ejg.10.2020.05.28.12.24.44; Thu, 28 May 2020 12:25:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406455AbgE1TWS (ORCPT + 99 others); Thu, 28 May 2020 15:22:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59528 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2406440AbgE1TWN (ORCPT ); Thu, 28 May 2020 15:22:13 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0153AC08C5C7; Thu, 28 May 2020 12:22:12 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: andrzej.p) with ESMTPSA id CA31A2A41D1 From: Andrzej Pietrasiewicz To: linux-pm@vger.kernel.org, linux-acpi@vger.kernel.org, netdev@vger.kernel.org, linux-wireless@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-renesas-soc@vger.kernel.org, linux-rockchip@lists.infradead.org Cc: "Rafael J . Wysocki" , Len Brown , Vishal Kulkarni , "David S . Miller" , Jiri Pirko , Ido Schimmel , Johannes Berg , Emmanuel Grumbach , Luca Coelho , Intel Linux Wireless , Kalle Valo , Peter Kaestle , Darren Hart , Andy Shevchenko , Sebastian Reichel , Miquel Raynal , Daniel Lezcano , Amit Kucheria , Support Opensource , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , =?UTF-8?q?Niklas=20S=C3=B6derlund?= , Heiko Stuebner , Orson Zhai , Baolin Wang , Chunyan Zhang , Zhang Rui , Allison Randal , Enrico Weigelt , Gayatri Kammela , Thomas Gleixner , Bartlomiej Zolnierkiewicz , Andrzej Pietrasiewicz , kernel@collabora.com Subject: [PATCH v4 09/11] thermal: core: Stop polling DISABLED thermal devices Date: Thu, 28 May 2020 21:20:49 +0200 Message-Id: <20200528192051.28034-10-andrzej.p@collabora.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200528192051.28034-1-andrzej.p@collabora.com> References: <20200528192051.28034-1-andrzej.p@collabora.com> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Polling DISABLED devices is not desired, as all such "disabled" devices are meant to be handled by userspace. This patch introduces and uses should_stop_polling() to decide whether the device should be polled or not. Signed-off-by: Andrzej Pietrasiewicz --- drivers/thermal/thermal_core.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 14baf0288759..e9c0b990e4a9 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -301,13 +301,22 @@ static void thermal_zone_device_set_polling(struct thermal_zone_device *tz, cancel_delayed_work(&tz->poll_queue); } +static inline bool should_stop_polling(struct thermal_zone_device *tz) +{ + return !thermal_zone_device_is_enabled(tz); +} + 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); @@ -517,6 +526,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; -- 2.17.1