Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp372042imm; Tue, 5 Jun 2018 22:02:56 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKUvAG4x4iX5RC1kX3fUMSueQL0L2zahMY9s0e6Y+n6VXBelFCOEpOtL6RTxQILsNU+N88c X-Received: by 2002:a17:902:1004:: with SMTP id b4-v6mr1672934pla.82.1528261376394; Tue, 05 Jun 2018 22:02:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528261376; cv=none; d=google.com; s=arc-20160816; b=mK48HEHuRElwtlPwdRPDUL9p/F84YAtILGWhN4A2T7+4PPQp7BlrGUtp7EL1tVuhcd MoTotXrOqeiAtHP4vWjuAkrAmkUo9rAUC7FUool2qGvm1Ea/rtzobv7NKJnYm72i0G0s oSLcQEkP5A3E79bNP+yK9x4Whw9vIHvR0HKe+QALWrGIoCrup9REuTazgQMtSTzsMDMv c15gkvTQwYLPjpFGyVew5x5l1eY/lFs50Bia27J4gs9q/hvDRXm2mplRsUeecQUC/ipl D8POHrq4Hmj7rk/yxYNrYrkHKmGpAdXjaHOuuAvfgWGIDzUBJkaxrXt3r1Na9j+yyQ9w 5iMg== 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=9xwZfmH44ZJiWTS7Mb42yWBvOJhrOc66psolFD0WaTA=; b=rEQjEw1kZcQhlr3i6ZrcUs5hxYYZcugB19Kwq/+ZbtSO+aYDF5zHwE9ySutriOwMSb EC/0Mde52LzaotF8ZtEIaeAAQSgl7YDlXD0xKqQ4T5nbtzPgD3rKlm8T0ph+Qporo9Aa p0tBswNKMWYE88rbSd2XoklufTCsHuECktOIokGMxaZMcYAs68frSuxvrAVHpoDQUcOI sMYdKfrdc2/v0JqOMrJU9izVv9O/gYOAnc5SlFTPh2hLvpc3Jkp/y2iExcsbFjRdRurB B133B1iU+L1PqrMuYF9SHtglTenI5fSOB5lUcq/JqgVRd5SYOHPfWLb2ALGx17gBdtAk UkbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=MHqDAkPp; 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 v30-v6si15096098pfl.233.2018.06.05.22.02.29; Tue, 05 Jun 2018 22:02:56 -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=MHqDAkPp; 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 S1751943AbeFFFBx (ORCPT + 99 others); Wed, 6 Jun 2018 01:01:53 -0400 Received: from mail-qk0-f194.google.com ([209.85.220.194]:46994 "EHLO mail-qk0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750817AbeFFFBv (ORCPT ); Wed, 6 Jun 2018 01:01:51 -0400 Received: by mail-qk0-f194.google.com with SMTP id k86-v6so3166790qkh.13; Tue, 05 Jun 2018 22:01:51 -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=9xwZfmH44ZJiWTS7Mb42yWBvOJhrOc66psolFD0WaTA=; b=MHqDAkPp3Bbv1z/a+c74Sn0YacecZQmk3n9IKg+qa1Ch9bxBRBsYmgC1P01689WqNL hPlfE49YnNVZnOCwcFvdd1/LF1ZD81x/t7/QR0CLqr4LRcy7+rq16t6M0RIS6H8gAgu9 1rVSh33eGnGd7j7U+XE2qcM3SY4ZJu/V1pyRFXzmG2UzSVBNRq6OWE75vdCLDmboQZHs CtKWnGtzWo76OCv4/b4eYJQoea2EkA2UZqyohr2Es4rUXV738EBdvp+X+XqOBLwIgImA c2zEeIwmFuShoKmsN4YbvDkyZfocBBw05DkHD0rmvx8w/cgsMqUPxJ5cFSpkWDIiGDwx Z+HA== 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=9xwZfmH44ZJiWTS7Mb42yWBvOJhrOc66psolFD0WaTA=; b=OremEQLSSTVXRH+Corsdn0T3v/5kEudlb7UM+biwJJdTFicyExK5vjkM3Uz4pTYKOi nVmaNWAFYpoOCcZ/DdRbDQYWCihQmw462X3Bwjl14ifx8qk4AA1al8ztW9JWiCiyQPAB gnUdrLrWVpjZN0LmCtvVw1++ELijeW2BUqQ24KAORs0hLfa30NqCFrIy956wQvyxWwiO BcBCI1+CmEpiBLm+8r6tBSPN/jq2vR125mpAQS6u1mMimFOUL7QQ+ot+CC8QgxqMZd8d OwEn6EGQuxSW32mP0Njfctbh1alL8Sfyf3tLRQzMsQNS4oZNst2qjet2RvwIaqhCi2/9 hbZA== X-Gm-Message-State: APt69E2DS6MUThqMZWqxbgYwCF+P+kasdApI5W575CGitZdwuAEjs7vI UoQkF1FYU+X9qnF+oFUb57DZH51a5XkWOFQlk3A= X-Received: by 2002:a37:1416:: with SMTP id e22-v6mr729445qkh.3.1528261310833; Tue, 05 Jun 2018 22:01:50 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a0c:98f9:0:0:0:0:0 with HTTP; Tue, 5 Jun 2018 22:01:50 -0700 (PDT) In-Reply-To: <80339b72-902f-a74e-6ad2-28744c7760cb@huawei.com> References: <1527765086-19873-1-git-send-email-xieyisheng1@huawei.com> <1527765086-19873-22-git-send-email-xieyisheng1@huawei.com> <80339b72-902f-a74e-6ad2-28744c7760cb@huawei.com> From: Andy Shevchenko Date: Wed, 6 Jun 2018 08:01:50 +0300 Message-ID: Subject: Re: [PATCH v3 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, Kefeng Wang 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 Wed, Jun 6, 2018 at 5:19 AM, Yisheng Xie wrote: > match_string() returns the index of an array for a matching string, > which can be used instead of open coded variant. > Thanks for an update. My comments below. I think you need to mentioned the string literal change in the commit message. > Cc: "David S. Miller" > Cc: Anthony Yznaga > Cc: Pavel Tatashin > Cc: sparclinux@vger.kernel.org > Signed-off-by: Yisheng Xie > --- > v3: > - add string literal instead of NULL for array hwcaps to make it > can use match_string() too. - per Andy > v2 > - new add for use match_string() helper patchset. > > arch/sparc/kernel/setup_64.c | 23 +++++++++-------------- > 1 file changed, 9 insertions(+), 14 deletions(-) > > diff --git a/arch/sparc/kernel/setup_64.c b/arch/sparc/kernel/setup_64.c > index 7944b3c..4f0ec0c 100644 > --- a/arch/sparc/kernel/setup_64.c > +++ b/arch/sparc/kernel/setup_64.c > @@ -401,7 +401,7 @@ void __init start_early_boot(void) > */ > "mul32", "div32", "fsmuld", "v8plus", "popc", "vis", "vis2", > "ASIBlkInit", "fmaf", "vis3", "hpc", "random", "trans", "fjfmau", > - "ima", "cspare", "pause", "cbcond", NULL /*reserved for crypto */, > + "ima", "cspare", "pause", "cbcond", "resv" /*reserved for crypto */, > "adp", Why not to spell "crypto" explicitly and remove comment? > }; > > @@ -418,7 +418,7 @@ void cpucap_info(struct seq_file *m) > seq_puts(m, "cpucaps\t\t: "); > for (i = 0; i < ARRAY_SIZE(hwcaps); i++) { > unsigned long bit = 1UL << i; > - if (hwcaps[i] && (caps & bit)) { > + if (bit != HWCAP_SPARC_CRYPTO && (caps & bit)) { I would rather swap the order of subsonditions to check if caps has a bit first, and then exclude CRYPTO. > seq_printf(m, "%s%s", > printed ? "," : "", hwcaps[i]); > printed++; > @@ -472,7 +472,7 @@ static void __init report_hwcaps(unsigned long caps) > > for (i = 0; i < ARRAY_SIZE(hwcaps); i++) { > unsigned long bit = 1UL << i; > - if (hwcaps[i] && (caps & bit)) > + if (bit != HWCAP_SPARC_CRYPTO && (caps & bit)) > report_one_hwcap(&printed, hwcaps[i]); Ditto. > } > if (caps & HWCAP_SPARC_CRYPTO) > @@ -504,18 +504,13 @@ static unsigned long __init mdesc_cpu_hwcap_list(void) > while (len) { > int i, plen; > > - for (i = 0; i < ARRAY_SIZE(hwcaps); i++) { > - unsigned long bit = 1UL << i; > + i = match_string(hwcaps, ARRAY_SIZE(hwcaps), prop); > + if (i >= 0) > + caps |= (1UL << i); Parens are redundant (and actually didn't present in the original code above). > > - if (hwcaps[i] && !strcmp(prop, hwcaps[i])) { > - caps |= bit; > - break; > - } > - } > - 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 > > > -- With Best Regards, Andy Shevchenko