Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp912090imm; Fri, 14 Sep 2018 08:11:18 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaGScUCLfwL/odaL1y9hhkaE6gsuTIMHlvSJgjrHTExobTGRZlD3m2tVvZgK5Fstv55aag2 X-Received: by 2002:a63:8e4a:: with SMTP id k71-v6mr12343451pge.45.1536937878031; Fri, 14 Sep 2018 08:11:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536937877; cv=none; d=google.com; s=arc-20160816; b=ujFnRUibi/CX89VJvVAjs26VuFec52iGJOZrl7tJ6k/CEkjbcz4wrmPm7a/LL9pXJB 2Cra8lCRswb7bb4EpVx0OwkjUw0/KgZ7O0zMgiCL4joh8N7nATT+zfss/vmznhdHZZHg 16dRXbcMapGN7Dwg8bY6qSXUpe9zv3msf58uVUEwO91TgkUWz+2TGoty6O3E392LbG/j nzPj3yEYGRb7EQ5JOyqjTiJDEd2uW+w6JndVVhFfDvJEe1EL2/Iw9j+8T+hwk29eAkVx 78cKfbJj+PEYWy2sHM1f9bm6tldcge8fu9/5B9l1yPB7ndu/rx84tW5ISfHd7GB2n7lm 996Q== 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=1iriwkYKRC72S4nmQLsu69QA9yYqKtPNDDxsicgaWGk=; b=pp0rF5t0AH/r1cR0EUMrhTyCb145gOS69RFvBBHYOLiG/jL0yinmV37K5yepxrmwQC IMh5eKQFpqTWShT8cvLj06tkudEpXK0ZNTPDnDPxO9uoFiiFT7J1L8fJR3/xDIcwnsuS EG4KHKdKV4TpfyFZpMReo5IGks8QAN+FxKJH3A34QDgVJVvK+6Y8Kl8EZV3dYwk9aSJC hWM7PMBq6CYbO9+U1QQlvfT4KMUpYBRgrjy53vpOD42xZtT/HjgMrmuVcgj+z16GdkCW 430zTYBrRf7K9K3mO0S1hO3wihd8psJ1xmkOon41eQ5a9o5YSZisVMwvDPhVrkNh1gMN Z7xQ== 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 c126-v6si7186349pfa.130.2018.09.14.08.11.02; Fri, 14 Sep 2018 08:11:17 -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 S1728078AbeINUZf (ORCPT + 99 others); Fri, 14 Sep 2018 16:25:35 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:12139 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726902AbeINUZe (ORCPT ); Fri, 14 Sep 2018 16:25:34 -0400 Received: from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id F24A0AA3C414C; Fri, 14 Sep 2018 23:10:31 +0800 (CST) Received: from linux-ibm.site (10.175.102.37) by DGGEMS401-HUB.china.huawei.com (10.3.19.201) with Microsoft SMTP Server id 14.3.399.0; Fri, 14 Sep 2018 23:10:32 +0800 From: zhong jiang To: , CC: , , , Subject: [PATCH] drm: nouveau: use match_string() helper to simplify the code Date: Fri, 14 Sep 2018 22:58:16 +0800 Message-ID: <1536937096-31093-1-git-send-email-zhongjiang@huawei.com> X-Mailer: git-send-email 1.7.12.4 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 implementation. Signed-off-by: zhong jiang --- drivers/gpu/drm/nouveau/dispnv04/tvnv17.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/nouveau/dispnv04/tvnv17.c b/drivers/gpu/drm/nouveau/dispnv04/tvnv17.c index 6a4ca13..053d794 100644 --- a/drivers/gpu/drm/nouveau/dispnv04/tvnv17.c +++ b/drivers/gpu/drm/nouveau/dispnv04/tvnv17.c @@ -641,17 +641,13 @@ static int nv17_tv_create_resources(struct drm_encoder *encoder, struct dcb_output *dcb = nouveau_encoder(encoder)->dcb; int num_tv_norms = dcb->tvconf.has_component_output ? NUM_TV_NORMS : NUM_LD_TV_NORMS; - int i; + int index; 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) + index = match_string(nv17_tv_norm_names, num_tv_norms, nouveau_tv_norm); + if (index >= 0) + tv_enc->tv_norm = index; + else NV_WARN(drm, "Invalid TV norm setting \"%s\"\n", nouveau_tv_norm); } -- 1.7.12.4