From patchwork Fri Jun 9 22:39:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joshua Clayton X-Patchwork-Id: 9779525 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 2CD756034B for ; Fri, 9 Jun 2017 22:52:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1DD3B2863A for ; Fri, 9 Jun 2017 22:52:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 12606286CD; Fri, 9 Jun 2017 22:52:57 +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 C8B4F2863A for ; Fri, 9 Jun 2017 22:52:56 +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=HLrlXKXSIew+dkPb2QFyHjhB5W x5DNuVh+PQNhanRm2QpxVsvNsmPtF7cy5aTIhcDG6OyQkLVXU81hOKRSBBpPRIvSusDvktCnyDD20 yx2o466JLjeAwBYpDGTkHXNvfc8TPkMzBITvmRoYXJMj71UWsUjTyCBUIfwjOsY4OWRQ84fnxvkQL RVp5KA9V4rSRw6UnnoMvDNBe8n6e+nzMyj1Zoxlu+rNzRir6TdZaurwVitZv+v/GnKWvYXn4Ew4MU vPAjFsUvkcm4G4tOoHqjY42/8lk2xf26EcCQ/WBigx1A3U7BAx3/pmoiUhVOitd1SHfiTUbR/Oo7J /2cIpwWA==; 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 1dJSlv-0007f1-A2; Fri, 09 Jun 2017 22:52:51 +0000 Received: from mail-pg0-x243.google.com ([2607:f8b0:400e:c05::243]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dJSZl-0000W5-Eg for linux-arm-kernel@lists.infradead.org; Fri, 09 Jun 2017 22:40:22 +0000 Received: by mail-pg0-x243.google.com with SMTP id v14so8807034pgn.1 for ; Fri, 09 Jun 2017 15:40:01 -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=JubjCMEoTEWbr79H0DF20/YwNaPlL3KACRx6p9m6O8wPJTm+rrrgj+WZaE6CscHfFo fuow65WWGzZAgA2ncDgZ6zypKmzczQwx6rxssVlvfJ/otkczZsfOzBvLLwnxz94cCNR2 buz1jdjULSv5snR+vmpJjFY4m8vC3hi/ZWDJQOTpHZ5r+FkuLuXBccRVdCxRVBIME0y9 bCV075nALwXvtBQgyzrm/zXdjTmLSuVIdBQl3qa8W7V9vvMLq/GB6WSxOcKWcPr78d2V kJUQIjz9obolB8UGhxVTWha1QxYNswbDr0s4A6hzKiOQfbHQ4F2kTeuboafG+vQcSHLa di9Q== 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=ijs4I7UjDNZQ08Z55bwoYAT65uWJjttWIrI8HpulppV5CkwYoGo1KQ0H/y8zA3fN0j 2tlb5VUjkYsmM8Hu2MMXk/I3Afu1v3AGTmf9IQaUkbo3t/wkfPUSrc3ACqZYe9z9BYGg yDICVpB6ISp1iI/EtJjRHyc6RmZ1rZU0aoowankmf2IeY9IFSHN9tENC4XP+UQED6a6p 8fHzPnhffzkivhrcBcPMzc9Hy3RCYCVhwkUnZl++oaFBmMmnxU3xgImoZEqp2I9vlulF x53dljQ/+R5maBXqT9Nz5moL03uFcQdu0xIO6lYJmht30T3+vH8zVti818/cwywu2QHE 2PMA== X-Gm-Message-State: AODbwcCp0QNE+MW7BRVJJTxwsAcxzdeLB2zOWDc5Z6T1UDXH0Br7Jrpq XkpAG2NDEdY2VQ== X-Received: by 10.98.204.71 with SMTP id a68mr14831408pfg.59.1497048000806; Fri, 09 Jun 2017 15:40:00 -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.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Jun 2017 15:39:59 -0700 (PDT) From: Joshua Clayton To: Alan Tull , Moritz Fischer , Anatolij Gustschin , Bastian Stender , Shawn Guo , Joshua Clayton Subject: [PATCH v13 6/6] fpga-manager: altera-ps-spi: use bitrev8x4 Date: Fri, 9 Jun 2017 15:39:39 -0700 Message-Id: <133de0a3543747b6784c50ffe7d78e76639f1167.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_154017_663987_612A291A X-CRM114-Status: GOOD ( 12.30 ) 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 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--; + } } }