From patchwork Sun Dec 30 18:57:36 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Lam X-Patchwork-Id: 1919971 X-Patchwork-Delegate: rui.zhang@intel.com Return-Path: X-Original-To: patchwork-linux-acpi@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 75BFC3FC85 for ; Sun, 30 Dec 2012 19:03:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754819Ab2L3TDZ (ORCPT ); Sun, 30 Dec 2012 14:03:25 -0500 Received: from mail-vb0-f47.google.com ([209.85.212.47]:36522 "EHLO mail-vb0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754787Ab2L3TDY (ORCPT ); Sun, 30 Dec 2012 14:03:24 -0500 X-Greylist: delayed 331 seconds by postgrey-1.27 at vger.kernel.org; Sun, 30 Dec 2012 14:03:24 EST Received: by mail-vb0-f47.google.com with SMTP id e21so12276895vbm.34 for ; Sun, 30 Dec 2012 11:03:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer; bh=MFm6cEepxgVfipLNrGdCRqQpKch5a6Ae7RpoM5erRNI=; b=USGYOoaZx/fO3r7GfCwG1RI6vUdlYkr694hJJqznYWOC/PsusVSQDwDTlQZeMfaHnj 9x0AwiUQ8VfUNKHlSYmuYrLF98SFbbCajRVQZHixWDNJSnlSW0wd9R8vkQ5GgpXc+70J 0seOmy51HUqY6kuJzTFwCPZ0eeZsv+frYd4GIb0Qluwv06zQ47t+dAQ6UemL6RttfIUd KGZ7hsZ5ZdRqnQr/PfOveISchLtN1WKZkZFjwfRbXtKiLvI3vlwoB5B9435GDWmZ1lR0 o7qELd4Ztyho+bI6HgD7MeVYJkTB+LEp8wTVbMevPIKnQIfhyQCf28KlVK1TaCoRv3zr SG2w== X-Received: by 10.220.225.132 with SMTP id is4mr59866906vcb.47.1356893872916; Sun, 30 Dec 2012 10:57:52 -0800 (PST) Received: from localhost.localdomain (c-71-61-181-125.hsd1.pa.comcast.net. [71.61.181.125]) by mx.google.com with ESMTPS id dl18sm36207552vdb.2.2012.12.30.10.57.51 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 30 Dec 2012 10:57:52 -0800 (PST) From: Alexander Lam To: Zhang Rui , Durgadoss R Cc: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, Alexander Lam Subject: [PATCH 1/1] thermal: Check cooling device's current state before declaring it inactive Date: Sun, 30 Dec 2012 13:57:36 -0500 Message-Id: <1356893856-26249-1-git-send-email-lambchop468@gmail.com> X-Mailer: git-send-email 1.8.0.2 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org It is possible for a cooling device to become active in between calls to the thermal governor. An example of this is the acerhdf driver, which can hand control of the cooling device over to the system firmware. Upon returning control back to the thermal system, the cooling device might be running again, so checking the current state of the cooling device is required. Signed-off-by: Alexander Lam --- drivers/thermal/step_wise.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/thermal/step_wise.c b/drivers/thermal/step_wise.c index 0cd5e9f..0eeb709 100644 --- a/drivers/thermal/step_wise.c +++ b/drivers/thermal/step_wise.c @@ -94,16 +94,21 @@ static void update_instance_for_dethrottle(struct thermal_zone_device *tz, unsigned long cur_state; list_for_each_entry(instance, &tz->thermal_instances, tz_node) { - if (instance->trip != trip || - instance->target == THERMAL_NO_TARGET) + if (instance->trip != trip) continue; cdev = instance->cdev; cdev->ops->get_cur_state(cdev, &cur_state); - instance->target = cur_state > instance->lower ? + cur_state = cur_state > instance->lower ? (cur_state - 1) : THERMAL_NO_TARGET; + if (cur_state == THERMAL_NO_TARGET && + instance->target == THERMAL_NO_TARGET) + continue; + + instance->target = cur_state; + /* Deactivate a passive thermal instance */ if (instance->target == THERMAL_NO_TARGET) update_passive_instance(tz, trip_type, -1);