Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp827938imm; Mon, 21 May 2018 15:16:38 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrDm9J5fhl7sRGUY5PYyCp1CCwoupnf8REp7ZR74S8sonJR0WVcEQZlKIxzX4LBB4YJq2WX X-Received: by 2002:a17:902:bb84:: with SMTP id m4-v6mr21941853pls.339.1526940998228; Mon, 21 May 2018 15:16:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526940998; cv=none; d=google.com; s=arc-20160816; b=Fz8hEBi5bLI2LD0I370N/5VI5714qURrPvXxzmq8kZ17wJ0Mr+6+Y3ZrDhIEcHeyYE /YFg0gcT4yG5mcXieELCsGn3/egU6dJav9L1siu/3QLt73Dg0tU+5Ivk4N+1M+MXl0PG FmlpS3316hIsZc0OS8Q6DhtjBoVtCYvSnOfvJQ3AE1zZbSpDHc1VYoO+GdQrEVL57fmr XQr70XmsHEesm+Pi7B/1RwtbtJ4nldJ7EuTUwt50ST6NeJxXJCtaDysULz+Ajojn3EEn lBtRui/NkxHnsfjb6j8toZ6oOqCcUS8WNciL/x8dV8G75Prhm5P/iRnGK8GnjRAP9ChS 1a2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=Cc717HO4IBwUT0TvOkDlEDEq6KKzrbdhX5aknq/GH8o=; b=1H5ltnh75Ljf9EwjoWfLNpVC4L/labiS/Cu/UK+Z5AzdSg81gvf6cSh9ep/Pe/OpY8 +GBZ1yb5wqiXbkH3UPPOTz28KMcltf1h4nx1NX+qteLym4e4iFLbpsnfuLREeGmI3qma r12A3UBb/H4CfyGqZXpV/yRkMUfriJF20ubrLcuyb9QX1QabEeU+PbNk3EzL7CWVhdMC 4eq86wk/IFp9BH11zl3m8yu0w7H5t9tm2BiBy+AvcfYOdGymsMk0NjiZusbzna6zFRrb UHj3JluBUaPclVXnXB5Yj+qVRvs3dLDvIDufQSsQhVnaCckk3YWV6O/AP0zo5sGI6nOZ OwdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=lt98a/l0; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a90-v6si14867098plc.329.2018.05.21.15.16.23; Mon, 21 May 2018 15:16:38 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=lt98a/l0; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753601AbeEUWQO (ORCPT + 99 others); Mon, 21 May 2018 18:16:14 -0400 Received: from mail-qk0-f193.google.com ([209.85.220.193]:41989 "EHLO mail-qk0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751905AbeEUWQI (ORCPT ); Mon, 21 May 2018 18:16:08 -0400 Received: by mail-qk0-f193.google.com with SMTP id b22-v6so13043228qkj.9 for ; Mon, 21 May 2018 15:16:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=Cc717HO4IBwUT0TvOkDlEDEq6KKzrbdhX5aknq/GH8o=; b=lt98a/l01UZGcaJOSS7mFN33H47Z4Jy37ODe9+r5woB/oIIUR3AGw4eEIotQsLyR4/ dH3yiXcR+/yGcE2LH+R0Gz0XAukJYUikFBjqp4T44JnfleNjzUccHPgBPNmLxBM1VEIb urzvI1+himMvrdydpww/ZYxYMrX2FY+6aULHgNVEFUpIzYCDVN/oheDWd56e0rJ3147M miDTLvZLvtSBHqJMp8UlsOWdp7sL1gPwgNFmOfX40XCjynwFONi7JSyCG52U5tQxMN5F kA7m6a/84LiejV/OjmdG702zlq+6PYU81soas141csCueBrg2oYo6JllAVzH0cfa32Yk XlvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=Cc717HO4IBwUT0TvOkDlEDEq6KKzrbdhX5aknq/GH8o=; b=bP/0oAfT97AhBidIckyBpQ7ji50wj8yJtG4bexxRCCH5hD0QYeD7u/9+FBvlVND8dp kzDhcGueCfR0nGTdkT2t5/UyOr1RXGLXsfMUOhuy0kavklqs/LaYrJOmA8sKMhG69d6a cA9bDAwmgp8+XMgzEmYcY6ET+a5RxFz5zrtDrATFlw+gk7g2a5kY9pbztQbCSgHIbExt Y8veaxNFMrldEnpWIdv8e7H0k2oL7n0cwa8bSg1HKGJjR6b52dTFZ7DPXLJIarc4q03K f+Lw3inMvT1bJdHt99B91s8ZxjI9GkJZf4SBu0iqJawf1v4s8ztIy+n0m/SqU431qr7n gE9g== X-Gm-Message-State: ALKqPwe1h9HegizX+uBgGrU4ga1hUDBwxQG/FHbcOJ19M1DoqQMF3Tk0 eGbBTDnWOWOVwqgT5jPBKMMgLGKGmx+56jkAUvU= X-Received: by 2002:a37:d1d3:: with SMTP id o80-v6mr18959668qkl.3.1526940967415; Mon, 21 May 2018 15:16:07 -0700 (PDT) MIME-Version: 1.0 Received: by 10.12.152.150 with HTTP; Mon, 21 May 2018 15:16:06 -0700 (PDT) In-Reply-To: <1526462116-10894-1-git-send-email-xieyisheng1@huawei.com> References: <1526462116-10894-1-git-send-email-xieyisheng1@huawei.com> From: Andy Shevchenko Date: Tue, 22 May 2018 01:16:06 +0300 Message-ID: Subject: Re: [PATCH] intel_th: pti: Convert to use sysfs_match_string() helper To: Yisheng Xie Cc: Alexander Shishkin , "Krogerus, Heikki" , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. > > 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 > -- With Best Regards, Andy Shevchenko