Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp5809078imm; Tue, 26 Jun 2018 19:12:55 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLne/BVVMVn8qpWG9yzJmRAQlzQf1pke+ZYpDcovywOfj5VzJmaxrrc4y5qT1BRUZdTbwvr X-Received: by 2002:a17:902:1127:: with SMTP id d36-v6mr4090752pla.267.1530065575582; Tue, 26 Jun 2018 19:12:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530065575; cv=none; d=google.com; s=arc-20160816; b=eUT5GOuRehMt2XHzK4EYUHCtQp2B7l+/0ViwL8M1oHCx5+R4MyBa0JC1GNGi/yLTuH USnKQR55s4pVH0c5+A+1rPz9lkftOXV5Zp/yRKYuc0tmy33IF181ENoVOwO+gxLP4Ib5 hi624AuJQYP9t5lA94+44Y2fdkKV3/rYY8Ms2+sOo0kTVqNulaFJJhZwCFtuMaAR/4Wd luul+tPHLQLVKjMePw0axIoB3l+8HVJXrHxuvEweSaDa4KKV3NJR+jW+1gXbJ6Sws5MZ AN66qxQSIlfs92H19yMydTtg1FUPZ7pLDV1bRJQUR1EX4Uzu5zAwgysf2vwNyXvF2C1R Py6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id :arc-authentication-results; bh=gxFTqVWggYqN53p2/9mnT+3rS61DqkUDgyotmOKaWGE=; b=Ol0CcodemQe4HkX5s9vmOR0RxQyaAVeqbuV7SC3sAREbXEJDNZReyEO1g66rJalq3i XUk2X/cj/DeMzfjCc16dkPXbQ852pdpZL5tOXZ5dEgNTeyM4TD/oFBQ0/FIJPIBvjpRy HJ6HGtUt4SeSmi5EqwuSZb5OXlzMLVKLswslxfBXpeJZEysAkbGN68UtZJkv3THWR5ay 1dTDHugX4QaEDATrnHnoRtpkQXc59k/HPK54XxibRpaA8MqxfJP/EVEbnK0vEePPAB36 Qxa91eZlelElc4zZ02Ttvnw+gQnEXrhr3KMQHJxA7syZ1kPpiXBOMKsrGhE7e9xEh0sn iA/w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g33-v6si2954289plb.297.2018.06.26.19.12.41; Tue, 26 Jun 2018 19:12:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754519AbeFZX4e (ORCPT + 99 others); Tue, 26 Jun 2018 19:56:34 -0400 Received: from mga07.intel.com ([134.134.136.100]:1613 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752209AbeFZX4d (ORCPT ); Tue, 26 Jun 2018 19:56:33 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Jun 2018 16:56:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,276,1526367600"; d="scan'208";a="50794618" Received: from spandruv-desk.jf.intel.com ([10.54.75.31]) by fmsmga008.fm.intel.com with ESMTP; 26 Jun 2018 16:56:30 -0700 Message-ID: <9ae4955e8026e1ddf0567e5cc210c5713668b631.camel@linux.intel.com> Subject: Re: [PATCH v2 10/21] cpufreq: intel_pstate: use match_string() helper From: Srinivas Pandruvada To: "Rafael J. Wysocki" , Yisheng Xie Cc: linux-kernel@vger.kernel.org, andy.shevchenko@gmail.com, Len Brown , Viresh Kumar , linux-pm@vger.kernel.org Date: Tue, 26 Jun 2018 16:56:30 -0700 In-Reply-To: <1633797.WhvbXNE1Nx@aspire.rjw.lan> References: <1527765086-19873-1-git-send-email-xieyisheng1@huawei.com> <1527765086-19873-11-git-send-email-xieyisheng1@huawei.com> <1633797.WhvbXNE1Nx@aspire.rjw.lan> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.2 (3.28.2-1.fc28) Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2018-06-26 at 17:23 +0200, Rafael J. Wysocki wrote: > On Thursday, May 31, 2018 1:11:15 PM CEST Yisheng Xie wrote: > > match_string() returns the index of an array for a matching string, > > which can be used instead of open coded variant. > > > > Reviewed-by: Andy Shevchenko Acked-by: Srinivas Pandruvada > > Cc: Srinivas Pandruvada > > Cc: Len Brown > > Cc: "Rafael J. Wysocki" > > Cc: Viresh Kumar > > Cc: linux-pm@vger.kernel.org > > Signed-off-by: Yisheng Xie > > --- > > v2: > > - add Reviewed-by tag. > > > > drivers/cpufreq/intel_pstate.c | 15 ++++++--------- > > 1 file changed, 6 insertions(+), 9 deletions(-) > > performance > > diff --git a/drivers/cpufreq/intel_pstate.c > > b/drivers/cpufreq/intel_pstate.c > > index 17e566af..d701e26 100644 > > --- a/drivers/cpufreq/intel_pstate.c > > +++ b/drivers/cpufreq/intel_pstate.c > > @@ -645,21 +645,18 @@ static ssize_t > > store_energy_performance_preference( > > { > > struct cpudata *cpu_data = all_cpu_data[policy->cpu]; > > char str_preference[21]; > > - int ret, i = 0; > > + int ret; > > > > ret = sscanf(buf, "%20s", str_preference); > > if (ret != 1) > > return -EINVAL; > > > > - while (energy_perf_strings[i] != NULL) { > > - if (!strcmp(str_preference, > > energy_perf_strings[i])) { > > - intel_pstate_set_energy_pref_index(cpu_dat > > a, i); > > - return count; > > - } > > - ++i; > > - } > > + ret = match_string(energy_perf_strings, -1, > > str_preference); > > + if (ret < 0) > > + return ret; > > > > - return -EINVAL; > > + intel_pstate_set_energy_pref_index(cpu_data, ret); > > + return count; > > } > > > > static ssize_t show_energy_performance_preference( > > > > Srinivas, any concerns? >