From patchwork Thu May 25 17:29:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joshua Clayton X-Patchwork-Id: 9748803 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 6337760388 for ; Thu, 25 May 2017 17:31:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4B4C62223E for ; Thu, 25 May 2017 17:31:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4019926247; Thu, 25 May 2017 17:31:18 +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 E07F927968 for ; Thu, 25 May 2017 17:31:17 +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=UycPIhuEFUxhl16sAUPOgCN12RhDRVyoQgbCpmGisH4=; b=GBa8Rh2LURIFKxMFDjfe1npTx4 m3im4zxNKdLYVrtJ2KcZWFsGr09Q7fp0A+fgsGZ27JRN/oqn8+BOV7uc9mJfPM7OowjFpROV/e1dh 2Te5/FLQ4C1qol9ZnxCLKmyMmob7svUNnFMB96A2DmQ1YiEp3Y5WaUWY7N1NyOLRgJ2jey2vp50Qs c9QQNflgCTKWeCzIrGCPQi2pjK0vIB0DaeKbHxG3JfCL+MDFCgu70H6plyFHZOGZ0dpVNjC8O93EV DkfToeCL3tZqfR9HXAb9i6Ee6V1dV5vweCegv4f6jicMLiykgi5hBTwDf8vGOIGRmW92ZmhbCz571 ojsB9gww==; 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 1dDwbU-0007xR-A8; Thu, 25 May 2017 17:31:16 +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 1dDwa3-0004vk-Oj for linux-arm-kernel@lists.infradead.org; Thu, 25 May 2017 17:29:52 +0000 Received: by mail-pf0-x241.google.com with SMTP id n23so40495968pfb.3 for ; Thu, 25 May 2017 10:29:30 -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; bh=hd1gardlHNQmYkgR7WBeIWYZaaXvyvVMK4evy9ps9Wg=; b=UieDJF0SK5GzgpZ445EglVQN2wG/iwd5UZEOHEyhTiFasS3nGmyd/k4UPmeAJ1YkBZ N2XFPrS3UsaqiHOfTs5evCZ7pXDwAF3SIhrh5r256OnoSDTIHV3cpe9cVEKph1LWZJ0W qbPO5qXDWQmc5QJgVbBjD+xS5h4lNW9t8Wek9zeD8WT9W8C6TgTkL255i2R4jYSm2n9i 9xNBE6RtA2Zg8dRpnGjl8TWwNXqdOPeiaXoziNWC3Fe7DN1hxEmlpYTbYCPQgX6IJ0SB LTt3oEf8P2VIYRAAQ5eMVSArZlT9L4v9uFuc9JXo4yDXP2Bp8BeN3AqlCH0w99rEnjRK NwyQ== 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; bh=hd1gardlHNQmYkgR7WBeIWYZaaXvyvVMK4evy9ps9Wg=; b=jmb3RgsmbBriFzs1iyxnoEKnR+3yNGCIYBEH3bPBz1DFLxXNXk6rK9hemyYheGF4Jy 2rkyMfAaAi1sOWEHYjgZw+PDubJn6+zCTcL4t6prJaOYBFxKoJTxe7ryNo57OpmmqPHj U38vI2TdPax8Ww7szDb7peY2zjVvjyaY2SzbrcgypJG+wGdCfNUVQ9SmGLw1o+3CoxY3 hNtDbZk8T4M8RGIKn9l533TpBPwCD1XHQOOa1F3YDVrEZef0iTbH7buIzLtIEfK7j5H+ oJGKffwFh72Xbgx5463+e3ZyaEzGChB67bEG6axac5/aqd8eJGRbkiRB0swpP+yVCkJq t2nQ== X-Gm-Message-State: AODbwcChSxqwnTmooKXX1Ce5nB/xRiMjIeaKkVGYubz3mGZSPBE1RqHA h4hB0ZE8p8UTBw== X-Received: by 10.99.174.77 with SMTP id e13mr11351350pgp.145.1495733370430; Thu, 25 May 2017 10:29:30 -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 b72sm16579738pfj.36.2017.05.25.10.29.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 May 2017 10:29:28 -0700 (PDT) From: Joshua Clayton To: Alan Tull , Moritz Fischer , Anatolij Gustschin , Bastian Stender , Shawn Guo , Joshua Clayton Subject: [PATCH v11 6/6] fpga-manager: altera-ps-spi: use bitrev8x4 Date: Thu, 25 May 2017 10:29:11 -0700 Message-Id: <20170525172911.11467-7-stillcompiling@gmail.com> X-Mailer: git-send-email 2.11.0 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-20170525_102948_424273_19B04EA8 X-CRM114-Status: GOOD ( 12.60 ) 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 --- 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 9e90f8086cd5..baddead15476 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--; + } } }