Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3407617imm; Mon, 4 Jun 2018 03:08:04 -0700 (PDT) X-Google-Smtp-Source: ADUXVKICC28PDSG3pvOceo+GZBuAbBCCxftfijYtwnB/ApjU+Ma/CkDdai7AHui4zRjzl7GRrxeG X-Received: by 2002:a17:902:7202:: with SMTP id ba2-v6mr13390024plb.119.1528106884770; Mon, 04 Jun 2018 03:08:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528106884; cv=none; d=google.com; s=arc-20160816; b=1CdZ63nWuTpBczd3Xhn3TLC31eS9NzJdH5eMyAQHItxqtu3KSRQbOFO4AVP43Z3ANX 5aH+gZFXM3GJEkO6KGtoKcV8v6ETFB7T2MteH1FZwCjUC78eHiuR7k95wnkyGCTSPs/w Qmr/NGnJCJhSdjXIb4mLgjTMwJoo5hB0UVfl+yY7Fd6ptJZhU0GeZ3ksFyrlBuUZGXII sxp5hHbagfDJZWBJpvmB956v854yN/PvWpURzvm7F2xASHS9NMPdQDVdMXjDZJ4vx4hr +OrzRpiCrBxtvcWalFLvqDkjgdVW+h9KChV68ubf8kWpcdC8QuhaPwpROHgmObHhn944 3hpw== 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=EmpFqRks8UYKFm5A4E81DAGXnb73GbHW2bZazxpbVLM=; b=nob9vQZdG78KdfFpIglDOMp0OGnEqYGU9c1CoHnX78LU142YElahvRv84vjJGMYahQ fo1tRxs0jIGGdvthu8FAUymFyLdyDc8H2Nu/NtBRf6n0iLNvfhn1mfR03cqaR1//c062 2NWxxDRz/RUUz09tz1JbRgOVdE2iAGKysEEg8Q3GoPEzI0nZ9mjK1qxUvFWsnNO+DuSe 4NsVmqtB50gG19YX2tK8VQDSA/zxVCDkgx3oB2h8nXP+N7z3PgGhg6PpjFQivoTY6tDy jqHf5TU00XtqUvFUoPYkcaTJ4YdudYeoTJvD0l16j+GCeyHVYDpVnKSzhL4/77MywiPG YBcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=p8W154sW; 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 q2-v6si30419517pgf.432.2018.06.04.03.07.50; Mon, 04 Jun 2018 03:08:04 -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=p8W154sW; 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 S1752606AbeFDKGs (ORCPT + 99 others); Mon, 4 Jun 2018 06:06:48 -0400 Received: from mail-qk0-f193.google.com ([209.85.220.193]:43581 "EHLO mail-qk0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752027AbeFDKGr (ORCPT ); Mon, 4 Jun 2018 06:06:47 -0400 Received: by mail-qk0-f193.google.com with SMTP id g126-v6so3506636qke.10; Mon, 04 Jun 2018 03:06:46 -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=EmpFqRks8UYKFm5A4E81DAGXnb73GbHW2bZazxpbVLM=; b=p8W154sWYKp0Kdmx5YrZQ8VI7sDBtIzCdpt7LlgVo90duc/UU5A1Di4peuQ8FW/3zt xAwJcdbybY6Q339BrVQOXFdCdJcb16Dv0UQiEYKMUTcAhEdybny3e5a8WUYK+n/m85Ns PLbRSil7BchR3ZpEVF3RGhGnsbcil2D/mZMFGCSOxcK2sdI25bL6c/wXn0+M7hcJVtXl zmlOu+w1VZaD8WjIT2nXbiXXMM52V1S++5VrAguq2wDWDvBBikevl0QPzDo9k7Hjf01g jpmK2vez7L/Um+rA3XtN8tSDlDBvuVz+crJa2thxRonJdSNrOTcryTPecScsuD3QCyPp K1FA== 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=EmpFqRks8UYKFm5A4E81DAGXnb73GbHW2bZazxpbVLM=; b=OOtRjMBD23Xb5fGFR98GDU2CtFuYQoFE3nxWMXR92mGd2Qiwic21l01DqSxK/pkrV8 eQMkz2/sEXR3fK8uaYNHR9yVBnYdsCqrWDJhZXffzN+8QJSZhrkT5qv8l9uyfjTBCtCv x4trWusXU54k4IKJc/6vl3uF3grVjq5yrV1VKTFYgGjyV56D6csXNy/tzz7nFSqrbOV6 gXqmsSvDtbDg+/4Bs/oQgeZ19TIuX317pQ9ExvnzsCXx/iKYhyfZWak/F0i+0CbN5kAR jhOmF3TCWbijjCkbtUoLsM+IpYJeGh9YwWYoul29NOwp7auJc1NxA7VryosswQ4Te+N/ WKqQ== X-Gm-Message-State: APt69E3D8kiGt+6poOV/svgsSzHzq1mkbpQCoWi08voi3glifHh8Ly4U RZeSiykbELWRcwjIzljs7ymeIknXmMf4pP/Zfw8= X-Received: by 2002:a37:1457:: with SMTP id e84-v6mr18469747qkh.3.1528106806338; Mon, 04 Jun 2018 03:06:46 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a0c:98f9:0:0:0:0:0 with HTTP; Mon, 4 Jun 2018 03:06:45 -0700 (PDT) In-Reply-To: <6fefc785-b6b7-e24f-2559-76ce70544717@huawei.com> 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> From: Andy Shevchenko Date: Mon, 4 Jun 2018 13:06:45 +0300 Message-ID: Subject: Re: [PATCH v2 21/21] sparc64: use match_string() helper To: Yisheng Xie Cc: Linux Kernel Mailing List , "David S. Miller" , Anthony Yznaga , Pavel Tatashin , sparclinux@vger.kernel.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 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 != ... -- With Best Regards, Andy Shevchenko