linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: zhong jiang <zhongjiang@huawei.com>
To: <stuyoder@gmail.com>, <laurentiu.tudor@nxp.com>
Cc: <linux-kernel@vger.kernel.org>
Subject: [PATCH] bus: fsl-mc: use match_string() helper to simplify the code
Date: Fri, 14 Sep 2018 23:03:24 +0800	[thread overview]
Message-ID: <1536937404-31455-1-git-send-email-zhongjiang@huawei.com> (raw)

match_string() returns the index of an array for a matching string,
which can be used intead of open coded implementation.

Signed-off-by: zhong jiang <zhongjiang@huawei.com>
---
 drivers/bus/fsl-mc/fsl-mc-allocator.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/bus/fsl-mc/fsl-mc-allocator.c b/drivers/bus/fsl-mc/fsl-mc-allocator.c
index e906ecfe..7ecc89c 100644
--- a/drivers/bus/fsl-mc/fsl-mc-allocator.c
+++ b/drivers/bus/fsl-mc/fsl-mc-allocator.c
@@ -160,16 +160,16 @@ static int __must_check object_type_to_pool_type(const char *object_type,
 						 enum fsl_mc_pool_type
 								*pool_type)
 {
-	unsigned int i;
+	int ret;
 
-	for (i = 0; i < ARRAY_SIZE(fsl_mc_pool_type_strings); i++) {
-		if (strcmp(object_type, fsl_mc_pool_type_strings[i]) == 0) {
-			*pool_type = i;
-			return 0;
-		}
+	ret = match_string(fsl_mc_pool_type_strings,
+			     ARRAY_SIZE(fsl_mc_pool_type_strings), object_type);
+	if (ret >= 0) {
+		*pool_type = ret;
+		return 0;
 	}
 
-	return -EINVAL;
+	return ret;
 }
 
 int __must_check fsl_mc_resource_allocate(struct fsl_mc_bus *mc_bus,
-- 
1.7.12.4


                 reply	other threads:[~2018-09-14 15:15 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1536937404-31455-1-git-send-email-zhongjiang@huawei.com \
    --to=zhongjiang@huawei.com \
    --cc=laurentiu.tudor@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stuyoder@gmail.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).