From patchwork Fri Jun 9 22:39:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joshua Clayton X-Patchwork-Id: 9779503 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 0621560352 for ; Fri, 9 Jun 2017 22:40:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ECD20286C4 for ; Fri, 9 Jun 2017 22:40:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E12CE286CD; Fri, 9 Jun 2017 22:40:40 +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 73E97286DB for ; Fri, 9 Jun 2017 22:40:40 +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=TGOPDQiE0kxCylC77cKf2YRohY O334/L8zRtJEdKyZniGB+BpwKjzZQjeiPEbeRuz5YZ1BB/aOBqyr03nPc0kXPcvwiRVjBlRNkQkSB lk8ItGP/vMYj1zAlbj1ECtuhcDAO1cdfssMw1LtnFmA9UC6fL99lXxhY6GyE7lBBwgIfVydX+1G34 egtEUJt8BFlENFwR5XhUZqE0gqO3cUB/ON00B4eh1v9RvwC1foLgE29IU2TtNQ9W1IShzuAZZOzWO +EixJU81XQqIxErAWXTqRq1EeAwT6m1o9Fk/K2M2QvoMEXGO4BijGrq71uKuwpcDmQ3vs8Cy2BuTQ mW74zaQw==; 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 1dJSa6-0002ED-N7; Fri, 09 Jun 2017 22:40:38 +0000 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dJSZj-0000Vw-11 for linux-arm-kernel@lists.infradead.org; Fri, 09 Jun 2017 22:40:18 +0000 Received: by mail-pf0-x244.google.com with SMTP id u26so9867178pfd.2 for ; Fri, 09 Jun 2017 15:39:59 -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=VWbguEWz66+DZi1hKcdbtXNSk/vZNiGoqT7WsdlZOf1xHPPOKnNoJ1Hhg42nOb+n+1 N4zn83kilON76jdUIdWvsDuGZnppJrK07s6NBxImpfJmng8Gf4n7cUT8LD/vkyhcA/xB dCsBl/DXbpjUWTOKI4LtzZ5V4zi+jlOtuDcPQOGLcSURWSjM9+1dA/irrfynu5ZiMgVG sK8s+q69jV+K0GI8ZkCYPyRR7GOlCgEgRnEGD2+B7+fuZyYALg8gucZEMiOhLOlMgnb1 izs1+s4SQkuqyinv4RbM1kmTj54ucFR0eWeCBaqK8v7wH+Jgv/8yzoXBX8tA8RlTY5KD PjNA== 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=bwTXI16VHW83og2Nw6SK1ytes1EDhOG+sq4XrNfOL227YMmHGhzjjkJ4EhJAM9eWF6 sy1Lr0MRXhFhwuxG8aqhEbElu983XQDJSCz1dGp4g2nIJZY1QQMEj9DC/zN9JnJdJVW/ ts0BjegZtyErH5RxURXTvA2m7DMErqW/DeebJZ4XY4gUzdoRPPCBdYmonrvqvQvbaMFV bLHOmDVf95BIP0l931a6b608NYKSqwVMai/k+d6RZRxlUB2MK23YDLdvtEdw4n5kGHmS lSvIDTqDmide23pztLsuE5Ev0kkvJtOUklfhGdm8Pnf90Wa2ntK1MeApayXFu3xWQRgU ejoQ== X-Gm-Message-State: AODbwcAzCgHc8d/1LlbtAwJRuF/W4vjk5GumZJ3Grw8x11M1YXi7Fx3X xuSYISVaBgsVAQ== X-Received: by 10.98.88.196 with SMTP id m187mr29231254pfb.87.1497047998712; Fri, 09 Jun 2017 15:39:58 -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 s4sm4771804pgr.10.2017.06.09.15.39.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Jun 2017 15:39:57 -0700 (PDT) From: Joshua Clayton To: Alan Tull , Moritz Fischer , Anatolij Gustschin , Bastian Stender , Shawn Guo , Joshua Clayton Subject: [PATCH v13 5/6] lib: add bitrev8x4() Date: Fri, 9 Jun 2017 15:39:38 -0700 Message-Id: <74028f801ba1d69e44b21d0f6d3d6ea8352fde4a.1497047816.git.stillcompiling@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <03e591707dc72f4c2b5e63a1272060956294ea51.1497047816.git.stillcompiling@gmail.com> References: <03e591707dc72f4c2b5e63a1272060956294ea51.1497047816.git.stillcompiling@gmail.com> In-Reply-To: <03e591707dc72f4c2b5e63a1272060956294ea51.1497047816.git.stillcompiling@gmail.com> References: <03e591707dc72f4c2b5e63a1272060956294ea51.1497047816.git.stillcompiling@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170609_154015_150627_C9F83F92 X-CRM114-Status: GOOD ( 11.38 ) 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 --- 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; \