Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp905207imm; Tue, 5 Jun 2018 06:22:25 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJ7WPwAOd0Jmi1jDPUBYfR0mEqibCkcCoMYIvr3dRk0qdQM3sbGjOA8qdIEkzArnMTUx0Of X-Received: by 2002:a63:a344:: with SMTP id v4-v6mr21235886pgn.442.1528204945878; Tue, 05 Jun 2018 06:22:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528204945; cv=none; d=google.com; s=arc-20160816; b=uTDOmJqOOCkNC3KGCs75ytALHPz1VooiwGrAVLus6m368U5s1EaHKxofH1wqmAHOdH 1v2NVF25BoDZOIqccDzDOQ5hTeC08a+scsZaHx/ePpCLuGH5IY41ddAPeJF9Z61XUhlB XE0KD8NbqItjHawUpPtsQFXUqqivB1cgkg0YSqUgy9Ec6eXkSOovUkfbaBUTH5vhTP/e 8K+CA+n/aXaZjvxcthjbzrPWKUaZRVjUYkSWi9tzwp0LIq4Ten14OrZfIrVzg4Qw5h24 xEjMbJyQBwYLgqbslE/EkrwD5T64IaEbWKxwomYHvGhSoUpfURx/3GfrO/Jlhw9U+vRE hX6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=IY0W9p9fxxPjWWNzA36Zh+VDlUjugwtjnE7lSfGxg0w=; b=UWNxyvHunZY+QJgeag+JQZikIu7ZtDZ+hzbKH6B1ZVlK10eTCM1IAtfoZ8fd9KqWQT zI2j8SXn1ypRvAUizmcLlHmFUkjc8yNGBFgbTgcFz4x2yea8RQV2ucdJMhWceTiD56fX HFkdKLZtJLs2K2xz7AGLx5V7a73VA3iDnX3v8GIdEKFqac+86t5kue+EZuowCbb4H6V3 WvXU8yBt9a/UhWoQ3OW79slTI88hZoJbCX4kZ5DKJEyEve2KYKrkj2Vcaj06CgLlTMIH w4prBiCfctzN1SotT2ZE180oWFW4bEjOnx6xCirKjAHnQR8gDob2dIH5NPe4bSHD3nTD l4XA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=YhSlLd59; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q7-v6si6236700pll.445.2018.06.05.06.22.11; Tue, 05 Jun 2018 06:22:25 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=YhSlLd59; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751919AbeFENU1 (ORCPT + 99 others); Tue, 5 Jun 2018 09:20:27 -0400 Received: from mail-qt0-f195.google.com ([209.85.216.195]:45519 "EHLO mail-qt0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751775AbeFENU0 (ORCPT ); Tue, 5 Jun 2018 09:20:26 -0400 Received: by mail-qt0-f195.google.com with SMTP id i18-v6so2286474qtp.12 for ; Tue, 05 Jun 2018 06:20:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=IY0W9p9fxxPjWWNzA36Zh+VDlUjugwtjnE7lSfGxg0w=; b=YhSlLd59NmFgzA3bLIKJzp6mo4D9CTYhmW/LJu0TRRMi5l37tf38LdYK1kKjSaD3GI XrxE1Sojx3dOsJALb2nuiyo+2ViY7oeA+IPezoSxdwLQuWSCOQRTEkV6lTAwKN02qJdq PBCbGjU0XRexw+WiNYg2JUcq6pgbyasGMg4hUSos2P1n19AQbmLMKpOc8DK6pcy+KAAE U55wMYmSD+KBmjPM8MBf0U+ayQGTk/lZ7UBjYCPFeLlgcaLuvc0PoYauUy1V5zSm5np+ H8hv5Fi7GjDjiTdiOSviYaEEpQh1IaGgj9luMh1iKGgHjlIBmHhG7P4Y65RcjCygrEls G/CQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=IY0W9p9fxxPjWWNzA36Zh+VDlUjugwtjnE7lSfGxg0w=; b=njm8WD+GGHVQceI9nLFhK6VaWwl+PRdaE77frWezYEEceOeL1qmdK7qapJzeoJTkSz VwG/gQQw338vwWiQUE+TJqx34VOLNQqffXUKudWtYRXFI1sAgDED6SKj70Bb42jg4TU6 xACiLohZ7oJV3DsYsXzKD/yHnIegFsf+0merq6ybR6Iy6JeMJcw/TFfqVt16I4eU7C+U ORhtqy+S+Pa3cyidcNLjUy6+049igIXU42EkF+NR0LUeFSyZxDzLUPmQxmV6JsURHJg/ c/M+wqbbvzJTjee/KGBsZmBnWxqtjYPFdnlyMQANPNtkSSt2Zb7f55Q9v7RQIo3HLpP0 5ZVg== X-Gm-Message-State: APt69E101N5tAfd5RwgnH1lVkMB1u+pK8YFRLEwmjcwaA0xSzW6mIqJ4 yRobrjCIMoGn+1wLuki02CGhglXB3/y2doCF9PU= X-Received: by 2002:a0c:ae2f:: with SMTP id y44-v6mr23877351qvc.157.1528204825697; Tue, 05 Jun 2018 06:20:25 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a0c:98f9:0:0:0:0:0 with HTTP; Tue, 5 Jun 2018 06:20:25 -0700 (PDT) In-Reply-To: <1527765086-19873-12-git-send-email-xieyisheng1@huawei.com> References: <1527765086-19873-1-git-send-email-xieyisheng1@huawei.com> <1527765086-19873-12-git-send-email-xieyisheng1@huawei.com> From: Andy Shevchenko Date: Tue, 5 Jun 2018 16:20:25 +0300 Message-ID: Subject: Re: [PATCH v2 11/21] drm/nouveau: use match_string() helper To: Yisheng Xie Cc: Linux Kernel Mailing List , Ben Skeggs , David Airlie , dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 31, 2018 at 2:11 PM, Yisheng Xie wrote: > match_string() returns the index of an array for a matching string, > which can be used instead of open coded variant. > Reviewed-by: Andy Shevchenko > 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 > -- With Best Regards, Andy Shevchenko