Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3039723imm; Sun, 3 Jun 2018 18:08:27 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKuy408RTrhdEWLGhNGKlrKrYDwPUR1fnkHORa0SJWUdyLV+T110YFs0V80PrhbvT4ozdYQ X-Received: by 2002:a17:902:a416:: with SMTP id p22-v6mr19617794plq.228.1528074507514; Sun, 03 Jun 2018 18:08:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528074507; cv=none; d=google.com; s=arc-20160816; b=CwC25skFm0CuMPdVwVy9DowSDlG8eA8DWnUrrDSlxCBplJ+kZriLmalHZrjNlDa+qD XkfKiN620PfQ51FCXUshv2S5g9LA0ChWfjroSAZrMnB/jESPdElodE84YUQWHApmZbLI q7s8Qt1cVhJkM0hiTqAZNyni7sAWbcNg2idDYGP29tiBdnYzLf6umARfsRtNGmN5T52V h9zx37EPE8sNp8dexeN0oVvEq+qx7CU3K8v7PwWy1XbvQAx0cgD+itAgoBd+hYYaMgQF IimAoqJ6x5yhP5X6SaANnTqP7DVbY4HoJ61LWv6BuQgnxu5G7tUN3ymQWZGQc7DgFi/c RW/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject:arc-authentication-results; bh=puh8rbD34cPgo9X7eGeyfZJGNNDNuUbD1znvaqh8D1c=; b=B2+cw6GYYHzLx9m9xoeijMkTp8LyGUhoJG3FLuBgko7q1udmlI8VT14way+1CDSiRu pUGwCM8u9OknvyDSQj9i+UGSRQIW2LcLpcehxXM9VtQCac5Q/p8dwHCTsKn48AqqkA4U Pf2JD7fT0DV5aQG90uiZMZPRCDtLYLAtThKRzrd8o7CU+ZDR38P4mY6aO+jnGC6lyMZb leLgLMRorQDCU/HiqKLKPy7/opI61HQbojpfu8BT0A5BYHNUGYbc86D4YDjRxN1Q/fVn +hYCiJRdoBQz6KEwyfkd1P5qyhOXFYpGrxUX7nG4Aai/Kw0SclG2lIzMcvj+++Gs8mp9 HGEA== 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 i33-v6si44373555pld.546.2018.06.03.18.08.12; Sun, 03 Jun 2018 18:08:27 -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 S1751838AbeFDBHr (ORCPT + 99 others); Sun, 3 Jun 2018 21:07:47 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:8629 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751603AbeFDBHp (ORCPT ); Sun, 3 Jun 2018 21:07:45 -0400 Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 99110A1D078AC; Mon, 4 Jun 2018 09:07:32 +0800 (CST) Received: from [127.0.0.1] (10.177.29.40) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.382.0; Mon, 4 Jun 2018 09:07:30 +0800 Subject: Re: [PATCH v2 21/21] sparc64: use match_string() helper To: Andy Shevchenko References: <1527765086-19873-1-git-send-email-xieyisheng1@huawei.com> <1527765086-19873-22-git-send-email-xieyisheng1@huawei.com> CC: Linux Kernel Mailing List , "David S. Miller" , Anthony Yznaga , Pavel Tatashin , From: Yisheng Xie Message-ID: <6fefc785-b6b7-e24f-2559-76ce70544717@huawei.com> Date: Mon, 4 Jun 2018 09:06:07 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.1.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.29.40] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Andy, On 2018/6/1 19:34, Andy Shevchenko wrote: > 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. > >> @@ -512,10 +512,9 @@ static unsigned long __init mdesc_cpu_hwcap_list(void) >> break; >> } >> } > > It seems previous loop also can be replaced. No, because the there is an NULL in the middle of the array hwcaps: static const char *hwcaps[] = { "flush", "stbar", "swap", "muldiv", "v9", "ultra3", "blkinit", "n2", /* These strings are as they appear in the machine description * 'hwcap-list' property for cpu nodes. */ "mul32", "div32", "fsmuld", "v8plus", "popc", "vis", "vis2", "ASIBlkInit", "fmaf", "vis3", "hpc", "random", "trans", "fjfmau", "ima", "cspare", "pause", "cbcond", NULL /*reserved for crypto */, "adp", }; Thanks Yisheng > >> - for (i = 0; i < ARRAY_SIZE(crypto_hwcaps); i++) { >> - if (!strcmp(prop, crypto_hwcaps[i])) >> - caps |= HWCAP_SPARC_CRYPTO; >> - } >> + i = match_string(crypto_hwcaps, ARRAY_SIZE(crypto_hwcaps), prop); >> + if (i >= 0) >> + caps |= HWCAP_SPARC_CRYPTO; >> >> plen = strlen(prop) + 1; >> prop += plen; >> -- >> 1.7.12.4 >> > > >