From: zhong jiang <zhongjiang@huawei.com>
To: <airlied@linux.ie>
Cc: <ville.syrjala@linux.intel.com>, <alexander.deucher@amd.com>,
<linux-kernel@vger.kernel.org>
Subject: [PATCH] drm: i2c: use match_string() helper to simplify the code
Date: Fri, 14 Sep 2018 23:01:55 +0800 [thread overview]
Message-ID: <1536937315-31350-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/gpu/drm/i2c/ch7006_drv.c | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
diff --git a/drivers/gpu/drm/i2c/ch7006_drv.c b/drivers/gpu/drm/i2c/ch7006_drv.c
index 544a8a2..ecabc92 100644
--- a/drivers/gpu/drm/i2c/ch7006_drv.c
+++ b/drivers/gpu/drm/i2c/ch7006_drv.c
@@ -440,7 +440,7 @@ static int ch7006_encoder_init(struct i2c_client *client,
struct drm_encoder_slave *encoder)
{
struct ch7006_priv *priv;
- int i;
+ int index;
ch7006_dbg(client, "\n");
@@ -464,14 +464,10 @@ static int ch7006_encoder_init(struct i2c_client *client,
priv->chip_version = ch7006_read(client, CH7006_VERSION_ID);
if (ch7006_tv_norm) {
- for (i = 0; i < NUM_TV_NORMS; i++) {
- if (!strcmp(ch7006_tv_norm_names[i], ch7006_tv_norm)) {
- priv->norm = i;
- break;
- }
- }
-
- if (i == NUM_TV_NORMS)
+ index = match_string(ch7006_tv_norm_names, NUM_TV_NORMS, ch7006_tv_norm);
+ if (index >= 0)
+ priv->norm = index;
+ else
ch7006_err(client, "Invalid TV norm setting \"%s\".\n",
ch7006_tv_norm);
}
--
1.7.12.4
reply other threads:[~2018-09-14 15:14 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=1536937315-31350-1-git-send-email-zhongjiang@huawei.com \
--to=zhongjiang@huawei.com \
--cc=airlied@linux.ie \
--cc=alexander.deucher@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=ville.syrjala@linux.intel.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).