From patchwork Thu Jun 29 16:50:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Enric Balletbo i Serra X-Patchwork-Id: 9817369 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 392EB603F2 for ; Thu, 29 Jun 2017 16:51:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2C4C7287D1 for ; Thu, 29 Jun 2017 16:51:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 20C5C287D3; Thu, 29 Jun 2017 16:51:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AF07F287E2 for ; Thu, 29 Jun 2017 16:51:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752723AbdF2QvF (ORCPT ); Thu, 29 Jun 2017 12:51:05 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:35227 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752136AbdF2Qux (ORCPT ); Thu, 29 Jun 2017 12:50:53 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: eballetbo) with ESMTPSA id D010926BEF1 From: Enric Balletbo i Serra To: Zhang Rui , rjw@rjwysocki.net, Len Brown , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Guenter Roeck , Sameer Nanda Subject: [PATCH v2 2/2] thermal: core: Allow to disable polling when disabling thermal zone. Date: Thu, 29 Jun 2017 18:50:35 +0200 Message-Id: <20170629165035.23101-2-enric.balletbo@collabora.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170629165035.23101-1-enric.balletbo@collabora.com> References: <20170629165035.23101-1-enric.balletbo@collabora.com> Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Under each thermal zone there is a optional file called "mode". Writing enabled or disabled to this file allows a given thermal zone to be enabled or disabled, but in current code, the monitoring queue doesn't stops. Add the code to disable polling when disabling thermal zone and enable polling when enabling the thermal zone. This patch is based on the original Sameer Nanda patch that implemented this idea for the ACPI thermal driver. Signed-off-by: Enric Balletbo i Serra --- Changes since v1: - Implement in thermal subsystem instead of ACPI thermal driver (Zhang Rui) v1: https://patchwork.kernel.org/patch/9804229/ drivers/thermal/thermal_core.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 5a51c74..869c8f3 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -292,6 +292,17 @@ static void thermal_unregister_governors(void) static void thermal_zone_device_set_polling(struct thermal_zone_device *tz, int delay) { + enum thermal_device_mode mode; + + if (tz->ops->get_mode) { + /* When the thermal zone is disabled stop the polling */ + tz->ops->get_mode(tz, &mode); + if (mode == THERMAL_DEVICE_DISABLED) { + cancel_delayed_work(&tz->poll_queue); + return; + } + } + if (delay > 1000) mod_delayed_work(system_freezable_wq, &tz->poll_queue, round_jiffies(msecs_to_jiffies(delay)));