Skip to contentSkip to conversation

drm: i2c: use match_string() helper to simplify the code

PATCH New zhong jiang 1 participant 1 message Sep 14, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm: i2c: use match_string() helper to simplify the code

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

---
 drivers/gpu/drm/i2c/ch7006_drv.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)
drivers/gpu/drm/i2c/ch7006_drv.c +5 -9
index 544a8a2..ecabc92 100644
@@ -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);
 	}
Signature · 1 line
1.7.12.4