From patchwork Sun Jul 30 08:17:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Sanpe X-Patchwork-Id: 13333363 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id DD8C8C001E0 for ; Sun, 30 Jul 2023 08:17:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 157676B0071; Sun, 30 Jul 2023 04:17:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 108A16B0072; Sun, 30 Jul 2023 04:17:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F116B6B0074; Sun, 30 Jul 2023 04:17:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id E05AC6B0071 for ; Sun, 30 Jul 2023 04:17:27 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 937D6140876 for ; Sun, 30 Jul 2023 08:17:27 +0000 (UTC) X-FDA: 81067573734.03.2AED69D Received: from mail-pf1-f195.google.com (mail-pf1-f195.google.com [209.85.210.195]) by imf30.hostedemail.com (Postfix) with ESMTP id CE7DD80017 for ; Sun, 30 Jul 2023 08:17:25 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=HMCIOPvH; spf=pass (imf30.hostedemail.com: domain of sanpeqf@gmail.com designates 209.85.210.195 as permitted sender) smtp.mailfrom=sanpeqf@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1690705045; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=IVTFeC1njEcnyTVKiMbZ60a86a9w2VC1BHkzlkf5gjo=; b=gvap/MdRNdQ8fTCvgSvs29HNqnPg5ry5IY5rkMZX/dE/fxzn2hTV4CXgxufqZ3JKH5+n0+ MHjTGaRMjz4ZcfWkF0ednwLVH/D6DkoSBW/WOw4x/FGSgCMbjoltuA6Cedwk0ixv4ZBv7S 84QGKeRBJ6pB6N7ZoVbEBHyS2mCmMfQ= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1690705045; a=rsa-sha256; cv=none; b=hAoc6NpotUyaXJZD43QKhzXx6GnygwB+LDXv4nGPdKS6OsjxBN1ZLC8UkpAlp5K4dtMezh dIsu5JZp6j8wxMN3izV98HW2OoJxyEjxu0qgvk6m7So5vY38wMZQs7ep28+DqmywVYFFEE gA6FKi4t4JDsDJp2uv6WYhs37N2y/7A= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=HMCIOPvH; spf=pass (imf30.hostedemail.com: domain of sanpeqf@gmail.com designates 209.85.210.195 as permitted sender) smtp.mailfrom=sanpeqf@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-pf1-f195.google.com with SMTP id d2e1a72fcca58-68706d67ed9so1916790b3a.2 for ; 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=IUX2H8NWi1ei1pxL32Qi+kVCiLpqmcoxjg173g5L25nFIu/eWJTnPUIoDEUyedNmwa m11sTiAY8hRpuajL97m4P+62ccJy8iQMh7GJbS694WorCbK33pBziu415wHyokRYAPKt TlkJqitsjDaWHi8iIlbP8+YKGsEyO0iD3FuRCtrn0c++p1UUbq/rMvffCJzH2VKtEh9T WW8cGP7zT1Gj9y2gf0XPJwfydtNuUd2TNc5mJnbPnaJ3kItGxB5Z0/fXzU0tuL++X1sH Un/KcnjUvsYVgSfVkLbPTnsYZmuWdNm95FEpxliZQxwCXz3fyyKlLB/fRe/7CW/FSV6Y 5wlg== X-Gm-Message-State: ABy/qLZ9cX1Lf4qm0V40qoajLQKq1cVTkXQkHf8J7+chHRKBzIyaHIy6 4/z1gN8Wxs40GnpJgYe6bhyincgXPtQnWlNA X-Google-Smtp-Source: APBJJlEMYTfIJeXisFEx+NqaYFPOGVHM/Dcm7lZiaoSTIMUA0SpIPe5w3NqQE1wosVJZcKYveWjOWw== 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 X-Rspamd-Queue-Id: CE7DD80017 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: f79uifxd1ryruzd6mems3441jcxhcg91 X-HE-Tag: 1690705045-543626 X-HE-Meta: U2FsdGVkX1+nzQG7AyVQFDXuLG7CpnpSZDS/sbvleS3dVzH1fXfoOMQoSW9N/mKeiGoG40qM1GOSztdP4ujHAzID1xZoA+0n2LKHd8fyiiBMJhrcMRDs2twLiXnRNzaG9WBi7BKuI80bplzjq23hkVtAevItk5x4vewgnXEPaFV2QoOqDlah/g4y8/ZsMao+QqpsPsqXZp2AKt9c+vzu7SGCdFMJDT7cozIfuvCoSZ7CViLih+knLVYjKSJkl26IMJg5Sp+qc7vN+bVNYW7CIKEFftZZRt4bU7vUtL9WPS02JfiN1dL4Iph+rmfioheq+W85rPOn6n7OvCm4haTOptYw2T6lBB7PP9mag5FWs3O3Gjd5guxhiL/ohE1M/5wRM7jV1zLHe2XD7tEg9UjsACWLtn2JFoOpNjlHDnv9EvCDCyYlGqw31ZcBSAAxQttuA5qesaV1dp0t8tyY8b9C1HzZbnNjiT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amicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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); } /*