From patchwork Fri Apr 26 20:35:57 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Pandruvada X-Patchwork-Id: 2495851 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 3B6663FDC4 for ; Fri, 26 Apr 2013 20:30:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932294Ab3DZUa4 (ORCPT ); Fri, 26 Apr 2013 16:30:56 -0400 Received: from mga02.intel.com ([134.134.136.20]:35977 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932161Ab3DZUaz (ORCPT ); Fri, 26 Apr 2013 16:30:55 -0400 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP; 26 Apr 2013 13:30:55 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.87,561,1363158000"; d="scan'208";a="303636366" Received: from spandruv-desktop.jf.intel.com ([10.7.199.75]) by orsmga001.jf.intel.com with ESMTP; 26 Apr 2013 13:30:55 -0700 From: Srinivas Pandruvada To: linux-acpi@vger.kernel.org Cc: rui.zhang@intel.com, linux-pm@vger.kernel.org, Srinivas Pandruvada Subject: [PATCH] thermal: Can't set policy Date: Fri, 26 Apr 2013 13:35:57 -0700 Message-Id: <1367008557-12443-1-git-send-email-srinivas.pandruvada@linux.intel.com> X-Mailer: git-send-email 1.7.11.7 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Setting policy results in invalid value error. >echo "step_wise" > policy >echo: write error: Invalid argument Need clean up of the buffer which "echo" may add based on the arguments, before comparing aganist list of governor names. Signed-off-by: Srinivas Pandruvada --- drivers/thermal/thermal_core.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 4cdc3e3..ed6904f 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -696,16 +696,27 @@ static ssize_t policy_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - int ret = -EINVAL; + int ret; struct thermal_zone_device *tz = to_thermal_zone(dev); struct thermal_governor *gov; + char str_gov[THERMAL_NAME_LENGTH]; + char format[6]; /* enough for 3 digit format width */ + + ret = snprintf(format, sizeof(format), "%%%ds", + THERMAL_NAME_LENGTH - 1); + if (ret < 0) + return ret; + ret = sscanf(buf, format, str_gov); + if (ret <= 0) + return -EINVAL; mutex_lock(&thermal_governor_lock); - gov = __find_governor(buf); - if (!gov) + gov = __find_governor(str_gov); + if (!gov) { + ret = -EINVAL; goto exit; - + } tz->governor = gov; ret = count;