Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1748722imm; Wed, 16 May 2018 02:26:29 -0700 (PDT) X-Google-Smtp-Source: AB8JxZr53liEkl561YBLurofmuwR2aqWrwdJbeCIEd9Q8g3MJ7ivX3gHxpeq3F+VWRY6b0dg6H+3 X-Received: by 2002:a65:65d5:: with SMTP id y21-v6mr56176pgv.277.1526462789753; Wed, 16 May 2018 02:26:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526462789; cv=none; d=google.com; s=arc-20160816; b=yNfEr6HqjzLx1DHTE01rsHW/Pl4MF1bZHGS+M1fy7AFhDg6BnNs+DrdMFo/6tTxuNe 7kQY8P3AMpRTsDI/Q63LKYK0lvya6HmeOXY/txrhjd0QLTE6wpd9MTi4yytrION0BOrG SBxfi0cctSPGUUM2et7gDT29fkQDJvEA/KtbAIU94X5i+JkdQeTsetW2BWvghjp2Jgo5 M7xszKsPYvlucfJgNAkvEu2FdCxJjUvEb7KWKnuozx3mEedVVKTpznrrhhEyY7K+u+Hh WBq5kju3UEI0nRzvoDO5hjrQuYZ/bLDRY5Pkq5A/IqqukqXTtdHjdHDJpf1aRH0NOXbg hikg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from:arc-authentication-results; bh=jvUHNQ/klpBh6pW+kmHTIgbAn2pE+usaijZr76e8Bh0=; b=rGpJqdTRGyaqqrGgC5Oe/S5s4sy4W19oujGU9iiroZvgC3AIHGy2Zc35zw9Dp5bVN6 lpvCNR6ztT4+XgQZaUAQr8IAGE+CJzsTgTwl+MyJEHXL/jdhYY1sQmp1u72E6WfP2CnG a3Nh7/w1TdvQnFdIYgmeC9xaAZHcXJxs7+gNBIg9C2v22r+15rERWKppavdJMSdu1Bps 9RkIhhKLt8QIkm3OZ7KNtk2ZUmgoDhIUqBzoAf1HJbLpQY/w9jIIQWNe8fTU5Ya8RkN9 zy2xUBI9J+4Ead1oaZ9gWZemvxW+E2KGzCTOobc++YA0jsWetpMarQeYPdtqy4iPSKn+ a17A== 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 b9-v6si1910719plb.522.2018.05.16.02.26.14; Wed, 16 May 2018 02:26:29 -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 S1752101AbeEPJZ7 (ORCPT + 99 others); Wed, 16 May 2018 05:25:59 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:7674 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751904AbeEPJZ6 (ORCPT ); Wed, 16 May 2018 05:25:58 -0400 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id BF8D36BD9E33C; Wed, 16 May 2018 17:25:44 +0800 (CST) Received: from linux-ibm.site (10.175.102.37) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.361.1; Wed, 16 May 2018 17:25:39 +0800 From: Yisheng Xie To: CC: , , "Yisheng Xie" Subject: [PATCH] intel_th: pti: Convert to use sysfs_match_string() helper Date: Wed, 16 May 2018 17:15:16 +0800 Message-ID: <1526462116-10894-1-git-send-email-xieyisheng1@huawei.com> X-Mailer: git-send-email 1.7.12.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.102.37] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The helper returns index of the matching string in an array, use it to simpler the code. 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