Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp494291imm; Thu, 31 May 2018 04:27:19 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJ3Bp3LxPW12fU65bonrx1Wybd8Fi82tZZxyLwBik4Z3s082rbD9YueeTIY4YxpLqnFgvVG X-Received: by 2002:a63:4383:: with SMTP id q125-v6mr5346339pga.412.1527766039737; Thu, 31 May 2018 04:27:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527766039; cv=none; d=google.com; s=arc-20160816; b=Na9eXpraK6hCVxPtGWVlFz6mIo54sm/VBqLI4bqwf4DH6GVkBh6D0ZdBrSPJ3KNEpp kHrDZ/GoYJZFvgtPzkElqVaHsQxNfsZZ7JTF8KANetNkp5zFDmu4mkvVo+NOSfMXmE9X nNSFIL0a/ptIZjAl58OZqYwLDYoYKDScFTsX6p64i3EmBQnthFiZ8LeSGLb4ooseUFfn DVH6H7MV03zvOWguOhAh7QFHOgP5zj7Paqap0AT6DvYFI4o2Q8r8JXqBsgn+CP3b3o9b sUaBJxKjs28fKdtKO2w2daYqSqnI3BlJBGxpfJNJbQVG1RDOIGtNj0KdWkybbiR7PoNg LHmQ== 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=wyM4kn+lMzu9MWecASYcnloLA5zoO+hdge4V8Yy/Hx0=; b=PM6mnqMJpVaVSKqpwojVI1hypfOA9o5ZSE/n0+biutt/enmXQAnfLe3pNsaq2DuwPq WIKeMg0AbwW+Ft/e2wadfVS+yP8UxW5LLMhODqzkVJwy/D8l8/IJ4wK058Msc4XeUbDi yYn40vjbB7qr1EvPgTD9mihItvF4mWq5Gmxdol36hQDkPRA+wKKsYKAy+iDC90P21pjA 6ru7aUqy3Z8SJBE4qI0RGcP9aT23gFKM3K/+89NolsFvhNXwXoidB+illPq9SHq8rkW9 rpp6V2La9yQGNMbzCBxaG+r/endyLQ0aQutWkLCvdqZjO8dapOw81w4FrHLpn7Up6Oa+ wCeA== 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 33-v6si37706947plu.385.2018.05.31.04.27.05; Thu, 31 May 2018 04:27:19 -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 S1755134AbeEaLZU (ORCPT + 99 others); Thu, 31 May 2018 07:25:20 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:8231 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754764AbeEaLWn (ORCPT ); Thu, 31 May 2018 07:22:43 -0400 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id D594439794AD7; Thu, 31 May 2018 19:22:29 +0800 (CST) Received: from linux-ibm.site (10.175.102.37) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.382.0; Thu, 31 May 2018 19:22:24 +0800 From: Yisheng Xie To: CC: , Yisheng Xie , "David Airlie" , Daniel Vetter , "Arvind Yadav" , Subject: [PATCH v2 12/21] drm: i2c: ch7006: use match_string() helper Date: Thu, 31 May 2018 19:11:17 +0800 Message-ID: <1527765086-19873-13-git-send-email-xieyisheng1@huawei.com> X-Mailer: git-send-email 1.7.12.4 In-Reply-To: <1527765086-19873-1-git-send-email-xieyisheng1@huawei.com> References: <1527765086-19873-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 instead 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 --- v2: - handle err case before normal case. 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..9eefdfe 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) -- 1.7.12.4