Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp652807imm; Tue, 5 Jun 2018 02:06:37 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLvxqicVoE6Sifn2GeksssrKGz5Ie+m4okSqEBdKuI2AFAK517WW+frWw/xaNRUH79UNC+3 X-Received: by 2002:a17:902:854a:: with SMTP id d10-v6mr15610680plo.106.1528189597080; Tue, 05 Jun 2018 02:06:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528189597; cv=none; d=google.com; s=arc-20160816; b=jP42erVH3kYLxiVAyFndf+jCnVaIiIlQISmecCnL0C1utIDlS3F9f9O7K8ra8TRiVL 7f7HHcmJlZCDXiSlN+C5h3Eo+Xw+aKJ55Kq0FprnBEFi8W7VEPum9pdf+f/OP34hHqDe NtrBdT7S836G0ZXXTyqx3RiZVsZkZzW5BQ1YH+rEghZdIbl0iwkfO3HlDXayYjEwvltJ gdCqk9ol7mD4nOF6xCeZ4rZ0rVOgfyOMxSSgU3U+5cELAj5STT28IkvIirX5ybW8ktIU caLHXwPWXlx9DX2nS58o76K5hl4Eoq60ZL7ZlzZkRE8SjwPYF/CwteFy195wZrrT7vT+ 9i8g== 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=XXuDaNyXJd2Hgver46+oMcmlC4EzdHqj18w672yvp4w=; b=yXQNDXXcZ/be6/LWKG50jwaPjWAEizSR5Aw/i7ntPuOxp5OcR6GaI6nZuLC2sepcyw eEhK0BJjbJqgKwzfDgUi0Ro2IJ5aj/uWVt/IRurAdfO1IZ9c31zbe6nMK7+lE3YzYfD+ NFYRPLP2I+w2hA0ZOvVILJwd3t82T/LgUdq/MG1kvWtlOfpOqKemCwIp+zBpIBNHhHbr 5VNXA2ddjUJZ+zJOQ3EPluD6znBer4+ayBTsFII16NTOcI2TqWrA9MKdDkS1ls+jZQvC F/Ht/biJjeaLEjga+yp+aQMFhmmcOxjvr5ItP63tT/PxaV8yh7x51smxRCda97i2qM9s Fp6A== 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 u32-v6si26162044pgn.488.2018.06.05.02.06.22; Tue, 05 Jun 2018 02:06:37 -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 S1751589AbeFEJF5 (ORCPT + 99 others); Tue, 5 Jun 2018 05:05:57 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:39894 "EHLO huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1751296AbeFEJF4 (ORCPT ); Tue, 5 Jun 2018 05:05:56 -0400 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 75A1638312AD1; Tue, 5 Jun 2018 17:05:52 +0800 (CST) Received: from [127.0.0.1] (10.177.29.40) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.382.0; Tue, 5 Jun 2018 17:05:50 +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> <6fefc785-b6b7-e24f-2559-76ce70544717@huawei.com> CC: Linux Kernel Mailing List , "David S. Miller" , Anthony Yznaga , Pavel Tatashin , From: Yisheng Xie Message-ID: <0eb48f06-2046-0b5e-4f16-4ebf3bd056b2@huawei.com> Date: Tue, 5 Jun 2018 17:05:27 +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/4 18:06, Andy Shevchenko wrote: > On Mon, Jun 4, 2018 at 4:06 AM, Yisheng Xie wrote: >> 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", >> }; > > Actually you can. > What you need is to add string literal instead of NULL and make an > additional condition after match_string() in all users (not to many), > something like > > i = match_string(); > if (i < 0) > ... > if (BIT(i) == HWCAP_SPARC_CRYPTO) // or != OK, I get your point. Thanks Yisheng > ... >