* [PATCH -next] drm/ch7006: Use match_string() helper to simplify the code
@ 2020-01-10 9:19 YueHaibing
0 siblings, 0 replies; only message in thread
From: YueHaibing @ 2020-01-10 9:19 UTC (permalink / raw)
To: airlied, daniel, yuehaibing, alexander.deucher; +Cc: linux-kernel, dri-devel
match_string() returns the array index of a matching string.
Use it instead of the open-coded implementation.
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
drivers/gpu/drm/i2c/ch7006_drv.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/drivers/gpu/drm/i2c/ch7006_drv.c b/drivers/gpu/drm/i2c/ch7006_drv.c
index b91e48d..f9a46b5 100644
--- a/drivers/gpu/drm/i2c/ch7006_drv.c
+++ b/drivers/gpu/drm/i2c/ch7006_drv.c
@@ -464,16 +464,13 @@ 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)
+ i = match_string(ch7006_tv_norm_names, NUM_TV_NORMS,
+ ch7006_tv_norm);
+ if (i < 0)
ch7006_err(client, "Invalid TV norm setting \"%s\".\n",
ch7006_tv_norm);
+ else
+ priv->norm = i;
}
if (ch7006_scale >= 0 && ch7006_scale <= 2)
--
2.7.4
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2020-01-12 12:36 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-10 9:19 [PATCH -next] drm/ch7006: Use match_string() helper to simplify the code YueHaibing
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).