All of lore.kernel.org
 help / color / mirror / Atom feed
From: Enric Balletbo i Serra <enric.balletbo@collabora.com>
To: Zhang Rui <rui.zhang@intel.com>,
	rjw@rjwysocki.net, Len Brown <lenb@kernel.org>,
	linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Guenter Roeck <groeck@chromium.org>, Sameer Nanda <snanda@chromium.org>
Subject: [PATCH v2 2/2] thermal: core: Allow to disable polling when disabling thermal zone.
Date: Thu, 29 Jun 2017 18:50:35 +0200	[thread overview]
Message-ID: <20170629165035.23101-2-enric.balletbo@collabora.com> (raw)
In-Reply-To: <20170629165035.23101-1-enric.balletbo@collabora.com>

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 <snanda@chromium.org>
patch that implemented this idea for the ACPI thermal driver.

Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
---
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)));
-- 
2.9.3


  reply	other threads:[~2017-06-29 16:50 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-29 16:50 [PATCH v2 1/2] acpi: thermal: update thermal_zone after enable the driver Enric Balletbo i Serra
2017-06-29 16:50 ` Enric Balletbo i Serra [this message]
2017-06-30  5:05   ` [PATCH v2 2/2] thermal: core: Allow to disable polling when disabling thermal zone Zhang Rui
2017-06-30  8:15     ` Enric Balletbo Serra
2017-07-01  3:06       ` Zhang Rui
2017-06-30  2:40 ` [PATCH v2 1/2] acpi: thermal: update thermal_zone after enable the driver Zhang Rui

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170629165035.23101-2-enric.balletbo@collabora.com \
    --to=enric.balletbo@collabora.com \
    --cc=groeck@chromium.org \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rjw@rjwysocki.net \
    --cc=rui.zhang@intel.com \
    --cc=snanda@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.