From patchwork Fri Mar 6 16:38:05 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe Leroy X-Patchwork-Id: 5956161 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: X-Original-To: patchwork-linux-crypto@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 05AC6BF440 for ; Fri, 6 Mar 2015 16:38:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 31793202AE for ; Fri, 6 Mar 2015 16:38:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 54D1F20256 for ; Fri, 6 Mar 2015 16:38:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752723AbbCFQiI (ORCPT ); Fri, 6 Mar 2015 11:38:08 -0500 Received: from pegase1.c-s.fr ([93.17.236.30]:53972 "EHLO mailhub1.si.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754114AbbCFQiH (ORCPT ); Fri, 6 Mar 2015 11:38:07 -0500 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 1405D1C8572; Fri, 6 Mar 2015 17:38:06 +0100 (CET) X-Virus-Scanned: amavisd-new at c-s.fr Received: from mailhub1.si.c-s.fr ([192.168.12.234]) by localhost (mailhub1.c-s.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id eUJv_sFgmdvv; Fri, 6 Mar 2015 17:38:05 +0100 (CET) Received: from messagerie.si.c-s.fr (messagerie [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id EAF931C8570; Fri, 6 Mar 2015 17:38:05 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id D2811C73C8; Fri, 6 Mar 2015 17:38:05 +0100 (CET) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id w1tGpov2jGZj; Fri, 6 Mar 2015 17:38:05 +0100 (CET) Received: from PO10863.localdomain (unknown [172.25.231.75]) by messagerie.si.c-s.fr (Postfix) with ESMTP id A6172C73C4; Fri, 6 Mar 2015 17:38:05 +0100 (CET) Received: by localhost.localdomain (Postfix, from userid 0) id 865ED1A241C; Fri, 6 Mar 2015 17:38:05 +0100 (CET) From: Christophe Leroy To: Kim Phillips , Herbert Xu , "David S. Miller" CC: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-crypto@vger.kernel.org Subject: [PATCH v2 02/17] crypto: talitos - Externalise specific SEC2 reset actions Message-Id: <20150306163805.865ED1A241C@localhost.localdomain> Date: Fri, 6 Mar 2015 17:38:05 +0100 (CET) Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP During init and reset, some actions are different between SEC1 and SEC2 This patch isolates them in small helper functions that we will be able to redefine for SEC1 Signed-off-by: Christophe Leroy --- drivers/crypto/talitos.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/drivers/crypto/talitos.c b/drivers/crypto/talitos.c index 857414a..103bfcf 100644 --- a/drivers/crypto/talitos.c +++ b/drivers/crypto/talitos.c @@ -88,9 +88,8 @@ static void unmap_single_talitos_ptr(struct device *dev, be16_to_cpu(talitos_ptr->len), dir); } -static int reset_channel(struct device *dev, int ch) +static unsigned int do_reset_channel(struct talitos_private *priv, int ch) { - struct talitos_private *priv = dev_get_drvdata(dev); unsigned int timeout = TALITOS_TIMEOUT; setbits32(priv->chan[ch].reg + TALITOS_CCCR, TALITOS_CCCR_RESET); @@ -99,6 +98,14 @@ static int reset_channel(struct device *dev, int ch) && --timeout) cpu_relax(); + return timeout; +} + +static int reset_channel(struct device *dev, int ch) +{ + struct talitos_private *priv = dev_get_drvdata(dev); + unsigned int timeout = do_reset_channel(priv, ch); + if (timeout == 0) { dev_err(dev, "failed to reset channel %d\n", ch); return -EIO; @@ -144,6 +151,12 @@ static int reset_device(struct device *dev) /* * Reset and initialize the device */ +static void do_init_device(struct talitos_private *priv) +{ + setbits32(priv->reg + TALITOS_IMR, TALITOS_IMR_INIT); + setbits32(priv->reg + TALITOS_IMR_LO, TALITOS_IMR_LO_INIT); +} + static int init_device(struct device *dev) { struct talitos_private *priv = dev_get_drvdata(dev); @@ -171,8 +184,7 @@ static int init_device(struct device *dev) } /* enable channel done and error interrupts */ - setbits32(priv->reg + TALITOS_IMR, TALITOS_IMR_INIT); - setbits32(priv->reg + TALITOS_IMR_LO, TALITOS_IMR_LO_INIT); + do_init_device(priv); /* disable integrity check error interrupts (use writeback instead) */ if (priv->features & TALITOS_FTR_HW_AUTH_CHECK)