Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp20998548ybl; Sun, 5 Jan 2020 17:07:55 -0800 (PST) X-Google-Smtp-Source: APXvYqzW7T8IZW8JwqnOeGwYsiB+95pRTG2dY9TGCMkmtMdfmKhf4XnEOmP8rL+VZ1AIioPWKOhA X-Received: by 2002:a9d:3a66:: with SMTP id j93mr110626063otc.25.1578272875572; Sun, 05 Jan 2020 17:07:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578272875; cv=none; d=google.com; s=arc-20160816; b=jsdBmBu4DTe/bgxdS8azHVExlgRPrRJ5YRhDeIm38o3FsP7BkEge6fgFpqD+ClXReo 5qpjGpfU5/hiTqJfnWe5AUh36hdkzBjZroRpuVVLGZrrR9+1TR34LdJgUMwGvBE3qqjy qtRZd0jCofV87leIQnB6mRxxnI5sgxxx2L5NvYXMFRmks2EfJtFVbLKy+f08ed19pIXV cLsc42NJOvNT4yIQBnVbac8cFTO54cgvu+Af9vnyaCeA2Cr1ULMSo86GZ8lENgZkWKN1 K+lgQCLHYHRk5skp9YS0TaXjVllVLpVQ20WT6cUKa9qnyPoY8iWE8p6pdakt+NbClUYa 8S0g== 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 :in-reply-to:references:mime-version:dkim-signature; bh=oD/TmYE7Rc3ZEG5cPZO14SpBA53dODt6EQBgZE8gYPI=; b=AQdzqpVNEsLY3DA8BGZn0REueEHgLl/gxj0Z/MFvjBnsXPzUF8h1UEcaVKYZS+iacr xiTaevPvmf7G7X6PeQPG0itADCtmxuyuSRsI8OIzmNwddfV6DXDOwnXlQu5GwQDiUDka RGznw7gMpyoNAxVKYf22vZ1edwSCwyiMnCKkg8DozLDScwlZd0D1A463dJWVtfPEpP0M TVzxD2NewREzqcN/ZIU2HM372j/C3Si7Gkzkt+sNTpVUKaE7+KHlSpuuBs1ajEnRGsiT RRsuEzA8u/ZV9NZSuuAo7Unpv+VeeZlZJVpcEg4RB4EokqRLDzk7+/537k/XumcMEQ+t OHUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=PEmo0PFq; 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 n139si33275635oig.121.2020.01.05.17.07.43; Sun, 05 Jan 2020 17:07:55 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=PEmo0PFq; 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 S1727389AbgAFBGS (ORCPT + 99 others); Sun, 5 Jan 2020 20:06:18 -0500 Received: from mail-ua1-f65.google.com ([209.85.222.65]:35567 "EHLO mail-ua1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727223AbgAFBGR (ORCPT ); Sun, 5 Jan 2020 20:06:17 -0500 Received: by mail-ua1-f65.google.com with SMTP id y23so16537759ual.2 for ; Sun, 05 Jan 2020 17:06:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=oD/TmYE7Rc3ZEG5cPZO14SpBA53dODt6EQBgZE8gYPI=; b=PEmo0PFq7DKBYxBtymV7LxJFLP5A+tQ61Dr0ltLhlVBdB2gwEN7SUZkn6EobnWvRem OOY+ffQNhh4/RyrTB7CjApYSGy04OicYqOgN/yxu270OCR+8vLKP3227IoaoKuTGEKNu 9mzyotU7JeOQnzPwz/GVM78jUm8dSUOobw4X68g2pB4VcfT58ih1EbnaFfXHDuONOBLt zkcRL44LM3kClp35/K3eqEzB7Tj18SjIJxG0L66oSkyefi5kpoM4BRRt3Q/v9IoM8y/p Ezv/Odb3x3dSfYxliNTUjm+idMNtR37QhXGI9QJJ+qIvJc/pXupjc7rIhOdXerPBXK4U Q5Mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=oD/TmYE7Rc3ZEG5cPZO14SpBA53dODt6EQBgZE8gYPI=; b=Fv/dZzN1lgOBUgC/HY/c+f4bFKyV0UPp9shngkhhMxVNWlWiKeG1ceuKxCO4qZfGJn rjvDC5YpZb82MN0DquHDVPMEvDMoSRAgcysND/qmpnv7zCzcMf2BMnIAahk9tVvzZ1RE Wxu39OEDPHGSXOciPnrsQezD1nQCGMkac24uWHjGxbScv9TPPV9GIC+dIy3z7FI8V5Ip mGk5YzwgHuwUXdQIrovWo5qiZhaby93xRhopPEcff02AW0AeQgmy4y6kd/GbJoBMnrRt hBgqUq2VtblRCBSAtzTa9kHc6V8RzvM/xusBxMQB8trT3GIF8ya0jreBWR21OX3lel4Q fkRA== X-Gm-Message-State: APjAAAV9mjV62lLJEyooJzhyvSqJdPDljhJN5vBVqMXiu2bT4RcauVPs WfKCgvYNYvEdMk1UDFY7Uyr0lyXjLUr0TzN8OU4= X-Received: by 2002:ab0:6029:: with SMTP id n9mr57299619ual.35.1578272776664; Sun, 05 Jan 2020 17:06:16 -0800 (PST) MIME-Version: 1.0 References: <20191230024628.11820-1-yuehaibing@huawei.com> In-Reply-To: <20191230024628.11820-1-yuehaibing@huawei.com> From: Ben Skeggs Date: Mon, 6 Jan 2020 11:06:05 +1000 Message-ID: Subject: Re: [Nouveau] [PATCH -next] drm/nouveau/nv04: Use match_string() helper to simplify the code To: YueHaibing Cc: Ben Skeggs , Dave Airlie , Daniel Vetter , Sam Ravnborg , Alex Deucher , Jani Nikula , Harry Wentland , ML nouveau , LKML , ML dri-devel 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 Mon, 30 Dec 2019 at 12:48, YueHaibing wrote: > > match_string() returns the array index of a matching string. > Use it instead of the open-coded implementation. > > Signed-off-by: YueHaibing Thanks! > --- > 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 > > > _______________________________________________ > Nouveau mailing list > Nouveau@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/nouveau