From patchwork Mon Aug 27 04:28:18 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: durgadoss.r@intel.com X-Patchwork-Id: 1376181 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 C821740D1A for ; Mon, 27 Aug 2012 04:29:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751495Ab2H0E3R (ORCPT ); Mon, 27 Aug 2012 00:29:17 -0400 Received: from mga09.intel.com ([134.134.136.24]:4000 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751775Ab2H0E3Q (ORCPT ); Mon, 27 Aug 2012 00:29:16 -0400 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP; 26 Aug 2012 21:29:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.80,318,1344236400"; d="scan'208";a="191657077" Received: from dr3-desktop.iind.intel.com ([10.223.107.36]) by orsmga002.jf.intel.com with ESMTP; 26 Aug 2012 21:29:13 -0700 From: Durgadoss R To: lenb@kernel.org, rui.zhang@intel.com Cc: linux-acpi@vger.kernel.org, eduardo.valentin@ti.com, Durgadoss R Subject: [PATCHv2 06/14] Thermal: Add a policy sysfs attribute Date: Mon, 27 Aug 2012 09:58:18 +0530 Message-Id: <1346041706-29642-7-git-send-email-durgadoss.r@intel.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1346041706-29642-1-git-send-email-durgadoss.r@intel.com> References: <1346041706-29642-1-git-send-email-durgadoss.r@intel.com> Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org This patch adds a policy sysfs attribute to a thermal zone. This attribute will give us the throttling policy used for the zone. This is a RO attribute. Signed-off-by: Durgadoss R --- drivers/thermal/thermal_sys.c | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/drivers/thermal/thermal_sys.c b/drivers/thermal/thermal_sys.c index 6adda39..8aa4200a6 100644 --- a/drivers/thermal/thermal_sys.c +++ b/drivers/thermal/thermal_sys.c @@ -378,10 +378,32 @@ passive_show(struct device *dev, struct device_attribute *attr, return sprintf(buf, "%d\n", tz->forced_passive); } +static ssize_t +policy_show(struct device *dev, struct device_attribute *devattr, char *buf) +{ + struct thermal_zone_device *tz = to_thermal_zone(dev); + struct thermal_zone_params *tzp = tz->tzp; + + if (!tzp) + return sprintf(buf, "step_wise(default)\n"); + + switch (tzp->throttle_policy) { + case THERMAL_FAIR_SHARE: + return sprintf(buf, "fair_share\n"); + case THERMAL_STEP_WISE: + return sprintf(buf, "step_wise\n"); + case THERMAL_USER_SPACE: + return sprintf(buf, "user_space\n"); + default: + return sprintf(buf, "unknown\n"); + } +} + static DEVICE_ATTR(type, 0444, type_show, NULL); 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(throttle_policy, S_IRUGO, policy_show, NULL); /* sys I/F for cooling device */ #define to_cooling_device(_dev) \ @@ -1349,10 +1371,16 @@ static int retrieve_zone_params(struct thermal_zone_device *tz) /* It is not an error to not have any platform data */ ret = get_platform_thermal_params(tz); - if (ret) + if (ret) { tz->tzp = NULL; + return 0; + } - return 0; + ret = device_create_file(&tz->device, &dev_attr_throttle_policy); + if (ret) + dev_err(&tz->device, "creating policy attr failed:%d\n", ret); + + return ret; } /**