Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp229294imm; Mon, 21 May 2018 05:14:59 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpJEIhvPXH/uhfwZGpgCdmSl5UvKw691xy4ApKFzlzg+/NFQ4DOMw3aLcvwMyioQGXhjIZL X-Received: by 2002:a17:902:205:: with SMTP id 5-v6mr16464554plc.301.1526904899344; Mon, 21 May 2018 05:14:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526904899; cv=none; d=google.com; s=arc-20160816; b=e4OIiU4SPxG3x1FHhFYAfME+vlcM4msooyqjhVonIUfaCCV7kO+j4cJe4WcK2z8w3n jVPgb8KXSapWEvNt44xWk1QzuRiQIVvLqrzQN+SA9RF8r+vFARzZgFKHwadOk5q2C5do Zc0FuXAxUWehTQnVbvwaVlj2NRGZmhp/9irrizEidx4jg11Jx/GJwpGL/dWFKQpUeq3b ayMh0hxT5uSgVp5zujNg5Hu2hA2TjP3NKKYhnDNiGGqltmAXua98j3uUUKtpX3MkSFJE MELdwecuToIbYH7yCwRAoUNJ1wR7yi93+JRAh5E8Arpe3UOytnow6bc1iUY8e+5eA1Nl KaQA== 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=B9aREHNQq+vrM8WC36mlxYbG3DAU1ihp1G+okPITVDI=; b=VSUl6+6sDMk03tD8mjxlWvqgbp23TxpUD+38lJkvE5rXh1lGXZJUOsVtDSEq3szrK7 iYDFM7If0QB4MJt71+hdfpRiW5bCT8qo4V/NzjKbcbiYyan75geMAU477fuih2xtyfHj 7if5MOM04c0+oIunDkX58GOC1u7/Z/EDJ+I6rqUfB+RFO6gNqxly80PnBXdytu/OND3d 1cWxpOwf5m4243E9zhuRojC2q1jmUJi1GKqhoLrugrYHpDya3NWhgaujwDT0Dx83+1Ey YI79TiU/zenoyTzkhyS4DTQkCHol2hnacx+p4LgOy+RAI8HdgDeeXD+8hA/8VPV4YIc+ zHUg== 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 a15-v6si14541289pll.412.2018.05.21.05.14.44; Mon, 21 May 2018 05:14:59 -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 S1752542AbeEUMMs (ORCPT + 99 others); Mon, 21 May 2018 08:12:48 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:7711 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752966AbeEUMJT (ORCPT ); Mon, 21 May 2018 08:09:19 -0400 Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 51421389BE4E; 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:08:58 +0800 From: Yisheng Xie To: CC: Yisheng Xie , Ben Skeggs , David Airlie , , Subject: [PATCH 21/33] drm/nouveau: use match_string() helper Date: Mon, 21 May 2018 19:57:58 +0800 Message-ID: <1526903890-35761-22-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: Ben Skeggs Cc: David Airlie Cc: dri-devel@lists.freedesktop.org Cc: nouveau@lists.freedesktop.org Signed-off-by: Yisheng Xie --- drivers/gpu/drm/nouveau/dispnv04/tvnv17.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/nouveau/dispnv04/tvnv17.c b/drivers/gpu/drm/nouveau/dispnv04/tvnv17.c index 6d99f11..a6b4c4a 100644 --- a/drivers/gpu/drm/nouveau/dispnv04/tvnv17.c +++ b/drivers/gpu/drm/nouveau/dispnv04/tvnv17.c @@ -644,14 +644,11 @@ static int nv17_tv_create_resources(struct drm_encoder *encoder, int i; if (nouveau_tv_norm) { - for (i = 0; i < num_tv_norms; i++) { - if (!strcmp(nv17_tv_norm_names[i], nouveau_tv_norm)) { - tv_enc->tv_norm = i; - break; - } - } - - if (i == num_tv_norms) + i = match_string(nv17_tv_norm_names, + num_tv_norms, nouveau_tv_norm); + if (i >= 0) + tv_enc->tv_norm = i; + else NV_WARN(drm, "Invalid TV norm setting \"%s\"\n", nouveau_tv_norm); } -- 1.7.12.4