lkml.org 
[lkml]   [2018]   [Jun]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v2 21/21] sparc64: use match_string() helper
From
Date
Hi Andy,

On 2018/6/1 19:34, Andy Shevchenko wrote:
> On Thu, May 31, 2018 at 2:11 PM, Yisheng Xie <xieyisheng1@huawei.com> 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
>>
>
>
>

\
 
 \ /
  Last update: 2018-06-04 03:08    [W:0.196 / U:0.344 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site