From patchwork Mon Jun 3 13:59:03 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Guo X-Patchwork-Id: 2652831 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) by patchwork2.kernel.org (Postfix) with ESMTP id 9ED63DF24C for ; Mon, 3 Jun 2013 13:58:46 +0000 (UTC) Received: from merlin.infradead.org ([205.233.59.134]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UjVHX-000174-VG; Mon, 03 Jun 2013 13:58:44 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UjVHW-0000jk-17; Mon, 03 Jun 2013 13:58:42 +0000 Received: from mail-db8lp0186.outbound.messaging.microsoft.com ([213.199.154.186] helo=db8outboundpool.messaging.microsoft.com) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UjVHS-0000iS-UO for linux-arm-kernel@lists.infradead.org; Mon, 03 Jun 2013 13:58:39 +0000 Received: from mail113-db8-R.bigfish.com (10.174.8.254) by DB8EHSOBE029.bigfish.com (10.174.4.92) with Microsoft SMTP Server id 14.1.225.23; Mon, 3 Jun 2013 13:58:16 +0000 Received: from mail113-db8 (localhost [127.0.0.1]) by mail113-db8-R.bigfish.com (Postfix) with ESMTP id 7D0CAA02A6; Mon, 3 Jun 2013 13:58:16 +0000 (UTC) X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPV:NLI; H:mail.freescale.net; RD:none; EFVD:NLI X-SpamScore: 0 X-BigFish: VS0(zzzz1f42h1ee6h1de0h1fdah1202h1e76h1d1ah1d2ah1fc6hzz8275dhz2dh87h2a8h668h839hd24he5bhf0ah1288h12a5h12a9h12bdh12e5h137ah139eh13b6h1441h1504h1537h162dh1631h1758h1898h18e1h1946h19b5h1ad9h1b0ah1d0ch1d2eh1d3fh1dc1h1dfeh1dffh1151h1155h) X-FB-DOMAIN-IP-MATCH: fail Received: from mail113-db8 (localhost.localdomain [127.0.0.1]) by mail113-db8 (MessageSwitch) id 1370267894558492_22294; Mon, 3 Jun 2013 13:58:14 +0000 (UTC) Received: from DB8EHSMHS011.bigfish.com (unknown [10.174.8.234]) by mail113-db8.bigfish.com (Postfix) with ESMTP id 85AA2220099; Mon, 3 Jun 2013 13:58:14 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by DB8EHSMHS011.bigfish.com (10.174.4.21) with Microsoft SMTP Server (TLS) id 14.1.225.23; Mon, 3 Jun 2013 13:58:14 +0000 Received: from tx30smr01.am.freescale.net (10.81.153.31) by 039-SN1MMR1-003.039d.mgd.msft.net (10.84.1.16) with Microsoft SMTP Server (TLS) id 14.2.328.11; Mon, 3 Jun 2013 13:59:16 +0000 Received: from S2101-09.ap.freescale.net ([10.192.185.233]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id r53Dw3GA029542; Mon, 3 Jun 2013 06:58:04 -0700 From: Shawn Guo To: Subject: [PATCH] thermal: thermal_core: policy store via sysfs is broken Date: Mon, 3 Jun 2013 21:59:03 +0800 Message-ID: <1370267943-13297-1-git-send-email-shawn.guo@linaro.org> X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 X-OriginatorOrg: sigmatel.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130603_095839_097800_26D9D370 X-CRM114-Status: UNSURE ( 8.68 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [213.199.154.186 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Eduardo Valentin , Zhang Rui , Shawn Guo , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org When function __find_governor() gets called from policy_store(), the argument 'buf' has a '\n' character at the end. This causes strnicmp() mismatches all the time. Consequently, policy_store() will always return -EINVAL, and hence the policy store via sysfs will always fail even when users store a correct policy name. Fix the problem by using strncasecmp() for policy name matching in __find_governor(). Signed-off-by: Shawn Guo --- drivers/thermal/thermal_core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index d755440..6ba869f 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c @@ -57,9 +57,10 @@ static struct thermal_governor *__find_governor(const char *name) { struct thermal_governor *pos; - list_for_each_entry(pos, &thermal_governor_list, governor_list) - if (!strnicmp(name, pos->name, THERMAL_NAME_LENGTH)) + list_for_each_entry(pos, &thermal_governor_list, governor_list) { + if (!strncasecmp(name, pos->name, strlen(pos->name))) return pos; + } return NULL; }