From patchwork Thu Dec 1 14:29:23 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Daniel Kachhap X-Patchwork-Id: 5421 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 0DB2C23E0C for ; Thu, 1 Dec 2011 14:29:41 +0000 (UTC) Received: from mail-lpp01m010-f52.google.com (mail-lpp01m010-f52.google.com [209.85.215.52]) by fiordland.canonical.com (Postfix) with ESMTP id D0CA4A18404 for ; Thu, 1 Dec 2011 14:29:40 +0000 (UTC) Received: by laah2 with SMTP id h2so1029498laa.11 for ; Thu, 01 Dec 2011 06:29:40 -0800 (PST) Received: by 10.152.104.1 with SMTP id ga1mr4656492lab.40.1322749780502; Thu, 01 Dec 2011 06:29:40 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.152.41.198 with SMTP id h6cs67244lal; Thu, 1 Dec 2011 06:29:40 -0800 (PST) Received: by 10.42.74.74 with SMTP id v10mr8575590icj.33.1322749778063; Thu, 01 Dec 2011 06:29:38 -0800 (PST) Received: from mail-iy0-f178.google.com (mail-iy0-f178.google.com [209.85.210.178]) by mx.google.com with ESMTPS id lw3si3213136icb.61.2011.12.01.06.29.37 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 01 Dec 2011 06:29:38 -0800 (PST) Received-SPF: pass (google.com: domain of amitdanielk@gmail.com designates 209.85.210.178 as permitted sender) client-ip=209.85.210.178; Authentication-Results: mx.google.com; spf=pass (google.com: domain of amitdanielk@gmail.com designates 209.85.210.178 as permitted sender) smtp.mail=amitdanielk@gmail.com; dkim=pass (test mode) header.i=@gmail.com Received: by iadj38 with SMTP id j38so2990790iad.37 for ; Thu, 01 Dec 2011 06:29:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=sender:from:to:cc:subject:date:message-id:x-mailer; bh=+p2S3xgHwmDAsTNwJROTTeDOcGY8ZKuDz1AA64uRh9g=; b=XfIkE2CDfVB3ks/7AdLLmILIxxTgXo46GXUpNKA/bVBLvzabOfpIkf45pOPaLGVtPh Rvg/U25pIztOdB4ZPfKhedUixIeHm8W+onXb26vGniYgbNwFndd6smV8jogZ/Kz8CLKq cRLLXGa7IcOtm8Bh50EnvDJ9LKB3angDHau04= Received: by 10.42.74.74 with SMTP id v10mr8575536icj.33.1322749777245; Thu, 01 Dec 2011 06:29:37 -0800 (PST) Received: from localhost.localdomain ([115.113.119.130]) by mx.google.com with ESMTPS id a2sm11976485igj.7.2011.12.01.06.29.33 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 01 Dec 2011 06:29:36 -0800 (PST) Sender: amit kachhap From: Amit Daniel Kachhap To: linux-pm@lists.linux-foundation.org Cc: linux-kernel@vger.kernel.org, mjg59@srcf.ucam.org, linux-acpi@vger.kernel.org, lenb@kernel.org, linaro-dev@lists.linaro.org, amit.kachhap@linaro.org, patches@linaro.org Subject: [PATCH] thermal: Add a new trip type to use cooling device instance number Date: Thu, 1 Dec 2011 19:59:23 +0530 Message-Id: <1322749763-11140-1-git-send-email-amit.kachhap@linaro.org> X-Mailer: git-send-email 1.7.1 This patch adds a new trip type THERMAL_TRIP_STATE_ACTIVE. This trip behaves same as THERMAL_TRIP_ACTIVE but also passes the cooling device instance number. This helps the cooling device registered as different instances to perform appropriate cooling action decision in the set_cur_state call back function. Also since the trip temperature's are in ascending order so some logic is put in place to skip the un-necessary checks. Signed-off-by: Amit Daniel Kachhap --- Documentation/thermal/sysfs-api.txt | 4 ++-- drivers/thermal/thermal_sys.c | 27 ++++++++++++++++++++++++++- include/linux/thermal.h | 1 + 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/Documentation/thermal/sysfs-api.txt b/Documentation/thermal/sysfs-api.txt index b61e46f..5c1d44e 100644 --- a/Documentation/thermal/sysfs-api.txt +++ b/Documentation/thermal/sysfs-api.txt @@ -184,8 +184,8 @@ trip_point_[0-*]_temp trip_point_[0-*]_type Strings which indicate the type of the trip point. - E.g. it can be one of critical, hot, passive, active[0-*] for ACPI - thermal zone. + E.g. it can be one of critical, hot, passive, active[0-1], + state-active[0-*] for ACPI thermal zone. RO, Optional cdev[0-*] diff --git a/drivers/thermal/thermal_sys.c b/drivers/thermal/thermal_sys.c index dd9a574..72b1ab3 100644 --- a/drivers/thermal/thermal_sys.c +++ b/drivers/thermal/thermal_sys.c @@ -192,6 +192,8 @@ trip_point_type_show(struct device *dev, struct device_attribute *attr, return sprintf(buf, "passive\n"); case THERMAL_TRIP_ACTIVE: return sprintf(buf, "active\n"); + case THERMAL_TRIP_STATE_ACTIVE: + return sprintf(buf, "state-active\n"); default: return sprintf(buf, "unknown\n"); } @@ -1035,7 +1037,7 @@ EXPORT_SYMBOL(thermal_cooling_device_unregister); void thermal_zone_device_update(struct thermal_zone_device *tz) { int count, ret = 0; - long temp, trip_temp; + long temp, trip_temp, max_state, last_trip_change = 0; enum thermal_trip_type trip_type; struct thermal_cooling_device_instance *instance; struct thermal_cooling_device *cdev; @@ -1086,6 +1088,29 @@ void thermal_zone_device_update(struct thermal_zone_device *tz) cdev->ops->set_cur_state(cdev, 0); } break; + case THERMAL_TRIP_STATE_ACTIVE: + list_for_each_entry(instance, &tz->cooling_devices, + node) { + if (instance->trip != count) + continue; + + if (temp <= last_trip_change) + continue; + + cdev = instance->cdev; + cdev->ops->get_max_state(cdev, &max_state); + + if ((temp >= trip_temp) && + ((count + 1) <= max_state)) + cdev->ops->set_cur_state(cdev, + count + 1); + else if ((temp < trip_temp) && + (count <= max_state)) + cdev->ops->set_cur_state(cdev, count); + + last_trip_change = trip_temp; + } + break; case THERMAL_TRIP_PASSIVE: if (temp >= trip_temp || tz->passive) thermal_zone_device_passive(tz, temp, diff --git a/include/linux/thermal.h b/include/linux/thermal.h index 47b4a27..d7d0a27 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -42,6 +42,7 @@ enum thermal_trip_type { THERMAL_TRIP_PASSIVE, THERMAL_TRIP_HOT, THERMAL_TRIP_CRITICAL, + THERMAL_TRIP_STATE_ACTIVE, }; struct thermal_zone_device_ops {