From patchwork Fri Apr 17 14:32: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: 6233781 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: X-Original-To: patchwork-linux-crypto@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E25779F1AC for ; Fri, 17 Apr 2015 14:34:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1268E20306 for ; Fri, 17 Apr 2015 14:34:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 82549202E5 for ; Fri, 17 Apr 2015 14:34:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934502AbbDQOcJ (ORCPT ); Fri, 17 Apr 2015 10:32:09 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:42145 "EHLO mailhub1.si.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752034AbbDQOcH (ORCPT ); Fri, 17 Apr 2015 10:32:07 -0400 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 0D2551C809B; Fri, 17 Apr 2015 16:32:06 +0200 (CEST) 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 vwNx-At29ohs; Fri, 17 Apr 2015 16:32:05 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id E8FF81C808B; Fri, 17 Apr 2015 16:32:05 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id D8DE7C73C8; Fri, 17 Apr 2015 16:32:05 +0200 (CEST) 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 1S8LY-bEMCS6; Fri, 17 Apr 2015 16:32:05 +0200 (CEST) Received: from PO10863.localdomain (unknown [10.25.205.191]) by messagerie.si.c-s.fr (Postfix) with ESMTP id B04D7C73C5; Fri, 17 Apr 2015 16:32:05 +0200 (CEST) Received: by localhost.localdomain (Postfix, from userid 0) id 9D8171A242C; Fri, 17 Apr 2015 16:32:05 +0200 (CEST) From: Christophe Leroy Subject: [PATCH v3 09/17] crypto: talitos - Add a feature to tag SEC1 To: Kim Phillips , Herbert Xu , David S Miller Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-crypto@vger.kernel.org Message-Id: <20150417143205.9D8171A242C@localhost.localdomain> Date: Fri, 17 Apr 2015 16:32:05 +0200 (CEST) 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=unavailable 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 We add a new feature in the features field, to mark compatible "fsl,sec1.0" We also define a helper function called has_ftr_sec1() to help functions quickly determine if they are running on SEC1 or SEC2+. When only SEC1 or SEC2 is compiled in, has_ftr_sec1() return trivial corresponding value. If both are compiled in, feature field is checked. Signed-off-by: Christophe Leroy --- drivers/crypto/talitos.c | 3 +++ drivers/crypto/talitos.h | 17 +++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/drivers/crypto/talitos.c b/drivers/crypto/talitos.c index bca6ded..db95023 100644 --- a/drivers/crypto/talitos.c +++ b/drivers/crypto/talitos.c @@ -2709,6 +2709,9 @@ static int talitos_probe(struct platform_device *ofdev) TALITOS_FTR_SHA224_HWINIT | TALITOS_FTR_HMAC_OK; + if (of_device_is_compatible(np, "fsl,sec1.0")) + priv->features |= TALITOS_FTR_SEC1; + priv->chan = kzalloc(sizeof(struct talitos_channel) * priv->num_channels, GFP_KERNEL); if (!priv->chan) { diff --git a/drivers/crypto/talitos.h b/drivers/crypto/talitos.h index f078da1..b0bdb4e 100644 --- a/drivers/crypto/talitos.h +++ b/drivers/crypto/talitos.h @@ -156,6 +156,23 @@ extern int talitos_submit(struct device *dev, int ch, struct talitos_desc *desc, #define TALITOS_FTR_HW_AUTH_CHECK 0x00000002 #define TALITOS_FTR_SHA224_HWINIT 0x00000004 #define TALITOS_FTR_HMAC_OK 0x00000008 +#define TALITOS_FTR_SEC1 0x00000010 + +/* + * If both CONFIG_CRYPTO_DEV_TALITOS1 and CONFIG_CRYPTO_DEV_TALITOS2 are + * defined, we check the features which are set according to the device tree. + * Otherwise, we answer true or false directly + */ +static inline bool has_ftr_sec1(struct talitos_private *priv) +{ +#if defined(CONFIG_CRYPTO_DEV_TALITOS1) && defined(CONFIG_CRYPTO_DEV_TALITOS2) + return priv->features & TALITOS_FTR_SEC1 ? true : false; +#elif defined(CONFIG_CRYPTO_DEV_TALITOS1) + return true; +#else + return false; +#endif +} /* * TALITOS_xxx_LO addresses point to the low data bits (32-63) of the register