Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp3184397rwb; Sun, 30 Jul 2023 02:01:17 -0700 (PDT) X-Google-Smtp-Source: APBJJlEzhWCEiQ0mb9VIR3T4Q8UMr/y0a05rr/DwQfJ9ddLJheaWbeKP4V3AD4WC0h7MpsHOwAZ5 X-Received: by 2002:a05:6402:3494:b0:522:b9ae:db3c with SMTP id v20-20020a056402349400b00522b9aedb3cmr2610297edc.6.1690707676740; Sun, 30 Jul 2023 02:01:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690707676; cv=none; d=google.com; s=arc-20160816; b=WYgrr40ASecAJ3d0JOY0udmXFwPnOGmAWdnBzOPYXfIwS2h1bGF/fBmav5NIlQ+DOJ PddOEAXtj0hwDxxyBJzpz1h2E/+i5GPBzAG5U9QmMsDIB9Nw9SipRcdr+l0jf5PKZbXi NEJTIMWwDBBaanPQn3UAYHGVfjR3Bp2RIpeUFYJH8RbhObEw0Mp19RSkZ6hKujh28qdw DRXWJJQssV0MzObUdxD41D9IEgm+ruaComOmgYSls8/Sm7xYqJfM82DqpFBKtkNoO6uf eOnMLFhpnEr2el94mRsTWJc04syQ6htCDj5wcBcpQ2arexMwa+wdmC1ifTxo2FvBGjdb CFVw== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=IVTFeC1njEcnyTVKiMbZ60a86a9w2VC1BHkzlkf5gjo=; fh=yJbiehwDnmEwsxQVWE9ZgQJU9D2vjbXJpdItl6TNbwo=; b=q0ntLzuhZXfH4/o1g0p+qz0j6psnXin7DsOQ4sb62+0MDl88uQoNNC73FleSS6vrjN te5flAswpBrqS3ltmF2lLRF0LVN5jJNMP8W5mIw900pu1HkSuvOfkY9wVBTuiFyKSJBU UqyKhc9Gywc2layHG3m7Fi33aVAkVcrnXLzbCYCRfkZzj+EYEQlFn6cNeHcs3YoR/oLL tfFq+5enIQ5TQtfF5zkwv+e4KKcKg9j2vH0xEtyXD2yU38MV82ySODiZlwL7VYKzacky BB/6XCeRPUNTco718HIElx4mYkchQ8kyftZOdAoB3sxrbln3zw15s8BQrNLjJyeXuzN4 VEbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=HMCIOPvH; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d5-20020a50fb05000000b00522215d85c5si5080181edq.282.2023.07.30.02.00.41; Sun, 30 Jul 2023 02:01:16 -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=@gmail.com header.s=20221208 header.b=HMCIOPvH; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229544AbjG3IR1 (ORCPT + 99 others); Sun, 30 Jul 2023 04:17:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229477AbjG3IR0 (ORCPT ); Sun, 30 Jul 2023 04:17:26 -0400 Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0FA37E45; Sun, 30 Jul 2023 01:17:25 -0700 (PDT) Received: by mail-pf1-x442.google.com with SMTP id d2e1a72fcca58-686f25d045cso2291315b3a.0; Sun, 30 Jul 2023 01:17:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690705044; x=1691309844; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=IVTFeC1njEcnyTVKiMbZ60a86a9w2VC1BHkzlkf5gjo=; b=HMCIOPvHnssLR6F4I7f40pNoiKpq2e36YsJlgIGfTAsEgxo6C5+1PzBh7Cq9y+XJD6 yoxymwOaIVSzVm3YP131hIvtFXtP34BBiGfFq0h9VevFg+Ygtiw1HIbZs0Ah/z2XcqV/ q1pIfqwpcG/n8Hfj8kVXjuLGBl5FMPoSGQeY6qYK1ESdS/VmTi+uPMQvJ5/59+4NYz9a om+nUNvbdGd+QBaXVcyTy9f1oB0RE9rBn1W3Cqk62eYQpZAU83ucJniRq8iV44JjGEvx TsYCZlQWUBCTz0IgBPnyyCy0q3JolWnYzqYcRA+kg0HcAMRNog5/OkPaIFefz9BPv7Yc QvTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690705044; x=1691309844; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=IVTFeC1njEcnyTVKiMbZ60a86a9w2VC1BHkzlkf5gjo=; b=AX6xuEmKrtzyRrZ/AtU5C4t8EfgI/ZnXqFyhzxGGPjwkHv22eBPF3ha4tiX+Bf/94z 37MYHFOjNOmkqYIGiQK8mgYcPpHH5nfiCgn4zVv2IGdoUEj0ZXxFcHb/MT8ShzBNqKYQ HxVqCY6bxSKzm5TIpFXMkYzmv+/UfbzCOEAFmzRqIO5YUs7xg6u0X3eEc+WWCp/aYheA lJdbguONTiQtfOwJ4LFBmGMHAnPeS0SFDY7AaMZ1YK4Vsc0VOAeqvjR13poLWpHbxBwk 4rKVAkY9PoZzuR+wUceT29r9LUic240Bb4prGH19rk1eTv71/i4SUk+YY9ybsju+A5P0 DqJQ== X-Gm-Message-State: ABy/qLaThOsIWb8+a9SZwzgHNDzYUUF2rnCEpd8q6PTia/4uEL1Xng4T GLyEUFfNrRBD0+OYcke72Ks= X-Received: by 2002:a05:6a20:ddaf:b0:131:a3b1:5674 with SMTP id kw47-20020a056a20ddaf00b00131a3b15674mr6341184pzb.22.1690705044264; Sun, 30 Jul 2023 01:17:24 -0700 (PDT) Received: from localhost ([2409:8a3c:3642:f381:ef03:9bcc:76f2:538c]) by smtp.gmail.com with ESMTPSA id i22-20020aa787d6000000b00682669dc19bsm5629437pfo.201.2023.07.30.01.17.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Jul 2023 01:17:23 -0700 (PDT) From: John Sanpe To: linux-mm@kvack.org, akpm@linux-foundation.org, rdunlap@infradead.org, torvalds@linux-foundation.org, unixbhaskar@gmail.com Cc: mm-commits@vger.kernel.org, linux-kernel@vger.kernel.org, John Sanpe Subject: [PATCH] lib/bch.c: using bitrev instead of internal logic Date: Sun, 30 Jul 2023 16:17:17 +0800 Message-ID: <20230730081717.1498217-1-sanpeqf@gmail.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,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 Replace internal logic with separate bitrev library. Signed-off-by: John Sanpe --- lib/Kconfig | 1 + lib/bch.c | 38 ++------------------------------------ 2 files changed, 3 insertions(+), 36 deletions(-) diff --git a/lib/Kconfig b/lib/Kconfig index 5c2da561c516..c686f4adc124 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -415,6 +415,7 @@ config REED_SOLOMON_DEC16 # config BCH tristate + select BITREVERSE config BCH_CONST_PARAMS bool diff --git a/lib/bch.c b/lib/bch.c index c8095f30f254..5f71fd76eca8 100644 --- a/lib/bch.c +++ b/lib/bch.c @@ -71,6 +71,7 @@ #include #include #include +#include #include #include @@ -114,47 +115,12 @@ struct gf_poly_deg1 { unsigned int c[2]; }; -static u8 swap_bits_table[] = { - 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, - 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0, - 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8, - 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8, - 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4, - 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4, - 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec, - 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc, - 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2, - 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2, - 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea, - 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa, - 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6, - 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6, - 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee, - 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe, - 0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1, - 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1, - 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9, - 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9, - 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5, - 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5, - 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed, - 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd, - 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3, - 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3, - 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb, - 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb, - 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7, - 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7, - 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef, - 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff, -}; - static u8 swap_bits(struct bch_control *bch, u8 in) { if (!bch->swap_bits) return in; - return swap_bits_table[in]; + return bitrev8(in); } /* -- 2.41.0