Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp13712933ybl; Sun, 29 Dec 2019 18:51:52 -0800 (PST) X-Google-Smtp-Source: APXvYqy1Q636aoyduPuUIkdEBqQZ3COyqBZ5le6dua9mGGSnGwOeN7/HJGQrDHnGGXfHXQfyRWxx X-Received: by 2002:a9d:7e99:: with SMTP id m25mr68990884otp.212.1577674312647; Sun, 29 Dec 2019 18:51:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577674312; cv=none; d=google.com; s=arc-20160816; b=KRdR7g+c3V2mm363X9X93siMtsz4iYlKnrq6nOKp98qIrqt8BHpoRdnQTlAGLDSwle D8IN7PATNN+5HAbtDJl4iI08Zk5Z9u4szX5lbv4P+rSF0muSCuP9kK6gssKyyJeiw7oQ vyncq/BeWKcMxRBq1l1t6FJmmRhix1s2Mgcw0lBBCd4iY9BLdi2iL9i5+i9CG4IAc10a VlZtcBLETCG4bQFRVlB5Wovnf3SqGppfkeZ/2sUr7q4ZsdAQF6bTv2iYBsBSZxXOAUBC V/mSMEHWlnduH/yAw0loU170HJ6hPjS/PUffj0eKh/fKIxbOSGM2YgEC1yNvLwOgywK6 DfFw== 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=WOqgri3NHMsQylnnPytHrKcHeKVA4k1eyQ/TT2ZbcRY=; b=fRZD+I1fr6gLW/sD0WlgV4xz4hh7O31/04WNunn13vnHgK0aTCRWL4CWZYIUAQbe1X xjC6cI2rIrhkqVCTfAKQZh076OeDhTifuj2Z+tFhuydS5Fh43gToAQ7j3Abl7FBcflqE N4i6KtYz7S1mjKJjd8nf3wQ7oz++Vw+kg8Q9caOzj2dZ98n4XORwQpt6GxsRw6/ShIZe qGghCu9AX4cZV/ZcxXth/aAPssLd8xnhKmvTTTOX8BOC+iWVxdAL5ZjsyEBgvj/TPT89 Q4WGHdSkO50vCp+wuAwdIJtSrdwylcmeN5TuQygPc5dbCuo8FBWaa9pEw5kcq8E0d8rI gnDA== 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 b9si12802240oie.20.2019.12.29.18.51.18; Sun, 29 Dec 2019 18:51:52 -0800 (PST) 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 S1727064AbfL3Cse (ORCPT + 99 others); Sun, 29 Dec 2019 21:48:34 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:8645 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727048AbfL3Cse (ORCPT ); Sun, 29 Dec 2019 21:48:34 -0500 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 2B288AE7A05B411EE62; Mon, 30 Dec 2019 10:48:31 +0800 (CST) Received: from localhost (10.133.213.239) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.439.0; Mon, 30 Dec 2019 10:48:20 +0800 From: YueHaibing To: , , , , , , , CC: , , Subject: [PATCH -next] drm/nouveau/nv04: Use match_string() helper to simplify the code Date: Mon, 30 Dec 2019 10:46:28 +0800 Message-ID: <20191230024628.11820-1-yuehaibing@huawei.com> X-Mailer: git-send-email 2.10.2.windows.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.133.213.239] 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 array index of a matching string. Use it instead of the open-coded implementation. Signed-off-by: YueHaibing --- 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 03466f0..3a9489e 100644 --- a/drivers/gpu/drm/nouveau/dispnv04/tvnv17.c +++ b/drivers/gpu/drm/nouveau/dispnv04/tvnv17.c @@ -644,16 +644,13 @@ 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) NV_WARN(drm, "Invalid TV norm setting \"%s\"\n", nouveau_tv_norm); + else + tv_enc->tv_norm = i; } drm_mode_create_tv_properties(dev, num_tv_norms, nv17_tv_norm_names); -- 2.7.4