From patchwork Fri Jun 2 20:30:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joshua Clayton X-Patchwork-Id: 9763415 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 1718A60360 for ; Fri, 2 Jun 2017 20:36:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0981D26247 for ; Fri, 2 Jun 2017 20:36:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F2129284F8; Fri, 2 Jun 2017 20:36:36 +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 B311226247 for ; Fri, 2 Jun 2017 20:36:36 +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=aNhhoXdTVoi8ptrixDNNsStGOlpzVQnjOQbj4jl4i14=; b=a3GlN+Dv63eX4W8/yics8UId44 7PZqIRO1WdOxOe60uv8J1rjzxUDp2vXAnv89uskbIvMPDOnRZZV01wJrwpo8zLFvEZ1pPU+wOuGX5 zo9DRrjA3RR7qJpGDug2glXnxGGc+Tu/BLna61yZ0WoYzoVvQLdTSXPNwQSjbM2QtnFVBi/za9gPi Rz/wA19k/9Le0M1Y6EWusAI0aoxclCmxIZqwmwjUCASFaDCuzKSzECQTxKCzTbp8HPs7/UrVeIMyd OjBjzmLfMqqiFje2LCy7sA4wzYmy4AyakFjfJ3zpa4sSLg0m63u2CSDMku3aAt/1W6Rcvj6qNg20g LCwLvD4w==; 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 1dGtJE-0002RN-AK; Fri, 02 Jun 2017 20:36:36 +0000 Received: from mail-pf0-x241.google.com ([2607:f8b0:400e:c00::241]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dGtEX-0007c0-5O for linux-arm-kernel@lists.infradead.org; Fri, 02 Jun 2017 20:31:52 +0000 Received: by mail-pf0-x241.google.com with SMTP id f27so13707980pfe.0 for ; Fri, 02 Jun 2017 13:31:27 -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=YkASwzbCdPIx9deOx+jMTySY2xHX7Z/H8HbmAigwoAs=; b=BByHMtc8pExBIYvF990OBWpIdzxXKH61fO+opO9He/DDPxmk9795YMiMmpvb0Kg/DJ OUo6p6WNEU4LpsRl2gVh3NFmlupbtCn21+IZJuykDgdVcxqzDZfI+ahtt4pQ+7cTJEiA ITgVvyTVqKovucfdn3wuf2OStugct2Po23OPi74scBBbK5x/VkPeUANIp3qoyWWyYBK2 I4U7aM4UpX93KEsS1laoJY9duS2uI/tGT9LUg5IChhoxtq8K/zB8oztgBfw/DDcBqdob CATiBQQIuyLe5VkvDJJzQIlsjgMFJQ0T76zMrAsZgz7e+LAJkR1jmBblSqxGrOCFxWwJ qbcg== 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=YkASwzbCdPIx9deOx+jMTySY2xHX7Z/H8HbmAigwoAs=; b=E2FulCNkjEUVuwnFGTkpfR/+DJ2c4+FxD2qwcHPy1Y3EydpVHGFO9ptTPcFl4NpdVU YaVvYZlVpVDZKdYsNC3SdqenGpZWMGL4f/qi1gbuxXkiKM3km/6MYM0bJ2KO4YqS+hrP QY8GypX3nqzUxGrj+WaiuTAF/MkOYFa/N4+E8EQVs7EKTLLVslnppwMEtnxXpVogBlKW pyxL3f8eGgNUYZ1sHP1o3TY9NRYOjVVKXhBy/nPadpcyRJ90CCRwAyhJ/AUJ5J/znD5A LYmCfC8XEMI0U4KJ4CUKVpVS7lCn3eGOTJ+YcoVqXPiznuetl29/IHASa1xhf9BMtBnn 7tqg== X-Gm-Message-State: AODbwcAe9OAY3y35Bdyy6yDnEwOeNKIVmDMB4VT+Y5V1YuhBS5QIV0fs XH8TCvN1EI6TLw== X-Received: by 10.84.217.201 with SMTP id d9mr1663035plj.164.1496435487610; Fri, 02 Jun 2017 13:31:27 -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.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Jun 2017 13:31:26 -0700 (PDT) From: Joshua Clayton To: Alan Tull , Moritz Fischer , Anatolij Gustschin , Bastian Stender , Shawn Guo , Joshua Clayton Subject: [PATCH v12 6/6] fpga-manager: altera-ps-spi: use bitrev8x4 Date: Fri, 2 Jun 2017 13:30:52 -0700 Message-Id: <9486718188ff6ec3d4cb4e196b4caa33c5af48e1.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_434340_BAECE084 X-CRM114-Status: GOOD ( 12.50 ) 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 Speed up bit reversal by using hardware bit reversal Add extra code to handle less than 4byte remnants, if any Signed-off-by: Joshua Clayton Signed-off-by: Alan Tull --- drivers/fpga/altera-ps-spi.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/drivers/fpga/altera-ps-spi.c b/drivers/fpga/altera-ps-spi.c index 0db8def668ed..14f14efdf0d5 100644 --- a/drivers/fpga/altera-ps-spi.c +++ b/drivers/fpga/altera-ps-spi.c @@ -149,12 +149,23 @@ static int altera_ps_write_init(struct fpga_manager *mgr, static void rev_buf(char *buf, size_t len) { - const char *fw_end = (buf + len); + u32 *fw32 = (u32 *)buf; + size_t extra_bytes = (len & 0x03); + const u32 *fw_end = (u32 *)(buf + len - extra_bytes); /* set buffer to lsb first */ - while (buf < fw_end) { - *buf = bitrev8(*buf); - buf++; + while (fw32 < fw_end) { + *fw32 = bitrev8x4(*fw32); + fw32++; + } + + if (extra_bytes) { + buf = (char *)fw_end; + while (extra_bytes) { + *buf = bitrev8(*buf); + buf++; + extra_bytes--; + } } }