Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp493953imm; Thu, 31 May 2018 04:26:57 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJJcD+XsAKlDJ6IKkQSd5zMzw6Qwjju2x5LIcBSjjnROa1m+69p+94ebS4H5Ut+GD8me447 X-Received: by 2002:a17:902:566:: with SMTP id 93-v6mr6672068plf.385.1527766017305; Thu, 31 May 2018 04:26:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527766017; cv=none; d=google.com; s=arc-20160816; b=pyu0FdIC6vWxjUNL5CubidKO2PWxUqA4OOelqyYzP7z2tBB8auAw9WAR9aeFnTaNX+ tELdJNKKZkAcQumRUWp1ZR57OkcK3jp974xbm8F9CzBWphk5/lCZ4GjTqSe5bHTLia1s uMLmumaxgLYA2xn0Jfd+uLyIYu8v8AaSG/cwyZ1G9lmf+khaUAXDaIy3RqCDPijv/K2/ pUiIU39t25oUTSA08dcG3Knv+7BIYL+DyYRpqhoj7k3lCRj9giSZhNW+kVm/16NnpcN8 nePgggrgG25XU2kE5r39hrNx+Y1QcGgaChm0UMbHRokijOloo3TpPaqN5moRSEak3tC7 8I5g== 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=kUqYgW7upkyVQdAn4CD9Xidp6sO9NtFoCkmkI44yq7I=; b=bDRiM9eF85PBuvYLjzj+T4zmLamAXAQqhj3ROcgjhy22wiztg1VtfRlia8A2i5AlW0 3Nx4s70fteqOHa8vf3Z5X+MFQOI77UuFydd++H8quH29MS4BZQcSQB9v9rWR66tJ5prV vHnWsEFdTLo28amEquHo2f6pbxwhyYArxpusNyJ9Yr1biTB45hE2KQDJiioU2Fb9Hds0 uH+pEXTI7bHGT3EvGBd/FuCmQswsuWP+qXo8s6HIe4lomMfmIroU4OMEQWFduZq0KBDB UrtQ4DrH+GMTM1aQWAVkMY+KmWmCwGj1T6o7PFvlzf0Jcfkb5OQoJ0lxw0uA3z6ZsTlA w9eQ== 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 1-v6si36432685plo.20.2018.05.31.04.26.43; Thu, 31 May 2018 04:26:57 -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 S1755150AbeEaLZX (ORCPT + 99 others); Thu, 31 May 2018 07:25:23 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:8228 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754758AbeEaLWn (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 A751DC64A547A; 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:23 +0800 From: Yisheng Xie To: CC: , Yisheng Xie , "Ben Skeggs" , David Airlie , , Subject: [PATCH v2 11/21] drm/nouveau: use match_string() helper Date: Thu, 31 May 2018 19:11:16 +0800 Message-ID: <1527765086-19873-12-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: Ben Skeggs Cc: David Airlie Cc: dri-devel@lists.freedesktop.org Cc: nouveau@lists.freedesktop.org Signed-off-by: Yisheng Xie --- v2: - handle err case before normal case - per Andy 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..67ba2ac 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); -- 1.7.12.4