From patchwork Tue Oct 9 05:53:51 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Len Brown X-Patchwork-Id: 1568881 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 D2B133FE80 for ; Tue, 9 Oct 2012 06:12:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752506Ab2JIGCb (ORCPT ); Tue, 9 Oct 2012 02:02:31 -0400 Received: from mail-qc0-f174.google.com ([209.85.216.174]:38957 "EHLO mail-qc0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751726Ab2JIGCZ (ORCPT ); Tue, 9 Oct 2012 02:02:25 -0400 Received: by mail-qc0-f174.google.com with SMTP id d3so3587711qch.19 for ; Mon, 08 Oct 2012 23:02:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:reply-to:organization; bh=FljCbdt4fCeIxwiRC6vFie3eaxK0MWBgmM5Av4nsmNU=; b=OCfWAVN70qB7AU1W+ljLHS88qMq/xaJikAGHjfk18OjtvE9m2BA1j9P5EJtMPEFwEH U5WZVVTpeUaxiB/WrcOcGprMDOGG/Qz24hA5057ahWzWM17TzIMUti0s/g8NprGZ6eBb 9yU9uMJLVL0ANeMihxnVE/AjsYxZwIYR+MsrA0QGW9e6OqfbTJZTHFNlOqA0v0VN7qSU sLN7BC25DMpcf1Ig5npu+U8w5qYoxqegNJbf9R/jzp87rIXScHkBGkrlmFby4xAH3iRF 1ICPN/om02ltwzPHuGyR3S2jpeH7cvoPY0mxvMaqDiWeRsGjHEOMN8sPmjavcwuMr4U1 tgOw== Received: by 10.229.136.143 with SMTP id r15mr7557238qct.99.1349762544471; Mon, 08 Oct 2012 23:02:24 -0700 (PDT) Received: from x980.localdomain6 (pool-74-104-146-186.bstnma.fios.verizon.net. [74.104.146.186]) by mx.google.com with ESMTPS id ck11sm20206037qab.17.2012.10.08.23.02.21 (version=SSLv3 cipher=OTHER); Mon, 08 Oct 2012 23:02:22 -0700 (PDT) From: Len Brown To: linux-acpi@vger.kernel.org, linux-pm@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Zhang Rui Subject: [PATCH 01/30] Thermal: Introduce multiple cooling states support Date: Tue, 9 Oct 2012 01:53:51 -0400 Message-Id: X-Mailer: git-send-email 1.8.0.rc1 In-Reply-To: <1349762060-25334-1-git-send-email-lenb@kernel.org> References: <1349762060-25334-1-git-send-email-lenb@kernel.org> Reply-To: Len Brown Organization: Intel Open Source Technology Center Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org From: Zhang Rui This is because general active cooling devices, like fans, may have multiple speeds, which can be mapped to different cooling states. Signed-off-by: Zhang Rui Reviewed-by: Rafael J. Wysocki Reviewed-by: Valentin, Eduardo --- drivers/thermal/thermal_sys.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/thermal/thermal_sys.c b/drivers/thermal/thermal_sys.c index 2ab31e4..dc4044b 100644 --- a/drivers/thermal/thermal_sys.c +++ b/drivers/thermal/thermal_sys.c @@ -1059,6 +1059,7 @@ void thermal_zone_device_update(struct thermal_zone_device *tz) enum thermal_trip_type trip_type; struct thermal_cooling_device_instance *instance; struct thermal_cooling_device *cdev; + unsigned long cur_state, max_state; mutex_lock(&tz->lock); @@ -1098,10 +1099,17 @@ void thermal_zone_device_update(struct thermal_zone_device *tz) cdev = instance->cdev; + cdev->ops->get_cur_state(cdev, &cur_state); + cdev->ops->get_max_state(cdev, &max_state); + if (temp >= trip_temp) - cdev->ops->set_cur_state(cdev, 1); + cur_state = cur_state < max_state ? + (cur_state + 1) : max_state; else - cdev->ops->set_cur_state(cdev, 0); + cur_state = cur_state > 0 ? + (cur_state - 1) : 0; + + cdev->ops->set_cur_state(cdev, cur_state); } break; case THERMAL_TRIP_PASSIVE: