From patchwork Tue Sep 16 10:57:42 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sanjay Singh Rawat X-Patchwork-Id: 4916321 X-Patchwork-Delegate: rui.zhang@intel.com Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 99EA2BEEA6 for ; Tue, 16 Sep 2014 10:57:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 73847200DF for ; Tue, 16 Sep 2014 10:57:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 31BC5201DE for ; Tue, 16 Sep 2014 10:57:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753636AbaIPK5m (ORCPT ); Tue, 16 Sep 2014 06:57:42 -0400 Received: from mail-pd0-f170.google.com ([209.85.192.170]:63160 "EHLO mail-pd0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752061AbaIPK5l (ORCPT ); Tue, 16 Sep 2014 06:57:41 -0400 Received: by mail-pd0-f170.google.com with SMTP id fp1so8494034pdb.1 for ; Tue, 16 Sep 2014 03:57:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=c+fAqxW4wgRA8fcJtYUbyPKvh/Jnud8eyoJmIDWaVP0=; b=kfsSWPHSo+1YHDEGIZC6n1Wjz7MgtoPNbNoJxLU3VNM4+24Q6d4FPvUmAGoz2Lpupu kb4Ukhgcp94wV3+WKd6SU66mER9oTGKNCxIO6wouECaO7DJO4CX2OurpgPxqL33gWxIy lS/K07ZeNeXARRJoiW429j4xZVNm3I21WUnGUZ0feFaInWPBDECZnBjN71jT3mmF7NMX yRG283Q7rUb8tQtyMz6aLMxB8uQb4Y8WG5A7woHjM6BzkJC22UzuFmlqqWq2LnhHx0so tuS9O8zE/N1D3GiMySkBjJdL0uWVRi3p8es8gCDzfJFlpKSLswCXrI6CEHH4l+0iEfEq veJw== X-Gm-Message-State: ALoCoQm7BaGdH2rGih9BVlzCrglurX+aCGO2Q/DjAZDlWormnBFt053nAobcej/PHuPMs+Ja3TWC X-Received: by 10.69.18.202 with SMTP id go10mr49994316pbd.84.1410865059255; Tue, 16 Sep 2014 03:57:39 -0700 (PDT) Received: from ubuntu5e03.LGE.NET ([203.247.149.152]) by mx.google.com with ESMTPSA id i17sm10687584pdj.18.2014.09.16.03.57.32 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 16 Sep 2014 03:57:36 -0700 (PDT) From: Sanjay Singh Rawat To: rui.zhang@intel.com, edubezval@gmail.com Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linaro-kernel@lists.linaro.org, Sanjay Singh Rawat Subject: [PATCH] thermal: show supported policies Date: Tue, 16 Sep 2014 16:27:42 +0530 Message-Id: <1410865062-28995-1-git-send-email-sanjay.rawat@linaro.org> X-Mailer: git-send-email 1.8.3.2 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-5.4 required=5.0 tests=BAYES_00, RCVD_IN_BL_SPAMCOP_NET, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_WEB, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP With knowledge of supported thermal policies from this attribute, it helps in setting the policy without failure from the available ones. Signed-off-by: Sanjay Singh Rawat --- drivers/thermal/thermal_core.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 71b0ec0..6caefcd 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -772,6 +772,25 @@ policy_show(struct device *dev, struct device_attribute *devattr, char *buf) return sprintf(buf, "%s\n", tz->governor->name); } +static ssize_t +available_policy_show(struct device *dev, struct device_attribute *devattr, + char *buf) +{ + ssize_t i = 0; + struct thermal_governor *temp; + struct thermal_zone_device *tz = to_thermal_zone(dev); + + mutex_lock(&tz->lock); + + list_for_each_entry(temp, &thermal_governor_list, governor_list) + i += sprintf(&buf[i], "%s ", temp->name); + + mutex_unlock(&tz->lock); + i += sprintf(&buf[i], "\n"); + + return i; +} + #ifdef CONFIG_THERMAL_EMULATION static ssize_t emul_temp_store(struct device *dev, struct device_attribute *attr, @@ -805,6 +824,7 @@ static DEVICE_ATTR(temp, 0444, temp_show, NULL); static DEVICE_ATTR(mode, 0644, mode_show, mode_store); static DEVICE_ATTR(passive, S_IRUGO | S_IWUSR, passive_show, passive_store); static DEVICE_ATTR(policy, S_IRUGO | S_IWUSR, policy_show, policy_store); +static DEVICE_ATTR(available_policy, S_IRUGO, available_policy_show, NULL); /* sys I/F for cooling device */ #define to_cooling_device(_dev) \ @@ -1538,6 +1558,10 @@ struct thermal_zone_device *thermal_zone_device_register(const char *type, if (result) goto unregister; + result = device_create_file(&tz->device, &dev_attr_available_policy); + if (result) + goto unregister; + /* Update 'this' zone's governor information */ mutex_lock(&thermal_governor_lock);