Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp5263948imm; Tue, 26 Jun 2018 08:25:48 -0700 (PDT) X-Google-Smtp-Source: AAOMgpe95Yo0jd5IwdmgVJregkacZ4yqwybXUDAfxYUXunpXl6NUZnu1V+IK/DAN52ouNK9XsQie X-Received: by 2002:a62:33c4:: with SMTP id z187-v6mr2050209pfz.190.1530026748208; Tue, 26 Jun 2018 08:25:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530026748; cv=none; d=google.com; s=arc-20160816; b=GqZB1A9xSgePWDqmn4dc6Fj6cDNzZ+0u8roqmBq5Qs2hXHyOzl3JIChtz6MVbh8vk8 HA2fxFvS2YkA9uZYFaT79DPnEnB9KnYkHLF92A2/C8xbtTIXvW9Cz/o28nCu99WKhLew EW6sCOod1Aj8Q9DgHSmKchqhmfK9uxk3biCaYmGDisUrud/s1RCdQOc+0AO7OUlREDtI sMHCJl0dkPcgLypCpEV85syZ2vDo1aiynotFNMTU9fhLO6wDB3dec1T/4m2mJ8QyvthW PBDLRIs4JQX+mIdYqCq8V+sLCHr5JLC6t6evyfZGvq5/Yoh0lNQDZVeFve4mIyZj1cQw R2xw== 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:message-id:date:subject:cc:to:from :arc-authentication-results; bh=SKisIPk1mX0TzTSZqAxxxcj6+3EB7C4D3kcIvNttcuM=; b=QrFe7CNTT5kCHv/z1gS5ic7y3ZDZC/BevscXG8ORqIceete+62pn1S7lQw35xFimdv NDvoh/wjZFnv8Pi0arPWKxNf1iuD4mm/cwm85dG0+/b6CVgyUweekWdlUwrcc+gb+244 yIj0uC8zgYM1vpP1aWxkPMng1uf8LFXeNNvr+2rTeMgKCSRSb3QF8izqXlGvU7kAbMEG XhJq4JdFqICaWlL9Jd19pPvFxMOxPSl5lZwwL8lcU8vm5Vq/fYMP0YxO5yGC4cCfN7sd ZS/pNk0dX0VVD8HzO3hJN1AGm0mypev3unyVsL/v+GqtTKujlLW6BT4QzF2qm5+6Nnuv A5mQ== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q2-v6si1763527plh.136.2018.06.26.08.25.33; Tue, 26 Jun 2018 08:25:48 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751773AbeFZPY3 (ORCPT + 99 others); Tue, 26 Jun 2018 11:24:29 -0400 Received: from cloudserver094114.home.pl ([79.96.170.134]:49296 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751072AbeFZPY2 (ORCPT ); Tue, 26 Jun 2018 11:24:28 -0400 Received: from 79.184.255.183.ipv4.supernova.orange.pl (79.184.255.183) (HELO aspire.rjw.lan) by serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer 0.83) id aeb47dd5528fa76a; Tue, 26 Jun 2018 17:24:27 +0200 From: "Rafael J. Wysocki" To: Yisheng Xie , Srinivas Pandruvada Cc: linux-kernel@vger.kernel.org, andy.shevchenko@gmail.com, Len Brown , Viresh Kumar , linux-pm@vger.kernel.org Subject: Re: [PATCH v2 10/21] cpufreq: intel_pstate: use match_string() helper Date: Tue, 26 Jun 2018 17:23:10 +0200 Message-ID: <1633797.WhvbXNE1Nx@aspire.rjw.lan> In-Reply-To: <1527765086-19873-11-git-send-email-xieyisheng1@huawei.com> References: <1527765086-19873-1-git-send-email-xieyisheng1@huawei.com> <1527765086-19873-11-git-send-email-xieyisheng1@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > 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(-) > > 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_data, 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?