Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp15994082rwd; Mon, 26 Jun 2023 04:27:36 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5qUSwPho9zL/jAPcmfj0XIN5fbikMDRTCbr0McGjFvTl7Hy+YbBY+yCUUZsXGPUlEJH5Mx X-Received: by 2002:aa7:88cf:0:b0:66c:6834:c585 with SMTP id k15-20020aa788cf000000b0066c6834c585mr8649804pff.34.1687778856562; Mon, 26 Jun 2023 04:27:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687778856; cv=none; d=google.com; s=arc-20160816; b=K2HGnqb/C0nci6vTWCayCG25PcnrAdO7wVu38yolw2EJxlQdppasJV4+an9HXYJtaF phpftySJvzPqXODtejDfuGpQRdjw59n4RgdOHPzOdtJ7SOl+LXLYo9ED46Jj+XzifXl4 9iQ8EdTrJjfyeJUXG9/P/AWNCvVOuSWssbYYxDkPxROnI5wmjcmElyIpAT4Zf4JU7ixZ G+hQrO3BIU/y+hygoQG+Yhi0CgnmcKLWKw9r8/fpNvwKcWWsAOInR5pqVIrngGcvzMM+ ID3h6+8Yu5CDzHB1Kb+9AlbxDIpEaK7NvyKSrnJg1kwvm4qVEVlpt98ibYWV1I6XX88X 633g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Iu0oIKQaNCiyZc9EFyINu4/dMS547r+wcjiUlpQ391Y=; fh=id5NoWTfrmVnmm2w/Ed5X4erHGUuViLdGWw+WL1NNbc=; b=ZYsvU/WImqr3WKqYGlYszPCzHBhqdxxP6PLzaqt6DynTkUlyCFKiG+h1M8YIriTgk1 miZViTWUtRTQ4b4BCnBh4sO0cS2g8RDNDgv7LDwjtfKH6Ec0c2TW6yt99WHBN5YsnYMN GDMPiBn1eX56eC3MF+s2NmwhG6687k4gewH1vXPD1dONaRaYoo06H7RQS/n1Bz2FJihX swDS9lLZRmlJpuV9TOos8X1yWV9oRTaGfFju4PNOlgsgMSRgAjAVVISZGr/W3yb6yIkG Z0Ad+KpKa4tUe9sf5icUtx7quBqiq1aKe6fBZ8f6Pm35w2Z1Z5Tksqqq8ALsVA128Ixf gyRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=NzPJj8J5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u70-20020a627949000000b00672ad8f037esi2964960pfc.231.2023.06.26.04.27.25; Mon, 26 Jun 2023 04:27:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=NzPJj8J5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230493AbjFZLVM (ORCPT + 99 others); Mon, 26 Jun 2023 07:21:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230359AbjFZLVH (ORCPT ); Mon, 26 Jun 2023 07:21:07 -0400 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4EE9D119; Mon, 26 Jun 2023 04:20:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1687778458; x=1719314458; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=EVl3YYff+bNDCeEIAFYAaLo4NmZDjHChTG2zsWTb6SY=; b=NzPJj8J5Jw0LvTiEo8yuJmGwL7A1WtkSraZwFQUc4Mh48FZRz+DUPZJQ lfwQ0vyhZxa8vh0ON4D4MJ2lUf8+TqlPjQDvthsaFv2OMQBddxh1JTpMD 0qcwMw+4zBaf7Tl1Vg7Ab4tAgiwVOtpCa3AO32e4YUgdlN/nBk07Uht0R ryubOlQgzfyHpPdPJUflaEZJdhl2zP/mbay86a020EsJQfNjeXq8qslEu 7jPndsCAcALffzVItPzt7w77AHdEwNrzsG0KGtzMNM3FbGe3GGBygmC3v 42cUnpbyB0PO7PFJe129JpXXdiAaFqtE5qkzjAw3wlGZN+iP+bxPI/5yV w==; X-IronPort-AV: E=Sophos;i="6.01,159,1684825200"; d="scan'208";a="220501431" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa5.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 26 Jun 2023 04:20:57 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Mon, 26 Jun 2023 04:20:56 -0700 Received: from wendy.microchip.com (10.10.115.15) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server id 15.1.2507.21 via Frontend Transport; Mon, 26 Jun 2023 04:20:53 -0700 From: Conor Dooley To: CC: , , Rob Herring , Krzysztof Kozlowski , Paul Walmsley , Albert Ou , Andrew Jones , Heiko Stuebner , "Evan Green" , Sunil V L , , , Subject: [PATCH v1 4/9] RISC-V: repurpose riscv_isa_ext array in riscv_fill_hwcap() Date: Mon, 26 Jun 2023 12:19:42 +0100 Message-ID: <20230626-thieving-jockstrap-d35d20b535c5@wendy> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230626-provable-angrily-81760e8c3cc6@wendy> References: <20230626-provable-angrily-81760e8c3cc6@wendy> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3378; i=conor.dooley@microchip.com; h=from:subject:message-id; bh=EVl3YYff+bNDCeEIAFYAaLo4NmZDjHChTG2zsWTb6SY=; b=owGbwMvMwCFWscWwfUFT0iXG02pJDCkzS/xOHvARZg/f8YlLI9BKZOvsxbtEVnyNvPPa8OTs1nOC uU//dpSyMIhxMMiKKbIk3u5rkVr/x2WHc89bmDmsTCBDGLg4BWAiS6UY/hlMYgidF17//8BOu2M95s kC8543Oka+Pn0wUDbz6aT4NW0M/xNFHrouDuHn6tGzLj2UOu9zZ+2k1IrISZGVqwv9bH5u5wAA X-Developer-Key: i=conor.dooley@microchip.com; a=openpgp; fpr=F9ECA03CF54F12CD01F1655722E2C55B37CF380C Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In riscv_fill_hwcap() riscv_isa_ext array can be looped over, rather than duplicating the list of extensions with individual SET_ISA_EXT_MAP() usage. While at it, drop the statement-of-the-obvious comments from the struct, rename uprop to something more suitable for its new use & constify the members. Signed-off-by: Conor Dooley --- arch/riscv/include/asm/hwcap.h | 6 ++---- arch/riscv/kernel/cpu.c | 5 +++-- arch/riscv/kernel/cpufeature.c | 26 +++++++------------------- 3 files changed, 12 insertions(+), 25 deletions(-) diff --git a/arch/riscv/include/asm/hwcap.h b/arch/riscv/include/asm/hwcap.h index 7a57e6109aef..36f46dfd2b87 100644 --- a/arch/riscv/include/asm/hwcap.h +++ b/arch/riscv/include/asm/hwcap.h @@ -70,10 +70,8 @@ unsigned long riscv_get_elf_hwcap(void); struct riscv_isa_ext_data { - /* Name of the extension displayed to userspace via /proc/cpuinfo */ - char uprop[RISCV_ISA_EXT_NAME_LEN_MAX]; - /* The logical ISA extension ID */ - unsigned int isa_ext_id; + const unsigned int id; + const char *name; }; extern const struct riscv_isa_ext_data riscv_isa_ext[]; diff --git a/arch/riscv/kernel/cpu.c b/arch/riscv/kernel/cpu.c index 61fb92e7d524..beb8b16bbf87 100644 --- a/arch/riscv/kernel/cpu.c +++ b/arch/riscv/kernel/cpu.c @@ -164,9 +164,10 @@ static void print_isa_ext(struct seq_file *f) { for (int i = 0; i < riscv_isa_ext_count; i++) { const struct riscv_isa_ext_data *edata = &riscv_isa_ext[i]; - if (!__riscv_isa_extension_available(NULL, edata->isa_ext_id)) + if (!__riscv_isa_extension_available(NULL, edata->id)) continue; - seq_printf(f, "_%s", edata->uprop); + + seq_printf(f, "_%s", edata->name); } } diff --git a/arch/riscv/kernel/cpufeature.c b/arch/riscv/kernel/cpufeature.c index f0ae310006de..b5e23506c4f0 100644 --- a/arch/riscv/kernel/cpufeature.c +++ b/arch/riscv/kernel/cpufeature.c @@ -99,11 +99,10 @@ static bool riscv_isa_extension_check(int id) return true; } -#define __RISCV_ISA_EXT_DATA(UPROP, EXTID) \ - { \ - .uprop = #UPROP, \ - .isa_ext_id = EXTID, \ - } +#define __RISCV_ISA_EXT_DATA(_name, _id) { \ + .name = #_name, \ + .id = _id, \ +} /* * The canonical order of ISA extension names in the ISA string is defined in @@ -367,20 +366,9 @@ void __init riscv_fill_hwcap(void) set_bit(nr, isainfo->isa); } } else { - /* sorted alphabetically */ - SET_ISA_EXT_MAP("smaia", RISCV_ISA_EXT_SMAIA); - SET_ISA_EXT_MAP("ssaia", RISCV_ISA_EXT_SSAIA); - SET_ISA_EXT_MAP("sscofpmf", RISCV_ISA_EXT_SSCOFPMF); - SET_ISA_EXT_MAP("sstc", RISCV_ISA_EXT_SSTC); - SET_ISA_EXT_MAP("svinval", RISCV_ISA_EXT_SVINVAL); - SET_ISA_EXT_MAP("svnapot", RISCV_ISA_EXT_SVNAPOT); - SET_ISA_EXT_MAP("svpbmt", RISCV_ISA_EXT_SVPBMT); - SET_ISA_EXT_MAP("zba", RISCV_ISA_EXT_ZBA); - SET_ISA_EXT_MAP("zbb", RISCV_ISA_EXT_ZBB); - SET_ISA_EXT_MAP("zbs", RISCV_ISA_EXT_ZBS); - SET_ISA_EXT_MAP("zicbom", RISCV_ISA_EXT_ZICBOM); - SET_ISA_EXT_MAP("zicboz", RISCV_ISA_EXT_ZICBOZ); - SET_ISA_EXT_MAP("zihintpause", RISCV_ISA_EXT_ZIHINTPAUSE); + for (int i = 0; i < riscv_isa_ext_count; i++) + SET_ISA_EXT_MAP(riscv_isa_ext[i].name, + riscv_isa_ext[i].id); } #undef SET_ISA_EXT_MAP } -- 2.40.1