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: 37441 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f71.google.com (mail-la0-f71.google.com [209.85.215.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id AA7BF20549 for ; Tue, 16 Sep 2014 10:57:48 +0000 (UTC) Received: by mail-la0-f71.google.com with SMTP id mc6sf3086169lab.6 for ; Tue, 16 Sep 2014 03:57:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=c+fAqxW4wgRA8fcJtYUbyPKvh/Jnud8eyoJmIDWaVP0=; b=XByDAa0PF0gokfkJqyiZi3PRuBOoJYDyyRIS4LNZ1KofoKLJkHV1+UQaTUqbFoxdbH I1EeEsKWgltkI0REWcFr52a953At49BAyWx4DfTbr6qx2RjX0qscGXy6a5qbvC/EfyQI fHl7DwrfySZ+WRG6kDJkziwCmm7E4WOilMnL6A0GNKXi6PvJ8E2IYKMfIIzmXbAAQ0ql UQllQxgy6J1i+71Yh+izHkZ5qGX7hmj/DN1heFO5elIPJFCYS3RSl3Sx6ZKwq4nAbmP/ mD4C0fMIXY7QYztvwt1z+/ZJZ40cUX2d67KSRVbaAEA17QubG6GgQPS6k8Yrs2tEl6JH /CYQ== X-Gm-Message-State: ALoCoQmlJShNLbowcrs0AlD2UPxixo4CEeDb22dZs4++3a7vXj0vmeTVMtOZW3ZpTIKTZ4iHTfD4 X-Received: by 10.112.188.136 with SMTP id ga8mr8268143lbc.8.1410865067025; Tue, 16 Sep 2014 03:57:47 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.43.50 with SMTP id t18ls444049lal.104.gmail; Tue, 16 Sep 2014 03:57:46 -0700 (PDT) X-Received: by 10.153.5.9 with SMTP id ci9mr11158922lad.75.1410865066762; Tue, 16 Sep 2014 03:57:46 -0700 (PDT) Received: from mail-la0-f44.google.com (mail-la0-f44.google.com [209.85.215.44]) by mx.google.com with ESMTPS id mk4si23567040lbc.48.2014.09.16.03.57.45 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 16 Sep 2014 03:57:45 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.44 as permitted sender) client-ip=209.85.215.44; Received: by mail-la0-f44.google.com with SMTP id mc6so6541463lab.17 for ; Tue, 16 Sep 2014 03:57:45 -0700 (PDT) X-Received: by 10.112.33.74 with SMTP id p10mr33378064lbi.0.1410865065074; Tue, 16 Sep 2014 03:57:45 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.112.130.169 with SMTP id of9csp366945lbb; Tue, 16 Sep 2014 03:57:44 -0700 (PDT) X-Received: by 10.68.209.194 with SMTP id mo2mr49287080pbc.80.1410865063663; Tue, 16 Sep 2014 03:57:43 -0700 (PDT) Received: from mail-pd0-f177.google.com (mail-pd0-f177.google.com [209.85.192.177]) by mx.google.com with ESMTPS id fn7si28938468pab.68.2014.09.16.03.57.40 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 16 Sep 2014 03:57:41 -0700 (PDT) Received-SPF: none (google.com: sanjay.rawat@linaro.org does not designate permitted sender hosts) client-ip=209.85.192.177; Received: by mail-pd0-f177.google.com with SMTP id y10so8439118pdj.36 for ; Tue, 16 Sep 2014 03:57:39 -0700 (PDT) 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 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: sanjay.rawat@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.44 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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);