From patchwork Thu Sep 7 09:00:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 111868 Delivered-To: patch@linaro.org Received: by 10.140.94.239 with SMTP id g102csp516592qge; Thu, 7 Sep 2017 02:01:29 -0700 (PDT) X-Google-Smtp-Source: ADKCNb4D6GSqJG0eZnwiaNm4mWhc2oBcxMCrPrYAzuOonecAZt0X51T8yua198xsM2/y4o04EK20 X-Received: by 10.84.210.67 with SMTP id z61mr2170983plh.125.1504774889884; Thu, 07 Sep 2017 02:01:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504774889; cv=none; d=google.com; s=arc-20160816; b=VdvqWyoIZFcc4dbWudoN3tOzh2DavBCWFAKA9S63QI6NJkWCfuMox3v75q+E3ElZt1 GB86Os6ohLuEa13hlMHyn2JKYCDrgWQhLtwnGU8Zq7semw2MMZOCzFJlTsn8vInfozI4 8uPDmcEVWr/Z8uwv3jjq76/scFCK3+sUbTFza8EvS/mq8J2yzLEz4RHgT2o4789atNPF /m+6z6mVVqUA91hLUWpSHl+FMQrUpSx2N8Ca0ioma5JWQ6K5Hno6WdWyPVdm975zHKrQ 5Jl/9TfqmbehGt8vBwro+DFEi/85QIhvtjLnznZj4A3Jvfpb5frzIREJJxhbz2kiidl3 aI/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=vr0O0X1ppuf7Ox72JxDd97Kmq4myzJbIb1/QbStSqYg=; b=LMuZCPDQoi0CiZz9vBrEEQrczoRikSm8upZ8QAkJsxzY8iL10Dy3IEXZsm6870ya10 UhLadJnDYct3DyFyJXIQ5RNKJRj569POkAeUYKgVbcJL2inFUQJcKq8zYuk9auFrj4tg z6KITXW4l+R6jpCfuGJPAkFXTGs4dabGV71609qtFImWmfmISYN0SZVHojP6PLu8YYtH Gyc1J60Z2DYV9v+iBoajrdvCAbdSBeQqcUpqixJBmt7FbxpAX9IMnX5phuVw/wtcjEGl BoGP1XSq2mO7nmURlpAEln7IW1dTdURK2wdM5HQA0/Ap0NG1aBGBAtvAtNVXxwlHZgX4 nWJA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e28si1529620pgn.756.2017.09.07.02.01.29; Thu, 07 Sep 2017 02:01:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754924AbdIGJB1 (ORCPT + 26 others); Thu, 7 Sep 2017 05:01:27 -0400 Received: from foss.arm.com ([217.140.101.70]:57226 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754905AbdIGJBZ (ORCPT ); Thu, 7 Sep 2017 05:01:25 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 681A680D; Thu, 7 Sep 2017 02:01:25 -0700 (PDT) Received: from gby.kfn.arm.com (unknown [10.45.48.140]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D1BF63F540; Thu, 7 Sep 2017 02:01:22 -0700 (PDT) From: Gilad Ben-Yossef To: Greg Kroah-Hartman , linux-crypto@vger.kernel.org, driverdev-devel@linuxdriverproject.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Cc: Ofir Drang , Suniel Mahesh Subject: [PATCH v3 1/8] staging: ccree: Replace kzalloc with devm_kzalloc Date: Thu, 7 Sep 2017 12:00:09 +0300 Message-Id: <1504774817-11984-2-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1504774817-11984-1-git-send-email-gilad@benyossef.com> References: <1504774817-11984-1-git-send-email-gilad@benyossef.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Suniel Mahesh It is recommended to use managed function devm_kzalloc, which simplifies driver cleanup paths and driver code. This patch does the following: (a) replace kzalloc with devm_kzalloc. (b) drop kfree(), because memory allocated with devm_kzalloc() is automatically freed on driver detach, otherwise it leads to a double free. (c) remove unnecessary blank lines. Signed-off-by: Suniel Mahesh [gby: rebase on top of latest coding style fixes changes] Acked-by: Gilad Ben-Yossef --- drivers/staging/ccree/ssi_driver.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) -- 2.1.4 diff --git a/drivers/staging/ccree/ssi_driver.c b/drivers/staging/ccree/ssi_driver.c index 9c6f120..47e0880 100644 --- a/drivers/staging/ccree/ssi_driver.c +++ b/drivers/staging/ccree/ssi_driver.c @@ -223,14 +223,15 @@ static int init_cc_resources(struct platform_device *plat_dev) struct resource *req_mem_cc_regs = NULL; void __iomem *cc_base = NULL; bool irq_registered = false; - struct ssi_drvdata *new_drvdata = kzalloc(sizeof(*new_drvdata), - GFP_KERNEL); + struct ssi_drvdata *new_drvdata; struct device *dev = &plat_dev->dev; struct device_node *np = dev->of_node; u32 signature_val; int rc = 0; - if (unlikely(!new_drvdata)) { + new_drvdata = devm_kzalloc(&plat_dev->dev, sizeof(*new_drvdata), + GFP_KERNEL); + if (!new_drvdata) { SSI_LOG_ERR("Failed to allocate drvdata"); rc = -ENOMEM; goto init_cc_res_err; @@ -435,10 +436,8 @@ static int init_cc_resources(struct platform_device *plat_dev) resource_size(new_drvdata->res_mem)); new_drvdata->res_mem = NULL; } - kfree(new_drvdata); dev_set_drvdata(&plat_dev->dev, NULL); } - return rc; } @@ -479,8 +478,6 @@ static void cleanup_cc_resources(struct platform_device *plat_dev) drvdata->cc_base = NULL; drvdata->res_mem = NULL; } - - kfree(drvdata); dev_set_drvdata(&plat_dev->dev, NULL); } From patchwork Thu Sep 7 09:00:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 111869 Delivered-To: patch@linaro.org Received: by 10.140.94.239 with SMTP id g102csp516775qge; Thu, 7 Sep 2017 02:01:36 -0700 (PDT) X-Google-Smtp-Source: ADKCNb5jNmeqxyCDEqpOj5umqyUm53pviy3Zgj+mJfya8RKOB4ZngWReDXxPUnyP7q6Sjy/FImQs X-Received: by 10.99.112.24 with SMTP id l24mr1951846pgc.302.1504774896390; Thu, 07 Sep 2017 02:01:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504774896; cv=none; d=google.com; s=arc-20160816; b=g/bUL6v+Z987eBHmtVH2928BcAgRNa4Ak2rTw5m/pcCgupbeOhmFvDriqVkgyxYxkl A73FXgjh1ke2g0kR3xJRMG62MvkiUHlJLcOX4w2Ds+LqfDyRJRzrQJT035KD6AuoSBl1 fStxAtHm0DVVJ224afFkUg2FXm8hd4u5YxltkP4Vqe/qmiMQsWkP8G/nrToIpKDUloUv wggYH+1Q2bHLTRyziyQcXt/8xJxi8HruMi/yvzc7mDDkupdhlAS7sbZt2TYpjc8dZDf6 wEnMQM+x/YMg3CancpMgVQCVSNE+ZQ5CuVc+Be6F6HBm82elYi8l7OnSjSq5G4GNa4Z1 XXuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=WBFc9mldpDmCJp7r59odRl1RR1IG/4YwI1a6Ztw0VmM=; b=jiJkVUnaxwwVaCyNAviITzQdGL6CpKoQgElP2sTYk1kOgIaukkdFM2hsjqS6nZzv5F 7T6UFfF/H8UTt1lT2KBJzPBMdu5uZgbZ4YCmSoHwHNVr0H4owRjq34d4rR3d8pH9CW1Z j0ZPGila0Q3oj191fFNklxKuI80iL2NkyJzRBtPDlyOgo/E857VlKNVawHSmOwUSj1nS kxyjFaCScMlFZHrXAGkeJFt8kxkyZ8M4rx6SzCoaNBnq9dDUZVHFsIp55efmT12n/HVi R4+NK/k3N6BRHNfUait8QhMZKnsHFI6y9zCqi+XD0ZnXyVcFs4ERrO7UH02mhuIo8qsO XOIg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e6si1494918pgr.74.2017.09.07.02.01.36; Thu, 07 Sep 2017 02:01:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754956AbdIGJBd (ORCPT + 26 others); Thu, 7 Sep 2017 05:01:33 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:57232 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754928AbdIGJB3 (ORCPT ); Thu, 7 Sep 2017 05:01:29 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 388B380D; Thu, 7 Sep 2017 02:01:29 -0700 (PDT) Received: from gby.kfn.arm.com (unknown [10.45.48.140]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 251AA3F540; Thu, 7 Sep 2017 02:01:26 -0700 (PDT) From: Gilad Ben-Yossef To: Greg Kroah-Hartman , linux-crypto@vger.kernel.org, driverdev-devel@linuxdriverproject.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Cc: Ofir Drang , Suniel Mahesh Subject: [PATCH v3 2/8] staging: ccree: Convert to devm_ioremap_resource for map, unmap Date: Thu, 7 Sep 2017 12:00:10 +0300 Message-Id: <1504774817-11984-3-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1504774817-11984-1-git-send-email-gilad@benyossef.com> References: <1504774817-11984-1-git-send-email-gilad@benyossef.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Suniel Mahesh It is recommended to use managed function devm_ioremap_resource(), which simplifies driver cleanup paths and driver code. This patch does the following: (a) replace request_mem_region(), ioremap() and corresponding error handling with devm_ioremap_resource(). (b) remove struct resource pointer(res_mem) in struct ssi_drvdata as it seems redundant, use struct resource pointer which is defined locally and adjust return value of platform_get_resource() accordingly. (c) release_mem_region() and iounmap() are dropped, since devm_ioremap_ resource() releases and unmaps mem region on driver detach. (d) adjust log messages accordingly and remove any blank lines. Signed-off-by: Suniel Mahesh [gby: rebase on top of latest coding style fixes changes] Acked-by: Gilad Ben-Yossef --- drivers/staging/ccree/ssi_driver.c | 60 ++++++++++---------------------------- drivers/staging/ccree/ssi_driver.h | 1 - 2 files changed, 15 insertions(+), 46 deletions(-) -- 2.1.4 diff --git a/drivers/staging/ccree/ssi_driver.c b/drivers/staging/ccree/ssi_driver.c index 47e0880..cbe9a03 100644 --- a/drivers/staging/ccree/ssi_driver.c +++ b/drivers/staging/ccree/ssi_driver.c @@ -246,35 +246,21 @@ static int init_cc_resources(struct platform_device *plat_dev) dev_set_drvdata(&plat_dev->dev, new_drvdata); /* Get device resources */ /* First CC registers space */ - new_drvdata->res_mem = platform_get_resource(plat_dev, IORESOURCE_MEM, 0); - if (unlikely(!new_drvdata->res_mem)) { - SSI_LOG_ERR("Failed getting IO memory resource\n"); - rc = -ENODEV; - goto init_cc_res_err; - } - SSI_LOG_DEBUG("Got MEM resource (%s): start=%pad end=%pad\n", - new_drvdata->res_mem->name, - new_drvdata->res_mem->start, - new_drvdata->res_mem->end); + req_mem_cc_regs = platform_get_resource(plat_dev, IORESOURCE_MEM, 0); /* Map registers space */ - req_mem_cc_regs = request_mem_region(new_drvdata->res_mem->start, resource_size(new_drvdata->res_mem), "arm_cc7x_regs"); - if (unlikely(!req_mem_cc_regs)) { - SSI_LOG_ERR("Couldn't allocate registers memory region at " - "0x%08X\n", (unsigned int)new_drvdata->res_mem->start); - rc = -EBUSY; - goto init_cc_res_err; - } - cc_base = ioremap(new_drvdata->res_mem->start, resource_size(new_drvdata->res_mem)); - if (unlikely(!cc_base)) { - SSI_LOG_ERR("ioremap[CC](0x%08X,0x%08X) failed\n", - (unsigned int)new_drvdata->res_mem->start, - (unsigned int)resource_size(new_drvdata->res_mem)); - rc = -ENOMEM; + new_drvdata->cc_base = devm_ioremap_resource(&plat_dev->dev, + req_mem_cc_regs); + if (IS_ERR(new_drvdata->cc_base)) { + rc = PTR_ERR(new_drvdata->cc_base); goto init_cc_res_err; } - SSI_LOG_DEBUG("CC registers mapped from %pa to 0x%p\n", &new_drvdata->res_mem->start, cc_base); - new_drvdata->cc_base = cc_base; - + SSI_LOG_DEBUG("Got MEM resource (%s): start=%pad end=%pad\n", + req_mem_cc_regs->name, + req_mem_cc_regs->start, + req_mem_cc_regs->end); + SSI_LOG_DEBUG("CC registers mapped from %pa to 0x%p\n", + &req_mem_cc_regs->start, new_drvdata->cc_base); + cc_base = new_drvdata->cc_base; /* Then IRQ */ new_drvdata->res_irq = platform_get_resource(plat_dev, IORESOURCE_IRQ, 0); if (unlikely(!new_drvdata->res_irq)) { @@ -424,17 +410,9 @@ static int init_cc_resources(struct platform_device *plat_dev) #ifdef ENABLE_CC_SYSFS ssi_sysfs_fini(); #endif - - if (req_mem_cc_regs) { - if (irq_registered) { - free_irq(new_drvdata->res_irq->start, new_drvdata); - new_drvdata->res_irq = NULL; - iounmap(cc_base); - new_drvdata->cc_base = NULL; - } - release_mem_region(new_drvdata->res_mem->start, - resource_size(new_drvdata->res_mem)); - new_drvdata->res_mem = NULL; + if (irq_registered) { + free_irq(new_drvdata->res_irq->start, new_drvdata); + new_drvdata->res_irq = NULL; } dev_set_drvdata(&plat_dev->dev, NULL); } @@ -470,14 +448,6 @@ static void cleanup_cc_resources(struct platform_device *plat_dev) cc_clk_off(drvdata); free_irq(drvdata->res_irq->start, drvdata); drvdata->res_irq = NULL; - - if (drvdata->cc_base) { - iounmap(drvdata->cc_base); - release_mem_region(drvdata->res_mem->start, - resource_size(drvdata->res_mem)); - drvdata->cc_base = NULL; - drvdata->res_mem = NULL; - } dev_set_drvdata(&plat_dev->dev, NULL); } diff --git a/drivers/staging/ccree/ssi_driver.h b/drivers/staging/ccree/ssi_driver.h index b6ad89a..518c0bf 100644 --- a/drivers/staging/ccree/ssi_driver.h +++ b/drivers/staging/ccree/ssi_driver.h @@ -128,7 +128,6 @@ struct ssi_crypto_req { * @fw_ver: SeP loaded firmware version */ struct ssi_drvdata { - struct resource *res_mem; struct resource *res_irq; void __iomem *cc_base; unsigned int irq; From patchwork Thu Sep 7 09:00:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 111870 Delivered-To: patch@linaro.org Received: by 10.140.94.239 with SMTP id g102csp516845qge; Thu, 7 Sep 2017 02:01:39 -0700 (PDT) X-Google-Smtp-Source: ADKCNb70mTAg+NkuThqEoVFkM9ZdGSFcdaqJwzOmwmPh6bVW8lY8ly+4FXKESJU9ig65cVDFYhRg X-Received: by 10.84.236.10 with SMTP id q10mr2319224plk.326.1504774899455; Thu, 07 Sep 2017 02:01:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504774899; cv=none; d=google.com; s=arc-20160816; b=Zo174PFOcIVniwK16JX3RmDI1zCAfbEsGUGIF17WP7UkqnINkIdLOQbeK+KfhUEm7L 4tKA38aIa0qXjhjHJXWL+ZUb40UEmS6vmsULesxCkAWGNhrB8s9eImoO7ZOuh4j444BY u9fJyajrEBClAyMc2FcPM4RPy0NJL/BYv7vGjrkIHx1siorF09uvYnxYPP1FZ6JfqPAO YVc2W78hST9ftDndLXjzlycBpAJjs1FEOU5SipEg6h2Zllvme8eimS/1u/81zHb/1ghj 2PJMsxlHIbCAKQhxdwjMmv1Tmt6JJ4ebAzsPNeqs2Nu/UbR8YvJ/1cddO5i5uEo6tdBm eK3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=KRr5Brtbn7+lWxsa1t3z9Rzcq69LpXlVz7xUB2/UEA8=; b=zPCO5mpMzrPqNaj8f9Cg28BgehWlVVeK5PAROn39L7p0B36qdWt/EkAosBK8drunOR slPW//EzRoirxIqguT4f+ICm1lMVL0+mt0n9iXPuVGOHo/hOLIFYLg3yj8sKxIbVZ+OU hPKTbDofNqCCOx87gIBpO0ollHPbtG6i5PAaoDLpwwSqIOiwxm7k1o5K2jnQOWQSReLL qeRDVyiIiFlGpPLBz89VYUEubzFrvTjP5mub2oc5BtKxv5EAG/Uoz3kKJJXBfwxHCAAt 6oTzE9XLxnIQjo4v+CU7e7YuMwRR3CwK+BwmHdo0lOdN2AU8biV5BwVY2lhHufwmQblU TK5w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a2si1648903pln.695.2017.09.07.02.01.38; Thu, 07 Sep 2017 02:01:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754977AbdIGJBg (ORCPT + 26 others); Thu, 7 Sep 2017 05:01:36 -0400 Received: from foss.arm.com ([217.140.101.70]:57244 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754952AbdIGJBd (ORCPT ); Thu, 7 Sep 2017 05:01:33 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id CE15980D; Thu, 7 Sep 2017 02:01:32 -0700 (PDT) Received: from gby.kfn.arm.com (unknown [10.45.48.140]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id F04273F540; Thu, 7 Sep 2017 02:01:30 -0700 (PDT) From: Gilad Ben-Yossef To: Greg Kroah-Hartman , linux-crypto@vger.kernel.org, driverdev-devel@linuxdriverproject.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Cc: Ofir Drang , Suniel Mahesh Subject: [PATCH v3 3/8] staging: ccree: Use platform_get_irq and devm_request_irq Date: Thu, 7 Sep 2017 12:00:11 +0300 Message-Id: <1504774817-11984-4-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1504774817-11984-1-git-send-email-gilad@benyossef.com> References: <1504774817-11984-1-git-send-email-gilad@benyossef.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Suniel Mahesh It is recommended to use managed function devm_request_irq(), which simplifies driver cleanup paths and driver code. This patch does the following: (a) replace platform_get_resource(), request_irq() and corresponding error handling with platform_get_irq() and devm_request_irq(). (b) remove struct resource pointer(res_irq) in struct ssi_drvdata as it seems redundant. (c) change type of member irq in struct ssi_drvdata from unsigned int to int, as return type of platform_get_irq is int and can be used in error handling. (d) remove irq_registered variable from driver probe as it seems redundant. (e) free_irq is not required any more, devm_request_irq() free's it on driver detach. (f) adjust log messages accordingly and remove any blank lines. Signed-off-by: Suniel Mahesh Acked-by: Gilad Ben-Yossef --- drivers/staging/ccree/ssi_driver.c | 30 +++++++++--------------------- drivers/staging/ccree/ssi_driver.h | 3 +-- 2 files changed, 10 insertions(+), 23 deletions(-) -- 2.1.4 diff --git a/drivers/staging/ccree/ssi_driver.c b/drivers/staging/ccree/ssi_driver.c index cbe9a03..3e7193d 100644 --- a/drivers/staging/ccree/ssi_driver.c +++ b/drivers/staging/ccree/ssi_driver.c @@ -222,7 +222,6 @@ static int init_cc_resources(struct platform_device *plat_dev) { struct resource *req_mem_cc_regs = NULL; void __iomem *cc_base = NULL; - bool irq_registered = false; struct ssi_drvdata *new_drvdata; struct device *dev = &plat_dev->dev; struct device_node *np = dev->of_node; @@ -262,26 +261,22 @@ static int init_cc_resources(struct platform_device *plat_dev) &req_mem_cc_regs->start, new_drvdata->cc_base); cc_base = new_drvdata->cc_base; /* Then IRQ */ - new_drvdata->res_irq = platform_get_resource(plat_dev, IORESOURCE_IRQ, 0); - if (unlikely(!new_drvdata->res_irq)) { + new_drvdata->irq = platform_get_irq(plat_dev, 0); + if (new_drvdata->irq < 0) { SSI_LOG_ERR("Failed getting IRQ resource\n"); - rc = -ENODEV; + rc = new_drvdata->irq; goto init_cc_res_err; } - rc = request_irq(new_drvdata->res_irq->start, cc_isr, - IRQF_SHARED, "arm_cc7x", new_drvdata); - if (unlikely(rc != 0)) { - SSI_LOG_ERR("Could not register to interrupt %llu\n", - (unsigned long long)new_drvdata->res_irq->start); + rc = devm_request_irq(&plat_dev->dev, new_drvdata->irq, cc_isr, + IRQF_SHARED, "arm_cc7x", new_drvdata); + if (rc) { + SSI_LOG_ERR("Could not register to interrupt %d\n", + new_drvdata->irq); goto init_cc_res_err; } init_completion(&new_drvdata->icache_setup_completion); - irq_registered = true; - SSI_LOG_DEBUG("Registered to IRQ (%s) %llu\n", - new_drvdata->res_irq->name, - (unsigned long long)new_drvdata->res_irq->start); - + SSI_LOG_DEBUG("Registered to IRQ: %d\n", new_drvdata->irq); new_drvdata->plat_dev = plat_dev; rc = cc_clk_on(new_drvdata); @@ -410,10 +405,6 @@ static int init_cc_resources(struct platform_device *plat_dev) #ifdef ENABLE_CC_SYSFS ssi_sysfs_fini(); #endif - if (irq_registered) { - free_irq(new_drvdata->res_irq->start, new_drvdata); - new_drvdata->res_irq = NULL; - } dev_set_drvdata(&plat_dev->dev, NULL); } return rc; @@ -443,11 +434,8 @@ static void cleanup_cc_resources(struct platform_device *plat_dev) #ifdef ENABLE_CC_SYSFS ssi_sysfs_fini(); #endif - fini_cc_regs(drvdata); cc_clk_off(drvdata); - free_irq(drvdata->res_irq->start, drvdata); - drvdata->res_irq = NULL; dev_set_drvdata(&plat_dev->dev, NULL); } diff --git a/drivers/staging/ccree/ssi_driver.h b/drivers/staging/ccree/ssi_driver.h index 518c0bf..88ef370 100644 --- a/drivers/staging/ccree/ssi_driver.h +++ b/drivers/staging/ccree/ssi_driver.h @@ -128,9 +128,8 @@ struct ssi_crypto_req { * @fw_ver: SeP loaded firmware version */ struct ssi_drvdata { - struct resource *res_irq; void __iomem *cc_base; - unsigned int irq; + int irq; u32 irq_mask; u32 fw_ver; /* Calibration time of start/stop From patchwork Thu Sep 7 09:00:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 111871 Delivered-To: patch@linaro.org Received: by 10.140.94.239 with SMTP id g102csp516878qge; Thu, 7 Sep 2017 02:01:41 -0700 (PDT) X-Google-Smtp-Source: ADKCNb4J4YmrT63sCJICJQcxRZEdnKLoYDAYOUsbl1+XBUcXuFMiooUWQJmLM4Joi+F54vI4jWy8 X-Received: by 10.99.116.21 with SMTP id p21mr1990532pgc.93.1504774901000; Thu, 07 Sep 2017 02:01:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504774900; cv=none; d=google.com; s=arc-20160816; b=kIUYuv5hZ1V07KnCBHCPiRpTzSiif/t2GrpppJr5SQLApznB1w4M7XrvI2mc+IgVzx SEobcQmvhcaAPhB+yAZqNLI9E9HLt59B6RckIQ3Q9K89m1y5opUPuLnQQnoJHvtvaaKe QnBPyj6eR8oCiuJE8fZwlY9ufF3vxJCn6X/49zLfMN7R/MhEItFCESObJQj2aQM5T4Vt 51Wt1OqwUgNwDIgj0SAwNSwGszFi/tb936/9B8tYP8upQxCU2F6mTCJcScV7G57UcmBS Arz943T0TrtKxu5nphCOEsYuzKLnc/WHN5cbuPjLXtJvGbBCb2sGX2yQwVX/SPPTWudk Ckpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=piDruKUdB/WtbXjqG68v1yNY2cEQwEm8f0l8ijoz5yI=; b=lrs9iwqpU/c8A3j7D3kc6T4t0rjaf/Xt+Ran8GvBGMlfXMUVAtIExoDIV+CB7LIL/t awfEecSwJVYBHBhFXam5V1l+wo1Mp2TQQpjhBox7sQlUMxCtSL+5F20YQKXUO9o4k1KS qWhXP9efupMvB9TMpft8d7kw/FKNdR4uA9R0QnPZLT3nfH8W7zx+WV1CeYmm58r8wFR3 grGCTUTCFClwrLvl8VswOW8Zf2KKDuxKAtB5k8kGhpela70W7JZxcyJEQ4XG+/N/BYlg kPE5v40TyaZPURjz8MYpLAe/F0ErYeFAMsosx5DzTZeDF6kGbjnv5fwj3t4/nVWnKhYq W9bA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a2si1648903pln.695.2017.09.07.02.01.40; Thu, 07 Sep 2017 02:01:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755001AbdIGJBi (ORCPT + 26 others); Thu, 7 Sep 2017 05:01:38 -0400 Received: from foss.arm.com ([217.140.101.70]:57256 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754931AbdIGJBg (ORCPT ); Thu, 7 Sep 2017 05:01:36 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 6627180D; Thu, 7 Sep 2017 02:01:36 -0700 (PDT) Received: from gby.kfn.arm.com (unknown [10.45.48.140]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 88AEF3F540; Thu, 7 Sep 2017 02:01:34 -0700 (PDT) From: Gilad Ben-Yossef To: Greg Kroah-Hartman , linux-crypto@vger.kernel.org, driverdev-devel@linuxdriverproject.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Cc: Ofir Drang Subject: [PATCH v3 4/8] staging: ccree: simplify resource release on error Date: Thu, 7 Sep 2017 12:00:12 +0300 Message-Id: <1504774817-11984-5-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1504774817-11984-1-git-send-email-gilad@benyossef.com> References: <1504774817-11984-1-git-send-email-gilad@benyossef.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The resource release on probe/init error was being handled in an awkward manner and possibly leaking memory on certain (unlikely) error path. Fix it by simplifying the error resource release and making it easier to track. Reported-by: Dan Carpenter Signed-off-by: Gilad Ben-Yossef --- drivers/staging/ccree/ssi_aead.c | 3 +- drivers/staging/ccree/ssi_cipher.c | 3 +- drivers/staging/ccree/ssi_driver.c | 102 ++++++++++++++++++++----------------- drivers/staging/ccree/ssi_hash.c | 3 +- 4 files changed, 59 insertions(+), 52 deletions(-) -- 2.1.4 diff --git a/drivers/staging/ccree/ssi_aead.c b/drivers/staging/ccree/ssi_aead.c index 5abe6b2..8191ec4 100644 --- a/drivers/staging/ccree/ssi_aead.c +++ b/drivers/staging/ccree/ssi_aead.c @@ -2720,6 +2720,7 @@ int ssi_aead_alloc(struct ssi_drvdata *drvdata) goto fail0; } + INIT_LIST_HEAD(&aead_handle->aead_list); drvdata->aead_handle = aead_handle; aead_handle->sram_workspace_addr = ssi_sram_mgr_alloc( @@ -2730,8 +2731,6 @@ int ssi_aead_alloc(struct ssi_drvdata *drvdata) goto fail1; } - INIT_LIST_HEAD(&aead_handle->aead_list); - /* Linux crypto */ for (alg = 0; alg < ARRAY_SIZE(aead_algs); alg++) { t_alg = ssi_aead_create_alg(&aead_algs[alg]); diff --git a/drivers/staging/ccree/ssi_cipher.c b/drivers/staging/ccree/ssi_cipher.c index 1ff3c8a..ab0349f 100644 --- a/drivers/staging/ccree/ssi_cipher.c +++ b/drivers/staging/ccree/ssi_cipher.c @@ -1312,9 +1312,8 @@ int ssi_ablkcipher_alloc(struct ssi_drvdata *drvdata) if (!ablkcipher_handle) return -ENOMEM; - drvdata->blkcipher_handle = ablkcipher_handle; - INIT_LIST_HEAD(&ablkcipher_handle->blkcipher_alg_list); + drvdata->blkcipher_handle = ablkcipher_handle; /* Linux crypto */ SSI_LOG_DEBUG("Number of algorithms = %zu\n", ARRAY_SIZE(blkcipher_algs)); diff --git a/drivers/staging/ccree/ssi_driver.c b/drivers/staging/ccree/ssi_driver.c index 3e7193d..dc22f13 100644 --- a/drivers/staging/ccree/ssi_driver.c +++ b/drivers/staging/ccree/ssi_driver.c @@ -233,16 +233,14 @@ static int init_cc_resources(struct platform_device *plat_dev) if (!new_drvdata) { SSI_LOG_ERR("Failed to allocate drvdata"); rc = -ENOMEM; - goto init_cc_res_err; + goto post_drvdata_err; } + dev_set_drvdata(&plat_dev->dev, new_drvdata); + new_drvdata->plat_dev = plat_dev; new_drvdata->clk = of_clk_get(np, 0); new_drvdata->coherent = of_dma_is_coherent(np); - /*Initialize inflight counter used in dx_ablkcipher_secure_complete used for count of BYSPASS blocks operations*/ - new_drvdata->inflight_counter = 0; - - dev_set_drvdata(&plat_dev->dev, new_drvdata); /* Get device resources */ /* First CC registers space */ req_mem_cc_regs = platform_get_resource(plat_dev, IORESOURCE_MEM, 0); @@ -250,38 +248,42 @@ static int init_cc_resources(struct platform_device *plat_dev) new_drvdata->cc_base = devm_ioremap_resource(&plat_dev->dev, req_mem_cc_regs); if (IS_ERR(new_drvdata->cc_base)) { + SSI_LOG_ERR("Failed to ioremap registers"); rc = PTR_ERR(new_drvdata->cc_base); - goto init_cc_res_err; + goto post_drvdata_err; } + SSI_LOG_DEBUG("Got MEM resource (%s): start=%pad end=%pad\n", req_mem_cc_regs->name, req_mem_cc_regs->start, req_mem_cc_regs->end); SSI_LOG_DEBUG("CC registers mapped from %pa to 0x%p\n", &req_mem_cc_regs->start, new_drvdata->cc_base); + cc_base = new_drvdata->cc_base; + /* Then IRQ */ new_drvdata->irq = platform_get_irq(plat_dev, 0); if (new_drvdata->irq < 0) { SSI_LOG_ERR("Failed getting IRQ resource\n"); rc = new_drvdata->irq; - goto init_cc_res_err; + goto post_drvdata_err; } + rc = devm_request_irq(&plat_dev->dev, new_drvdata->irq, cc_isr, IRQF_SHARED, "arm_cc7x", new_drvdata); if (rc) { SSI_LOG_ERR("Could not register to interrupt %d\n", new_drvdata->irq); - goto init_cc_res_err; + goto post_drvdata_err; } - init_completion(&new_drvdata->icache_setup_completion); - SSI_LOG_DEBUG("Registered to IRQ: %d\n", new_drvdata->irq); - new_drvdata->plat_dev = plat_dev; + + init_completion(&new_drvdata->icache_setup_completion); rc = cc_clk_on(new_drvdata); if (rc) - goto init_cc_res_err; + goto post_drvdata_err; if (!new_drvdata->plat_dev->dev.dma_mask) new_drvdata->plat_dev->dev.dma_mask = &new_drvdata->plat_dev->dev.coherent_dma_mask; @@ -295,7 +297,7 @@ static int init_cc_resources(struct platform_device *plat_dev) SSI_LOG_ERR("Invalid CC signature: SIGNATURE=0x%08X != expected=0x%08X\n", signature_val, (u32)DX_DEV_SIGNATURE); rc = -EINVAL; - goto init_cc_res_err; + goto post_clk_err; } SSI_LOG_DEBUG("CC SIGNATURE=0x%08X\n", signature_val); @@ -306,21 +308,26 @@ static int init_cc_resources(struct platform_device *plat_dev) rc = init_cc_regs(new_drvdata, true); if (unlikely(rc != 0)) { SSI_LOG_ERR("init_cc_regs failed\n"); - goto init_cc_res_err; + goto post_clk_err; } #ifdef ENABLE_CC_SYSFS rc = ssi_sysfs_init(&plat_dev->dev.kobj, new_drvdata); if (unlikely(rc != 0)) { SSI_LOG_ERR("init_stat_db failed\n"); - goto init_cc_res_err; + goto post_regs_err; } #endif + rc = ssi_fips_init(new_drvdata); + if (unlikely(rc != 0)) { + SSI_LOG_ERR("SSI_FIPS_INIT failed 0x%x\n", rc); + goto post_sysfs_err; + } rc = ssi_sram_mgr_init(new_drvdata); if (unlikely(rc != 0)) { SSI_LOG_ERR("ssi_sram_mgr_init failed\n"); - goto init_cc_res_err; + goto post_fips_init_err; } new_drvdata->mlli_sram_addr = @@ -328,57 +335,51 @@ static int init_cc_resources(struct platform_device *plat_dev) if (unlikely(new_drvdata->mlli_sram_addr == NULL_SRAM_ADDR)) { SSI_LOG_ERR("Failed to alloc MLLI Sram buffer\n"); rc = -ENOMEM; - goto init_cc_res_err; + goto post_sram_mgr_err; } rc = request_mgr_init(new_drvdata); if (unlikely(rc != 0)) { SSI_LOG_ERR("request_mgr_init failed\n"); - goto init_cc_res_err; + goto post_sram_mgr_err; } rc = ssi_buffer_mgr_init(new_drvdata); if (unlikely(rc != 0)) { SSI_LOG_ERR("buffer_mgr_init failed\n"); - goto init_cc_res_err; + goto post_req_mgr_err; } rc = ssi_power_mgr_init(new_drvdata); if (unlikely(rc != 0)) { SSI_LOG_ERR("ssi_power_mgr_init failed\n"); - goto init_cc_res_err; - } - - rc = ssi_fips_init(new_drvdata); - if (unlikely(rc != 0)) { - SSI_LOG_ERR("SSI_FIPS_INIT failed 0x%x\n", rc); - goto init_cc_res_err; + goto post_buf_mgr_err; } rc = ssi_ivgen_init(new_drvdata); if (unlikely(rc != 0)) { SSI_LOG_ERR("ssi_ivgen_init failed\n"); - goto init_cc_res_err; + goto post_power_mgr_err; } /* Allocate crypto algs */ rc = ssi_ablkcipher_alloc(new_drvdata); if (unlikely(rc != 0)) { SSI_LOG_ERR("ssi_ablkcipher_alloc failed\n"); - goto init_cc_res_err; + goto post_ivgen_err; } /* hash must be allocated before aead since hash exports APIs */ rc = ssi_hash_alloc(new_drvdata); if (unlikely(rc != 0)) { SSI_LOG_ERR("ssi_hash_alloc failed\n"); - goto init_cc_res_err; + goto post_cipher_err; } rc = ssi_aead_alloc(new_drvdata); if (unlikely(rc != 0)) { SSI_LOG_ERR("ssi_aead_alloc failed\n"); - goto init_cc_res_err; + goto post_hash_err; } /* If we got here and FIPS mode is enabled @@ -389,24 +390,33 @@ static int init_cc_resources(struct platform_device *plat_dev) return 0; -init_cc_res_err: - SSI_LOG_ERR("Freeing CC HW resources!\n"); - - if (new_drvdata) { - ssi_aead_free(new_drvdata); - ssi_hash_free(new_drvdata); - ssi_ablkcipher_free(new_drvdata); - ssi_ivgen_fini(new_drvdata); - ssi_power_mgr_fini(new_drvdata); - ssi_buffer_mgr_fini(new_drvdata); - request_mgr_fini(new_drvdata); - ssi_sram_mgr_fini(new_drvdata); - ssi_fips_fini(new_drvdata); +post_hash_err: + ssi_hash_free(new_drvdata); +post_cipher_err: + ssi_ablkcipher_free(new_drvdata); +post_ivgen_err: + ssi_ivgen_fini(new_drvdata); +post_power_mgr_err: + ssi_power_mgr_fini(new_drvdata); +post_buf_mgr_err: + ssi_buffer_mgr_fini(new_drvdata); +post_req_mgr_err: + request_mgr_fini(new_drvdata); +post_sram_mgr_err: + ssi_sram_mgr_fini(new_drvdata); +post_fips_init_err: + ssi_fips_fini(new_drvdata); +post_sysfs_err: #ifdef ENABLE_CC_SYSFS - ssi_sysfs_fini(); + ssi_sysfs_fini(); #endif - dev_set_drvdata(&plat_dev->dev, NULL); - } +post_regs_err: + fini_cc_regs(new_drvdata); +post_clk_err: + cc_clk_off(new_drvdata); +post_drvdata_err: + SSI_LOG_ERR("ccree init error occurred!\n"); + dev_set_drvdata(&plat_dev->dev, NULL); return rc; } diff --git a/drivers/staging/ccree/ssi_hash.c b/drivers/staging/ccree/ssi_hash.c index 13291ae..36495b5 100644 --- a/drivers/staging/ccree/ssi_hash.c +++ b/drivers/staging/ccree/ssi_hash.c @@ -2234,6 +2234,7 @@ int ssi_hash_alloc(struct ssi_drvdata *drvdata) goto fail; } + INIT_LIST_HEAD(&hash_handle->hash_list); drvdata->hash_handle = hash_handle; sram_size_to_alloc = sizeof(digest_len_init) + @@ -2264,8 +2265,6 @@ int ssi_hash_alloc(struct ssi_drvdata *drvdata) goto fail; } - INIT_LIST_HEAD(&hash_handle->hash_list); - /* ahash registration */ for (alg = 0; alg < ARRAY_SIZE(driver_hash); alg++) { struct ssi_hash_alg *t_alg; From patchwork Thu Sep 7 09:00:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 111872 Delivered-To: patch@linaro.org Received: by 10.140.94.239 with SMTP id g102csp517000qge; Thu, 7 Sep 2017 02:01:46 -0700 (PDT) X-Google-Smtp-Source: ADKCNb6Tc9o+sREf3h1uH3s9EHok7pNUEGDhSCo3KY70wVBpr+cNdU734J4uqdWQUIQT938FpT+p X-Received: by 10.99.129.194 with SMTP id t185mr1925287pgd.195.1504774906579; Thu, 07 Sep 2017 02:01:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504774906; cv=none; d=google.com; s=arc-20160816; b=jEl1fV8xggKnb3fjDuICe0oj+LcOnRR5vc1y93LiW/SZhxcJA5WijCO8MZe+00JigF MzPo8WDiGSH/ElWo5tp1/kY/8AJKTeLWuiDMLVuAFfV3ZpsQVq2uIURu0QZ1Rt1/6DlN jch081YlGyzs373x4G0ud4bWtzEn4RbJMv4l/JgVuj8tGu34GQvv8vbL6mBTmw5RO195 Sr1/Xoy2QJBGo4zoTIu6kS1jZIKv/IFov5U+80yyPTa1lHeDyslV1CFYrjuiDhzSiyQZ z4uhZzHIB5JnM+OKIX88iNrCNoWA0w3iBz49WmmAzYXLGWb90Ra3rSqxIr6Yh99UDyQj UV5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=cltr8pjqX4JQrNKKm4tUqzDLMeEjwcUbneo+qt0i6pw=; b=ql2rUpshCXr9Xd3m2zug+0IjSWWOmnO8qzdwTP6FtlnYQqOiaYjCOPLHch2lXQzGks QeY1jRo/Ct5FF24+zaDnto3d54OvmyVq66vMtKAnJS7Vnb2xSYbmmnDWSw7jhlbIKI2+ eWDJGFEMBLMGLI9mqD/9+EtCDA//ik47Wrsgvo7+PxCT3xeEwVYTZz9ddvL0QSTtBnaU FfoQzk8j2P5b2GJiFNTu0pmIre5oodm96gxH29mHfEhaMHp2MsnbvbctdDRINP8Ah8/g qxb34JJfEAbgHZlMP0PenyQIOwHxD21FZb7LRN2s+Hzpix33ow52/873T9Y/m6SCwuB7 JMig== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 3si1598814plp.512.2017.09.07.02.01.46; Thu, 07 Sep 2017 02:01:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755019AbdIGJBm (ORCPT + 26 others); Thu, 7 Sep 2017 05:01:42 -0400 Received: from foss.arm.com ([217.140.101.70]:57266 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754893AbdIGJBk (ORCPT ); Thu, 7 Sep 2017 05:01:40 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B649E80D; Thu, 7 Sep 2017 02:01:39 -0700 (PDT) Received: from gby.kfn.arm.com (unknown [10.45.48.140]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1DBD33F540; Thu, 7 Sep 2017 02:01:37 -0700 (PDT) From: Gilad Ben-Yossef To: Greg Kroah-Hartman , linux-crypto@vger.kernel.org, driverdev-devel@linuxdriverproject.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Cc: Ofir Drang Subject: [PATCH v3 5/8] staging: ccree: remove unused completion Date: Thu, 7 Sep 2017 12:00:13 +0300 Message-Id: <1504774817-11984-6-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1504774817-11984-1-git-send-email-gilad@benyossef.com> References: <1504774817-11984-1-git-send-email-gilad@benyossef.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org icache_setup_completion is no longer used. Remove it. Signed-off-by: Gilad Ben-Yossef --- drivers/staging/ccree/ssi_driver.c | 2 -- drivers/staging/ccree/ssi_driver.h | 1 - 2 files changed, 3 deletions(-) -- 2.1.4 diff --git a/drivers/staging/ccree/ssi_driver.c b/drivers/staging/ccree/ssi_driver.c index dc22f13..8f1d7af 100644 --- a/drivers/staging/ccree/ssi_driver.c +++ b/drivers/staging/ccree/ssi_driver.c @@ -279,8 +279,6 @@ static int init_cc_resources(struct platform_device *plat_dev) } SSI_LOG_DEBUG("Registered to IRQ: %d\n", new_drvdata->irq); - init_completion(&new_drvdata->icache_setup_completion); - rc = cc_clk_on(new_drvdata); if (rc) goto post_drvdata_err; diff --git a/drivers/staging/ccree/ssi_driver.h b/drivers/staging/ccree/ssi_driver.h index 88ef370..9b6476d 100644 --- a/drivers/staging/ccree/ssi_driver.h +++ b/drivers/staging/ccree/ssi_driver.h @@ -138,7 +138,6 @@ struct ssi_drvdata { u32 monitor_null_cycles; struct platform_device *plat_dev; ssi_sram_addr_t mlli_sram_addr; - struct completion icache_setup_completion; void *buff_mgr_handle; void *hash_handle; void *aead_handle; From patchwork Thu Sep 7 09:00:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 111873 Delivered-To: patch@linaro.org Received: by 10.140.94.239 with SMTP id g102csp517030qge; Thu, 7 Sep 2017 02:01:48 -0700 (PDT) X-Google-Smtp-Source: ADKCNb4WE8vTb3+WD+F6mQ4rJLjiV3dtaKa1pq0PO9Q6Wyfeeb8tcsOhHdVPoBINbfJeruQP5Gkw X-Received: by 10.84.233.66 with SMTP id k2mr2180041plt.57.1504774908177; Thu, 07 Sep 2017 02:01:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504774908; cv=none; d=google.com; s=arc-20160816; b=qe0MYPY1DlMNx8jsA7gtjoryagKJz+x8ZQ9n8k787x1ZaCDtPIAA+tZMFE87sJq/ht 8Cym3L/Z8p+LAzHsVBbanCMIXKP5IqPx/nP5UJZ0vc5Sm4hFwcPgna/xjYFAZTTtAHa9 hxS0eM4QivwZU3fKkvvFqHTG02xAytOZLsqh6g0sgUupDa+ADlwK2/YApCRji65KWnI6 Nket5DiVnyQPIRXS4BbjLuCtQAOqhh7p5VOXfcV7kI6Bl2JUrPKZ2uMGvena5St97OQJ BTvoqlKkmqGkSl+R5lwGIbgwCJtZ3EtlOd2LF0rGODJJrSXBpovvNjGTaJ/5/7oOB+3R irbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=fwtsk9ntsL2uaf31Vro4gEycuDzb/TJQ/Epr9eZi83o=; b=sN6BbrGrqGvYso+3xk4ja8g1nVdagIMYGyMa7oFWOFuQCXqC6L8V+60Ul4erAKE6e+ UNNTd0MXJ643EAqsdI2WQjmGZ69FoAeDfTs6CDegkX2bcflPTsyghwlC6OUN/ap2I30x nV5hlWmxYiWwxzch7pGQl94OX+/BlqJVjsHqdiCHNh7sEAwGeHKVQa0BCyeWRn0HFBYm xZzkQ9xdKmvE0pEU8ur2j4ZedTBhbKBL502izMIK5hECWXza1soPl3Xr69g15bUj9JlD j1BSUuJltEUXpZm9oMoAIZj7x+504s2pOU1qYR/BuPr3RT+KAGD7Zg8OnJY1CayCuhbP Bgzg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f12si2014550plt.140.2017.09.07.02.01.47; Thu, 07 Sep 2017 02:01:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755041AbdIGJBp (ORCPT + 26 others); Thu, 7 Sep 2017 05:01:45 -0400 Received: from foss.arm.com ([217.140.101.70]:57274 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754893AbdIGJBn (ORCPT ); Thu, 7 Sep 2017 05:01:43 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 201C380D; Thu, 7 Sep 2017 02:01:43 -0700 (PDT) Received: from gby.kfn.arm.com (unknown [10.45.48.140]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7C9463F540; Thu, 7 Sep 2017 02:01:41 -0700 (PDT) From: Gilad Ben-Yossef To: Greg Kroah-Hartman , linux-crypto@vger.kernel.org, driverdev-devel@linuxdriverproject.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Cc: Ofir Drang Subject: [PATCH v3 6/8] staging: ccree: move over to BIT macro for bit defines Date: Thu, 7 Sep 2017 12:00:14 +0300 Message-Id: <1504774817-11984-7-git-send-email-gilad@benyossef.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1504774817-11984-1-git-send-email-gilad@benyossef.com> References: <1504774817-11984-1-git-send-email-gilad@benyossef.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use BIT macro for bit definitions where needed. Signed-off-by: Gilad Ben-Yossef --- drivers/staging/ccree/ssi_cipher.h | 10 +++++----- drivers/staging/ccree/ssi_driver.c | 3 ++- drivers/staging/ccree/ssi_driver.h | 6 +++--- 3 files changed, 10 insertions(+), 9 deletions(-) -- 2.1.4 diff --git a/drivers/staging/ccree/ssi_cipher.h b/drivers/staging/ccree/ssi_cipher.h index 296b375..c9a83df 100644 --- a/drivers/staging/ccree/ssi_cipher.h +++ b/drivers/staging/ccree/ssi_cipher.h @@ -27,11 +27,11 @@ #include "ssi_buffer_mgr.h" /* Crypto cipher flags */ -#define CC_CRYPTO_CIPHER_KEY_KFDE0 (1 << 0) -#define CC_CRYPTO_CIPHER_KEY_KFDE1 (1 << 1) -#define CC_CRYPTO_CIPHER_KEY_KFDE2 (1 << 2) -#define CC_CRYPTO_CIPHER_KEY_KFDE3 (1 << 3) -#define CC_CRYPTO_CIPHER_DU_SIZE_512B (1 << 4) +#define CC_CRYPTO_CIPHER_KEY_KFDE0 BIT(0) +#define CC_CRYPTO_CIPHER_KEY_KFDE1 BIT(1) +#define CC_CRYPTO_CIPHER_KEY_KFDE2 BIT(2) +#define CC_CRYPTO_CIPHER_KEY_KFDE3 BIT(3) +#define CC_CRYPTO_CIPHER_DU_SIZE_512B BIT(4) #define CC_CRYPTO_CIPHER_KEY_KFDE_MASK (CC_CRYPTO_CIPHER_KEY_KFDE0 | CC_CRYPTO_CIPHER_KEY_KFDE1 | CC_CRYPTO_CIPHER_KEY_KFDE2 | CC_CRYPTO_CIPHER_KEY_KFDE3) diff --git a/drivers/staging/ccree/ssi_driver.c b/drivers/staging/ccree/ssi_driver.c index 8f1d7af..6d16220 100644 --- a/drivers/staging/ccree/ssi_driver.c +++ b/drivers/staging/ccree/ssi_driver.c @@ -185,7 +185,8 @@ int init_cc_regs(struct ssi_drvdata *drvdata, bool is_probe) CC_HAL_WRITE_REGISTER(CC_REG_OFFSET(HOST_RGF, HOST_ICR), val); /* Unmask relevant interrupt cause */ - val = (~(SSI_COMP_IRQ_MASK | SSI_AXI_ERR_IRQ_MASK | SSI_GPR0_IRQ_MASK)); + val = (unsigned int)(~(SSI_COMP_IRQ_MASK | SSI_AXI_ERR_IRQ_MASK | + SSI_GPR0_IRQ_MASK)); CC_HAL_WRITE_REGISTER(CC_REG_OFFSET(HOST_RGF, HOST_IMR), val); #ifdef DX_HOST_IRQ_TIMER_INIT_VAL_REG_OFFSET diff --git a/drivers/staging/ccree/ssi_driver.h b/drivers/staging/ccree/ssi_driver.h index 9b6476d..06a3c48 100644 --- a/drivers/staging/ccree/ssi_driver.h +++ b/drivers/staging/ccree/ssi_driver.h @@ -68,12 +68,12 @@ #define SSI_AXI_IRQ_MASK ((1 << DX_AXIM_CFG_BRESPMASK_BIT_SHIFT) | (1 << DX_AXIM_CFG_RRESPMASK_BIT_SHIFT) | \ (1 << DX_AXIM_CFG_INFLTMASK_BIT_SHIFT) | (1 << DX_AXIM_CFG_COMPMASK_BIT_SHIFT)) -#define SSI_AXI_ERR_IRQ_MASK (1 << DX_HOST_IRR_AXI_ERR_INT_BIT_SHIFT) +#define SSI_AXI_ERR_IRQ_MASK BIT(DX_HOST_IRR_AXI_ERR_INT_BIT_SHIFT) -#define SSI_COMP_IRQ_MASK (1 << DX_HOST_IRR_AXIM_COMP_INT_BIT_SHIFT) +#define SSI_COMP_IRQ_MASK BIT(DX_HOST_IRR_AXIM_COMP_INT_BIT_SHIFT) /* TEE FIPS status interrupt */ -#define SSI_GPR0_IRQ_MASK (1 << DX_HOST_IRR_GPR0_BIT_SHIFT) +#define SSI_GPR0_IRQ_MASK BIT(DX_HOST_IRR_GPR0_BIT_SHIFT) #define SSI_CRA_PRIO 3000