From patchwork Fri Jun 2 20:30:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joshua Clayton X-Patchwork-Id: 9763407 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9A9ED6038E for ; Fri, 2 Jun 2017 20:32:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8CD23205A4 for ; Fri, 2 Jun 2017 20:32:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 81660283BA; Fri, 2 Jun 2017 20:32:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1E8AC212E8 for ; Fri, 2 Jun 2017 20:32:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=R+zAucJ/fvAsV9V2JtHx6iz9eSC9GuGt+q427+tQeTo=; b=JWux6KguOIWJ70vW0rjWmb/dIg eVezCTRcHnXa5xDs0H1J6TWdrXDBIuv1Rs6KWPBKmHMjQdAkDn/zcnOfxexDs4ywSwCvcmS6ehDrd Sr1pIdSBQjsF/Wkz5iTxW8ANq66nAAxsmGEP7SkH4phz+LTpSmsalzXDoe8uEG0s5UB6JiwVP6ce2 JIMXDl28MjhvPLMKU1hbnc04l+vyXVHLift5mJZm86R1VwH9GsMrm2sspnSiuiDmoEsdmVptaH9zZ WteZYd9SPKYuz+pWDt62bzlUrbKPk8UW5RYObFP7eGbLZHCdwpmYUULW1sDaG5ASx9Ypvm5tmsDy7 G3sjRU7w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dGtF3-0000Dz-LU; Fri, 02 Jun 2017 20:32:17 +0000 Received: from mail-pg0-x242.google.com ([2607:f8b0:400e:c05::242]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dGtEW-0007bi-Eg for linux-arm-kernel@lists.infradead.org; Fri, 02 Jun 2017 20:31:51 +0000 Received: by mail-pg0-x242.google.com with SMTP id h64so2834198pge.3 for ; Fri, 02 Jun 2017 13:31:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=eiwaXMHDe28AIDe8O6m1YguZ9DsjmcGEmLs8XlV+zrU=; b=aIaoBf8ZskkP6N+/8xEUTq54G/BGQ2Vlxp60yVAa3j7AFtdISGNKJNEQW7xHrLawlP aCn0leVCooHEENcuxtcBwzgYcGbMKgbQF3zR+o2xjPYUjMOtHSwZRsAcWbv3E+bfbiwC f/T6MF/u5zCz/Q7P7FYqj0xVhD+ioKtTNNbYa6W++q9gvpHkSA6+8++MP5S4HYuD8EqK oTuJFlL/7NodVDnCrNcP4RgFISLj47T7oECGrUtxJ0SjagmUB1NSJlpTxS0nxEYhB67T GSCsW11RwTt2YFnnNiGstw+2pxVJRUhu/t75JrqF2EKOvFfSuLw0vMc62yxqXN/Fwgqy K8dQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=eiwaXMHDe28AIDe8O6m1YguZ9DsjmcGEmLs8XlV+zrU=; b=lUL9Jpy7ag8BLZk3IJZfoW7+YfLJRDYEF9aeyMcgmjJuI7W252DyRb2UIZn/PWy7tV jS0ppZ++FTC4SDICaquRXPkwNRVk26ltS4G5Quok+opljwgIpPMMHN+ZJ4tOaBr4UgzF qqCQIIC57fmwOPRG7n+V5RtKnJy/Tjaadv1E7ponNJbPjUkzzVuS6K4yKNFubLG/AQDr 7pKHjDoGLyfsnzidhl1JuJnkcSyMwGMTcNugu9RegWVyeuXbvfPC2x5oQDgjueeYNI7K oZsKYqWJlAz3H/HjNM/6juFSNv8a+kU8f82iejmKrfudgu2Z+9Jq0XsxVLBnhdg/sM93 zCmg== X-Gm-Message-State: AODbwcD5L7NDd/BNQzRUWO/skueoRuQvndD77bqNF06gfObOU6EjamZ9 iNYfi5TqKBE5uw== X-Received: by 10.99.108.193 with SMTP id h184mr8719538pgc.166.1496435483550; Fri, 02 Jun 2017 13:31:23 -0700 (PDT) Received: from localhost.localdomain (68-185-59-186.static.knwc.wa.charter.com. [68.185.59.186]) by smtp.gmail.com with ESMTPSA id c4sm6967218pfg.31.2017.06.02.13.31.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Jun 2017 13:31:22 -0700 (PDT) From: Joshua Clayton To: Alan Tull , Moritz Fischer , Anatolij Gustschin , Bastian Stender , Shawn Guo , Joshua Clayton Subject: [PATCH v12 5/6] lib: add bitrev8x4() Date: Fri, 2 Jun 2017 13:30:51 -0700 Message-Id: <7108de698ffdeaa3c61a23997bc0877120bf114e.1496434383.git.stillcompiling@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <684ea151ba9aa2c6555a299daf56552ddc11f596.1496434383.git.stillcompiling@gmail.com> References: <684ea151ba9aa2c6555a299daf56552ddc11f596.1496434383.git.stillcompiling@gmail.com> In-Reply-To: <20170525172911.11467-1-stillcompiling@gmail.com> References: <20170525172911.11467-1-stillcompiling@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170602_133145_440959_238A456F X-CRM114-Status: GOOD ( 11.58 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , devicetree@vger.kernel.org, linux-fpga@vger.kernel.org, Russell King , linux-kernel@vger.kernel.org, Rob Herring , Sascha Hauer , Fabio Estevam , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Add a function to reverse bytes within a 32 bit word. Operate on a u32 rather than individual bytes. Signed-off-by: Joshua Clayton Signed-off-by: Alan Tull --- include/linux/bitrev.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/include/linux/bitrev.h b/include/linux/bitrev.h index fb790b8449c1..b97be27e5a85 100644 --- a/include/linux/bitrev.h +++ b/include/linux/bitrev.h @@ -29,6 +29,8 @@ static inline u32 __bitrev32(u32 x) #endif /* CONFIG_HAVE_ARCH_BITREVERSE */ +#define __bitrev8x4(x) (__bitrev32(swab32(x))) + #define __constant_bitrev32(x) \ ({ \ u32 __x = x; \ @@ -50,6 +52,15 @@ static inline u32 __bitrev32(u32 x) __x; \ }) +#define __constant_bitrev8x4(x) \ +({ \ + u32 __x = x; \ + __x = ((__x & (u32)0xF0F0F0F0UL) >> 4) | ((__x & (u32)0x0F0F0F0FUL) << 4); \ + __x = ((__x & (u32)0xCCCCCCCCUL) >> 2) | ((__x & (u32)0x33333333UL) << 2); \ + __x = ((__x & (u32)0xAAAAAAAAUL) >> 1) | ((__x & (u32)0x55555555UL) << 1); \ + __x; \ +}) + #define __constant_bitrev8(x) \ ({ \ u8 __x = x; \ @@ -75,6 +86,14 @@ static inline u32 __bitrev32(u32 x) __bitrev16(__x); \ }) +#define bitrev8x4(x) \ +({ \ + u32 __x = x; \ + __builtin_constant_p(__x) ? \ + __constant_bitrev8x4(__x) : \ + __bitrev8x4(__x); \ + }) + #define bitrev8(x) \ ({ \ u8 __x = x; \