Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp228103imm; Mon, 21 May 2018 05:13:39 -0700 (PDT) X-Google-Smtp-Source: AB8JxZp/ri3JrVI0YKX40t3ZeiQwco4c/85gjShgrD0yAYnMqrwKKeApygBKTVHyRFmzpB3Mj4MM X-Received: by 2002:a65:640d:: with SMTP id a13-v6mr10635248pgv.312.1526904819203; Mon, 21 May 2018 05:13:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526904819; cv=none; d=google.com; s=arc-20160816; b=SRkaBFgjBaZMOVqzWFV8U1PVoBlvwguMRACY5MYgqwnrhsoAH2tdBDSG4b4Hign8LE Go5KdZVcXLrKQZwD+UirHO1YRKQcvlsedqdSp1w3G4fNMORbqScTnDkvNrO9mqXGmNiQ F17C6kGGH3AVcOJJRn3PEAyCg/OSaMPi0EIJidG1Ojjq5P26d/yE4HVJakmrPng4wbka tZmbUaVYk42nU4mYCD3XKdZSXTjG4vw7EKVwZhRPw+ZkTUIoviRZraCMoEOYKqnrdreh UKh/wBEg/eXKjo9owfLUJqMlB+lG0vBzCQ69YWc8IDTjzC1b5XbH2xzkuWjVvF+9riP6 me2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=Ffa5Yb+n2iP6TEB5ZHXlUjBTCnlCUeWRXhbKtbC53qw=; b=odEMcPEKmwtIlYKMC5VWCCFZ/ZHxqlLw+vVdbk30l3FtG9b37sO+3yhz97Wod06lqO lrPqq73I6y0tpUk9XlKpcXkbafE0MCvHg0iENva/FKv9iPc5paMUdRGNCMdHjPK6Oepa seVV9cAJqhO9QKSGZD2QdB0vtLlcKMvm+KXaOBYDvyyF+RrnSKvWqhTdONYUgToCQjD0 DBGwFzvmaA/2K847y7T28rroI8//84uGgw6RRwktkkaLAlW5or32jBOLbiEn6G+gUUxv l/h4IflAGCfRDJp5hidsKitcukjDZvV/CuuhVjKZouERPB5M1/5omD/q6kgiKwupPI/L eopA== 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 u23-v6si14772659plk.487.2018.05.21.05.13.24; Mon, 21 May 2018 05:13:39 -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 S1753149AbeEUMLt (ORCPT + 99 others); Mon, 21 May 2018 08:11:49 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:7719 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752994AbeEUMJY (ORCPT ); Mon, 21 May 2018 08:09:24 -0400 Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id C19B9A3120CC2; Mon, 21 May 2018 20:09:06 +0800 (CST) Received: from linux-ibm.site (10.175.102.37) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.382.0; Mon, 21 May 2018 20:09:00 +0800 From: Yisheng Xie To: CC: Yisheng Xie , David Airlie , Daniel Vetter , Arvind Yadav , Subject: [PATCH 23/33] drm: i2c: ch7006: use match_string() helper Date: Mon, 21 May 2018 19:58:00 +0800 Message-ID: <1526903890-35761-24-git-send-email-xieyisheng1@huawei.com> X-Mailer: git-send-email 1.7.12.4 In-Reply-To: <1526903890-35761-1-git-send-email-xieyisheng1@huawei.com> References: <1526903890-35761-1-git-send-email-xieyisheng1@huawei.com> 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 variant. Cc: David Airlie Cc: Yisheng Xie Cc: Daniel Vetter Cc: Arvind Yadav Cc: dri-devel@lists.freedesktop.org Signed-off-by: Yisheng Xie --- 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 544a8a2..405c7fb 100644 --- a/drivers/gpu/drm/i2c/ch7006_drv.c +++ b/drivers/gpu/drm/i2c/ch7006_drv.c @@ -464,14 +464,11 @@ 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) + priv->norm = i; + else ch7006_err(client, "Invalid TV norm setting \"%s\".\n", ch7006_tv_norm); } -- 1.7.12.4