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: 2652821 X-Patchwork-Delegate: rui.zhang@intel.com Return-Path: X-Original-To: patchwork-linux-pm@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 F3F353FC23 for ; Mon, 3 Jun 2013 13:58:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755520Ab3FCN6S (ORCPT ); Mon, 3 Jun 2013 09:58:18 -0400 Received: from mail-db8lp0184.outbound.messaging.microsoft.com ([213.199.154.184]:55578 "EHLO db8outboundpool.messaging.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754306Ab3FCN6R (ORCPT ); Mon, 3 Jun 2013 09:58:17 -0400 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: CC: Zhang Rui , Eduardo Valentin , , Shawn Guo 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 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.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; }