Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp945676imm; Mon, 21 May 2018 17:50:23 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqDBBfIRcDl9+PagDJSQv0XQn1+XXmVdR7TiNGaxSHwnmv2cW2RG+W6ckq3IGBIKcWM0S5A X-Received: by 2002:a62:a21e:: with SMTP id m30-v6mr22228546pff.251.1526950223546; Mon, 21 May 2018 17:50:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526950223; cv=none; d=google.com; s=arc-20160816; b=XhVesFnLvZqi/R2SbhnB5SaqsTzFVga/MrsHQHHVlQB5LRrLohCOEFwcv9pymeW98b hlPtNqqDsmhD4ssc+w6rkyjH1kZtInShjAz1sQZdkgyn4x+dVxUaEijipb8hbKm/Fdw9 nVPPzkVKFV9ABPVhNzU9cxiGe7EkJ/ERO9cOAwxjCdGKaZR9XpmsAPX8Tyz4vBRyQi0U ywu3U5k10KpfWPqgfxSrKeiBrV4N2oKxANO9e0ayvbibyMMXYs349pn+vo0+dB6uSwqJ Baa35iBmHDpUyp/Bxjxg4y6GDrQIN+PZVLqLOMIlrdXVk8Wu1y7ADefTOskhJLyGF+uN yQCA== 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:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject:arc-authentication-results; bh=PFskKrZB+2j/oM3O+7/k+/U3wztVhbJqjEyeHHStM4s=; b=tB4bu0qqLueX2SX/6jCNuB6R++MRWX2OUeQj9GQJQg2DpoOZSOkpIOQGPSY1I5vk+4 3yQE86xkStMP/IQmCH0+OFROvwS0WFdY/6klJ4NkiI3AZdc5tKAGFS2TUfyHmLHtKNmE /wTBbOOKQLiX5Z71ZyufIlEDOMzqygNZ3ZcXygo3kzCKe97QQ6Tlq2AvB/Gh1D0VZIzS CfmaSpaiKTbA6hSSSpqNcmsQyid6Yf/IKTuT/XkVTqEFMpTHD98zn2gaktfP0o4gfuof fQ/U3pkYODeHv7oUJ0Ae57fXnvzoah5tMJ4FhLKFbK7KJgZYm8q69tey8Q9JqAFvU8u4 6Itw== 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 u14-v6si15314889pfa.84.2018.05.21.17.50.09; Mon, 21 May 2018 17:50:23 -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 S1752062AbeEVAtx (ORCPT + 99 others); Mon, 21 May 2018 20:49:53 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:60359 "EHLO huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1751101AbeEVAtt (ORCPT ); Mon, 21 May 2018 20:49:49 -0400 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 9BFC34699F68E; Tue, 22 May 2018 08:49:46 +0800 (CST) Received: from [127.0.0.1] (10.177.29.40) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.382.0; Tue, 22 May 2018 08:49:43 +0800 Subject: Re: [PATCH] intel_th: pti: Convert to use sysfs_match_string() helper To: Andy Shevchenko References: <1526462116-10894-1-git-send-email-xieyisheng1@huawei.com> CC: Alexander Shishkin , "Krogerus, Heikki" , Linux Kernel Mailing List From: Yisheng Xie Message-ID: <258eebad-2552-1581-5fba-a98c84340061@huawei.com> Date: Tue, 22 May 2018 08:49:40 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.1.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.29.40] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Andy, On 2018/5/22 6:16, Andy Shevchenko wrote: > On Wed, May 16, 2018 at 12:15 PM, Yisheng Xie wrote: >> The helper returns index of the matching string in an array, >> use it to simpler the code. > > IIRC I sent the patch with the same semantics week or so ago against this file. Right, I get it. Sorry about that. Thanks Yisheng > >> >> Signed-off-by: Yisheng Xie >> --- >> drivers/hwtracing/intel_th/pti.c | 11 ++++------- >> 1 file changed, 4 insertions(+), 7 deletions(-) >> >> diff --git a/drivers/hwtracing/intel_th/pti.c b/drivers/hwtracing/intel_th/pti.c >> index 5669433..75cb368 100644 >> --- a/drivers/hwtracing/intel_th/pti.c >> +++ b/drivers/hwtracing/intel_th/pti.c >> @@ -272,15 +272,12 @@ static ssize_t lpp_dest_store(struct device *dev, struct device_attribute *attr, >> const char *buf, size_t size) >> { >> struct pti_device *pti = dev_get_drvdata(dev); >> - ssize_t ret = -EINVAL; >> - int i; >> + ssize_t ret; >> >> - for (i = 0; i < ARRAY_SIZE(lpp_dest_str); i++) >> - if (sysfs_streq(buf, lpp_dest_str[i])) >> - break; >> + ret = sysfs_match_string(lpp_dest_str, buf); >> >> - if (i < ARRAY_SIZE(lpp_dest_str) && pti->lpp_dest_mask & BIT(i)) { >> - pti->lpp_dest = i; >> + if (ret >= 0 && pti->lpp_dest_mask & BIT(ret)) { >> + pti->lpp_dest = ret; >> ret = size; >> } >> >> -- >> 1.7.12.4 >> > > >