From patchwork Tue Apr 14 18:01:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrzej Pietrasiewicz X-Patchwork-Id: 221201 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, UNPARSEABLE_RELAY, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B17EFC2BB85 for ; Tue, 14 Apr 2020 18:01:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 97D0D20767 for ; Tue, 14 Apr 2020 18:01:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2503232AbgDNSBt (ORCPT ); Tue, 14 Apr 2020 14:01:49 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:46864 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2503198AbgDNSBf (ORCPT ); Tue, 14 Apr 2020 14:01:35 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: andrzej.p) with ESMTPSA id A8CD92A1BE7 From: Andrzej Pietrasiewicz To: linux-pm@vger.kernel.org Cc: Zhang Rui , "Rafael J . Wysocki" , Len Brown , Jiri Pirko , Ido Schimmel , "David S . Miller" , Peter Kaestle , Darren Hart , Andy Shevchenko , Support Opensource , Daniel Lezcano , Amit Kucheria , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , Allison Randal , Enrico Weigelt , Gayatri Kammela , Thomas Gleixner , linux-acpi@vger.kernel.org, netdev@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel@collabora.com, Andrzej Pietrasiewicz Subject: [RFC v2 7/9] thermal: core: Monitor thermal zone after mode change Date: Tue, 14 Apr 2020 20:01:03 +0200 Message-Id: <20200414180105.20042-8-andrzej.p@collabora.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200414180105.20042-1-andrzej.p@collabora.com> References: <2bc5a902-acde-526a-11a5-2357d899916c@linaro.org> <20200414180105.20042-1-andrzej.p@collabora.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Mode changing might imply a need to stop/start polling the device. monitor_thermal_zone() when mode changes. Signed-off-by: Andrzej Pietrasiewicz --- drivers/thermal/thermal_core.c | 2 +- drivers/thermal/thermal_core.h | 2 ++ drivers/thermal/thermal_sysfs.c | 7 +++++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index a59c3411fb9c..7637ddb79813 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -305,7 +305,7 @@ static void thermal_zone_device_set_polling(struct thermal_zone_device *tz, cancel_delayed_work(&tz->poll_queue); } -static void monitor_thermal_zone(struct thermal_zone_device *tz) +void monitor_thermal_zone(struct thermal_zone_device *tz) { mutex_lock(&tz->lock); diff --git a/drivers/thermal/thermal_core.h b/drivers/thermal/thermal_core.h index a9bf00e91d64..469258778161 100644 --- a/drivers/thermal/thermal_core.h +++ b/drivers/thermal/thermal_core.h @@ -89,6 +89,8 @@ thermal_cooling_device_stats_update(struct thermal_cooling_device *cdev, unsigned long new_state) {} #endif /* CONFIG_THERMAL_STATISTICS */ +void monitor_thermal_zone(struct thermal_zone_device *tz); + /* device tree support */ #ifdef CONFIG_THERMAL_OF int of_parse_thermal_zones(void); diff --git a/drivers/thermal/thermal_sysfs.c b/drivers/thermal/thermal_sysfs.c index cbb27b3c96d2..bc34d0f9768b 100644 --- a/drivers/thermal/thermal_sysfs.c +++ b/drivers/thermal/thermal_sysfs.c @@ -62,11 +62,14 @@ 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 old_mode, mode; int result; if (!tz->ops->set_mode) return -EPERM; + old_mode = thermal_zone_device_get_mode(tz); + if (!strncmp(buf, "enabled", sizeof("enabled") - 1)) result = thermal_zone_device_enable(tz); else if (!strncmp(buf, "disabled", sizeof("disabled") - 1)) @@ -77,6 +80,10 @@ mode_store(struct device *dev, struct device_attribute *attr, if (result) return result; + mode = thermal_zone_device_get_mode(tz); + if (mode != old_mode) + monitor_thermal_zone(tz); + return count; }