Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp916730imm; Fri, 14 Sep 2018 08:15:08 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZUp0kEANL7olHUuVZc14Tj53H0/IdzpQvRIEcYcaXfUr+u27R5LN37LEC0myxV9rCTIwvj X-Received: by 2002:aa7:86cb:: with SMTP id h11-v6mr12990093pfo.58.1536938108324; Fri, 14 Sep 2018 08:15:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536938108; cv=none; d=google.com; s=arc-20160816; b=fI7exT4USPuiAQemKF0FVmlkJPseHNrVBqwBfNxxUS79IAMHRzUZrSliy5xemx7QZT 5L+odoZRPOKcTHZwRviXF3rXhi9Sq6RIUA8iYkSHa8e7ljPU4dAZVvvMKHp43HIcW/cq hTPR4fOvVXOmsMqdPVZIP4Bvfkpc2llCZ/6hnISLZ9HAs6lpJZKAVu7aGdrarTWrpzSf 6/ToSoD+KZgw9Y1CHvvesl+EaRS2iubAAHxCg1Ui6EUNGsTVMK+JkiqnWCHdQDJJZFhF WwpGvUSzZ5mZ3RPfW3UNu4yc9eD7p8TO5368oyqfokOMq9rKQ3Sz9NTkWLmbcS3XeJC0 7dLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=wER/RiWrw1le6rums1EgE+y/CGOfF9ViYooL9+nSsBs=; b=YyqSzWOw3CM8Lx/gt0OWyhFvsgfKYFdK5R92jtV7I7gNa6MR6d9DQXm+Z97FEAwXc5 rwasrqEUpLrY7iBh5nQIha4nLjzfYz0wPJIODNtOxC2jjDjDHrqJcp+WFTQqb2aQ3EVZ l/nrkclaFJTxmBfarlctXzlZD8LGM1djiLoPABSuXhEKIBY7tAOjsoJuZ5TRQukF21oq MGg5U4zUPmjbkNtWXWHaZU2t7CY1KTGVjnTJkKLPvrBDODyNPfJV6ubH9cxoZBQgEtUE DfdalEea48wd5PNxQBr7j3QFZBL+7xcpo9oh1g/UFdS/2RT+jfPdSKXIpOi8Goy2MCcj ATBg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g16-v6si7133804pgj.35.2018.09.14.08.14.43; Fri, 14 Sep 2018 08:15:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728160AbeINU3N (ORCPT + 99 others); Fri, 14 Sep 2018 16:29:13 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:12140 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726925AbeINU3N (ORCPT ); Fri, 14 Sep 2018 16:29:13 -0400 Received: from DGGEMS413-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id BC12B458EFE88; Fri, 14 Sep 2018 23:14:11 +0800 (CST) Received: from linux-ibm.site (10.175.102.37) by DGGEMS413-HUB.china.huawei.com (10.3.19.213) with Microsoft SMTP Server id 14.3.399.0; Fri, 14 Sep 2018 23:14:11 +0800 From: zhong jiang To: CC: , , Subject: [PATCH] drm: i2c: use match_string() helper to simplify the code Date: Fri, 14 Sep 2018 23:01:55 +0800 Message-ID: <1536937315-31350-1-git-send-email-zhongjiang@huawei.com> X-Mailer: git-send-email 1.7.12.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.102.37] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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