All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yisheng Xie <xieyisheng1@huawei.com>
To: <alexander.shishkin@linux.intel.com>
Cc: <heikki.krogerus@linux.intel.com>, <linux-kernel@vger.kernel.org>,
	"Yisheng Xie" <xieyisheng1@huawei.com>
Subject: [PATCH] intel_th: pti: Convert to use sysfs_match_string() helper
Date: Wed, 16 May 2018 17:15:16 +0800	[thread overview]
Message-ID: <1526462116-10894-1-git-send-email-xieyisheng1@huawei.com> (raw)

The helper returns index of the matching string in an array,
use it to simpler the code.

Signed-off-by: Yisheng Xie <xieyisheng1@huawei.com>
---
 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

             reply	other threads:[~2018-05-16  9:26 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-16  9:15 Yisheng Xie [this message]
2018-05-21 22:16 ` [PATCH] intel_th: pti: Convert to use sysfs_match_string() helper Andy Shevchenko
2018-05-22  0:49   ` Yisheng Xie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1526462116-10894-1-git-send-email-xieyisheng1@huawei.com \
    --to=xieyisheng1@huawei.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.