From patchwork Tue Oct 22 15:30:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 11204729 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DAECE13BD for ; Tue, 22 Oct 2019 15:30:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B8B9A2084B for ; Tue, 22 Oct 2019 15:30:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jVYHcG2y" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731100AbfJVPa1 (ORCPT ); Tue, 22 Oct 2019 11:30:27 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:38215 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730433AbfJVPa0 (ORCPT ); Tue, 22 Oct 2019 11:30:26 -0400 Received: by mail-pg1-f194.google.com with SMTP id w3so10159467pgt.5; Tue, 22 Oct 2019 08:30:26 -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 :mime-version:content-transfer-encoding; bh=ATIwrf/1fIEUlKhFd36q+N/Ssl36ZJUl1JImv5rIDe0=; b=jVYHcG2y1vchfspKigbDnXW8DzWH8gDgp1bGHchM/LqtbiplfZtL3aY7nebEPA+1o+ sccYNTu9iARcdVNlohY/BaybEx/FNbxJCr5OmCPap95OOaiX3lCNEMg5Xll/LaOO5HKi xQkS4YxR/TkS/55d/Vyis6F+YcZ1EbNW+aBeISLOq5aFGRepU4Hp0umYBzQbNsv3W13a DjOxU2jPYMx4+pNqYj/BImnvt5iEpUHCPoJR3sX4fbXKZ6mIsFK8Ed0Xf7o2kya4czeD YAkqG84sh5rMbDfaF6XpZr39I9efgtNhI9BYlNXiaU5xfQVLus38x+X1EgxOXM/RwiuC TipQ== 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:mime-version:content-transfer-encoding; bh=ATIwrf/1fIEUlKhFd36q+N/Ssl36ZJUl1JImv5rIDe0=; b=Q4gi9qdqE2j4mcsoe8HpPeq4JMDI4QXfR/i5TQ+IJf1RpD+hcvcjjbgAoIk37GtFx3 Pr2JXv1BIOcQaNaw2WO0D+oUHMlsfsYTqCy8UMTPOXhQDpPYqGqUw+lAFPj7fvl6yEOZ WvHHZxsZekraxP8/DmpUcR4teCNG+MAnQVvuwE+d44FHiJOEmt1yDdP12oIVj11Vg6aq UoETOMicMQ+x2+ShcNp+hLyQdMy1vxDtFYbJCxGwXdZssBClnuqwwoZAwoOCWmIttzJT CMf8AklnRQILehBubGWxTs+d8ldsuTaaTVk/wILzQFPp8TWp46Ph6B9qtbujI7aeso5h wUmg== X-Gm-Message-State: APjAAAXC8uXu6zJSPQswkRhwRwbD2bG0Yt9SHAixXBlE15edVt+wkyMN Ma62utAb3LCqJaC5fp4KxJ2od772 X-Google-Smtp-Source: APXvYqyYaii82DUJJmMLQRC4tlBlWil3ezwfSgN0fqfJ5rXse7PaVQpC5+2uGpYACUDYs6b7VZQWfw== X-Received: by 2002:a63:5d06:: with SMTP id r6mr4482677pgb.216.1571758225540; Tue, 22 Oct 2019 08:30:25 -0700 (PDT) Received: from localhost.lan (c-67-185-54-80.hsd1.wa.comcast.net. [67.185.54.80]) by smtp.gmail.com with ESMTPSA id z63sm6066128pgb.75.2019.10.22.08.30.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2019 08:30:24 -0700 (PDT) From: Andrey Smirnov To: linux-crypto@vger.kernel.org Cc: Andrey Smirnov , =?utf-8?q?Horia_Geant=C4=83?= , Chris Healy , Lucas Stach , Herbert Xu , Iuliana Prodan , linux-kernel@vger.kernel.org Subject: [PATCH v2 1/6] crypto: caam - use devres to unmap memory Date: Tue, 22 Oct 2019 08:30:08 -0700 Message-Id: <20191022153013.3692-2-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191022153013.3692-1-andrew.smirnov@gmail.com> References: <20191022153013.3692-1-andrew.smirnov@gmail.com> MIME-Version: 1.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Use devres to unmap memory and drop corresponding iounmap() call. Signed-off-by: Andrey Smirnov Reviewed-by: Horia Geantă Cc: Chris Healy Cc: Lucas Stach Cc: Horia Geantă Cc: Herbert Xu Cc: Iuliana Prodan Cc: linux-crypto@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- drivers/crypto/caam/ctrl.c | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/drivers/crypto/caam/ctrl.c b/drivers/crypto/caam/ctrl.c index db22777d59b4..35bf82d1bedc 100644 --- a/drivers/crypto/caam/ctrl.c +++ b/drivers/crypto/caam/ctrl.c @@ -308,11 +308,9 @@ static int caam_remove(struct platform_device *pdev) { struct device *ctrldev; struct caam_drv_private *ctrlpriv; - struct caam_ctrl __iomem *ctrl; ctrldev = &pdev->dev; ctrlpriv = dev_get_drvdata(ctrldev); - ctrl = (struct caam_ctrl __iomem *)ctrlpriv->ctrl; /* Remove platform devices under the crypto node */ of_platform_depopulate(ctrldev); @@ -334,9 +332,6 @@ static int caam_remove(struct platform_device *pdev) debugfs_remove_recursive(ctrlpriv->dfs_root); #endif - /* Unmap controller region */ - iounmap(ctrl); - return 0; } @@ -611,10 +606,11 @@ static int caam_probe(struct platform_device *pdev) /* Get configuration properties from device tree */ /* First, get register page */ - ctrl = of_iomap(nprop, 0); - if (!ctrl) { + ctrl = devm_of_iomap(dev, nprop, 0, NULL); + ret = PTR_ERR_OR_ZERO(ctrl); + if (ret) { dev_err(dev, "caam: of_iomap() failed\n"); - return -ENOMEM; + return ret; } caam_little_end = !(bool)(rd_reg32(&ctrl->perfmon.status) & @@ -632,22 +628,18 @@ static int caam_probe(struct platform_device *pdev) if (ctrlpriv->qi_present && !caam_dpaa2) { ret = qman_is_probed(); if (!ret) { - ret = -EPROBE_DEFER; - goto iounmap_ctrl; + return -EPROBE_DEFER; } else if (ret < 0) { dev_err(dev, "failing probe due to qman probe error\n"); - ret = -ENODEV; - goto iounmap_ctrl; + return -ENODEV; } ret = qman_portals_probed(); if (!ret) { - ret = -EPROBE_DEFER; - goto iounmap_ctrl; + return -EPROBE_DEFER; } else if (ret < 0) { dev_err(dev, "failing probe due to qman portals probe error\n"); - ret = -ENODEV; - goto iounmap_ctrl; + return -ENODEV; } } #endif @@ -722,7 +714,7 @@ static int caam_probe(struct platform_device *pdev) ret = dma_set_mask_and_coherent(dev, caam_get_dma_mask(dev)); if (ret) { dev_err(dev, "dma_set_mask_and_coherent failed (%d)\n", ret); - goto iounmap_ctrl; + return ret; } ctrlpriv->era = caam_get_era(ctrl); @@ -927,8 +919,6 @@ static int caam_probe(struct platform_device *pdev) if (ctrlpriv->qi_init) caam_qi_shutdown(dev); #endif -iounmap_ctrl: - iounmap(ctrl); return ret; } From patchwork Tue Oct 22 15:30:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 11204727 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9110C1575 for ; Tue, 22 Oct 2019 15:30:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6F44D21925 for ; Tue, 22 Oct 2019 15:30:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="frkKSecJ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732315AbfJVPa2 (ORCPT ); Tue, 22 Oct 2019 11:30:28 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:33013 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731847AbfJVPa2 (ORCPT ); Tue, 22 Oct 2019 11:30:28 -0400 Received: by mail-pf1-f196.google.com with SMTP id c184so1355111pfb.0; Tue, 22 Oct 2019 08:30:28 -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 :mime-version:content-transfer-encoding; bh=rT4GXJF7buPzYnqx1xUjqSmLFZuFPpQXbUzgyd/qzyo=; b=frkKSecJzMMV84FXEwhiPWVRa7fA/HBirX5Ee433R2NY5Tg7ukl7nuR26bEQ1QG724 1UpWkQ2zqTUXih8UgaDEocX87XDJ9ggN25yMzsKMUapdO2c35l0W4s4RB7rd3bKEZBCu X99tDNj1m/ycQE8uOp6lPQalgSUVlfH/iSHE/IlCtr+T9ESzEshAttra9jhA4r/Qz2HD zLEmWqUCa+FDBXPHqK0Ro1TpUOD7VNvf5qUHnuByge+oWOlrCB6jwJuFZYsHrvNKeAbP upH39WW29kuzM3svDJMRHhknVK1BbBpAPDzQECwA0zj5Nsk6NWgZTxvSEaTfRHHA2A7p 54mQ== 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:mime-version:content-transfer-encoding; bh=rT4GXJF7buPzYnqx1xUjqSmLFZuFPpQXbUzgyd/qzyo=; b=S0UlGPykUhHszFCOc+wYeYZMFNjbLAMLiZkClFqV0p4jD8UbgGQ2xhkSbZs2T4tGYE K9jd85KrilYMJXU+idfr63SzJwrzPmCIiGp6UPRTYyGstNvwNs4YYiDGKaKsFnkUZJaB XFUWKalZkkzU4J+8JRyBkdtLh+uqEamfGDwJQtIHEJZfV4aAun4BeiOOPRkR1h3jUXQ4 jFub4MKesrX7uO7dQFr4rGrYeXS4Buku/pIxhaYg9300qXAo8fxHbkWPpxLl4UxdbEbI wUfpZ6RGju/dI+tHSHEorKj72pUQy5awLys5jVxWVDijSDBJodQ4L9nFZPN5XtOJCmL/ FlrA== X-Gm-Message-State: APjAAAVJQEJaVfid+WwM6uFNrCca6owgIRlhGm/KnwOq464wqfCDZnmk 7P/xt8J/hTkmOB6uuVR0mo1GeWxw X-Google-Smtp-Source: APXvYqz2jivGMVgx/Ywafy07MpfqNt6nU536T1eaDqJlAEHikHNtbs9majer6J4WihD1cY5t/HRHMQ== X-Received: by 2002:a63:a02:: with SMTP id 2mr4355409pgk.389.1571758227209; Tue, 22 Oct 2019 08:30:27 -0700 (PDT) Received: from localhost.lan (c-67-185-54-80.hsd1.wa.comcast.net. [67.185.54.80]) by smtp.gmail.com with ESMTPSA id z63sm6066128pgb.75.2019.10.22.08.30.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2019 08:30:26 -0700 (PDT) From: Andrey Smirnov To: linux-crypto@vger.kernel.org Cc: Andrey Smirnov , =?utf-8?q?Horia_Geant=C4=83?= , Chris Healy , Lucas Stach , Herbert Xu , Iuliana Prodan , linux-kernel@vger.kernel.org Subject: [PATCH v2 2/6] crypto: caam - use devres to remove debugfs Date: Tue, 22 Oct 2019 08:30:09 -0700 Message-Id: <20191022153013.3692-3-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191022153013.3692-1-andrew.smirnov@gmail.com> References: <20191022153013.3692-1-andrew.smirnov@gmail.com> MIME-Version: 1.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Use devres to remove debugfs and drop corresponding debugfs_remove_recursive() call. Signed-off-by: Andrey Smirnov Reviewed-by: Horia Geantă Cc: Chris Healy Cc: Lucas Stach Cc: Horia Geantă Cc: Herbert Xu Cc: Iuliana Prodan Cc: linux-crypto@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- drivers/crypto/caam/ctrl.c | 21 ++++++++++++++------- drivers/crypto/caam/intern.h | 1 - 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/drivers/crypto/caam/ctrl.c b/drivers/crypto/caam/ctrl.c index 35bf82d1bedc..254963498abc 100644 --- a/drivers/crypto/caam/ctrl.c +++ b/drivers/crypto/caam/ctrl.c @@ -327,11 +327,6 @@ static int caam_remove(struct platform_device *pdev) if (!ctrlpriv->mc_en && ctrlpriv->rng4_sh_init) deinstantiate_rng(ctrldev, ctrlpriv->rng4_sh_init); - /* Shut down debug views */ -#ifdef CONFIG_DEBUG_FS - debugfs_remove_recursive(ctrlpriv->dfs_root); -#endif - return 0; } @@ -563,6 +558,13 @@ static int init_clocks(struct device *dev, const struct caam_imx_data *data) return devm_add_action_or_reset(dev, disable_clocks, ctrlpriv); } +#ifdef CONFIG_DEBUG_FS +static void caam_remove_debugfs(void *root) +{ + debugfs_remove_recursive(root); +} +#endif + /* Probe routine for CAAM top (controller) level */ static int caam_probe(struct platform_device *pdev) { @@ -575,6 +577,7 @@ static int caam_probe(struct platform_device *pdev) struct caam_drv_private *ctrlpriv; #ifdef CONFIG_DEBUG_FS struct caam_perfmon *perfmon; + struct dentry *dfs_root; #endif u32 scfgr, comp_params; u8 rng_vid; @@ -728,8 +731,12 @@ static int caam_probe(struct platform_device *pdev) */ perfmon = (struct caam_perfmon __force *)&ctrl->perfmon; - ctrlpriv->dfs_root = debugfs_create_dir(dev_name(dev), NULL); - ctrlpriv->ctl = debugfs_create_dir("ctl", ctrlpriv->dfs_root); + dfs_root = debugfs_create_dir(dev_name(dev), NULL); + ret = devm_add_action_or_reset(dev, caam_remove_debugfs, dfs_root); + if (ret) + return ret; + + ctrlpriv->ctl = debugfs_create_dir("ctl", dfs_root); #endif /* Check to see if (DPAA 1.x) QI present. If so, enable */ diff --git a/drivers/crypto/caam/intern.h b/drivers/crypto/caam/intern.h index 731b06becd9c..359eb76d1259 100644 --- a/drivers/crypto/caam/intern.h +++ b/drivers/crypto/caam/intern.h @@ -102,7 +102,6 @@ struct caam_drv_private { * variables at runtime. */ #ifdef CONFIG_DEBUG_FS - struct dentry *dfs_root; struct dentry *ctl; /* controller dir */ struct debugfs_blob_wrapper ctl_kek_wrap, ctl_tkek_wrap, ctl_tdsk_wrap; #endif From patchwork Tue Oct 22 15:30:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 11204725 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BAC6E14E5 for ; Tue, 22 Oct 2019 15:30:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8F2C1218AE for ; Tue, 22 Oct 2019 15:30:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Efu2Ml4t" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732331AbfJVPac (ORCPT ); Tue, 22 Oct 2019 11:30:32 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:41900 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731847AbfJVPaa (ORCPT ); Tue, 22 Oct 2019 11:30:30 -0400 Received: by mail-pl1-f193.google.com with SMTP id t10so8508676plr.8; Tue, 22 Oct 2019 08:30:29 -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 :mime-version:content-transfer-encoding; bh=ms5yYseASytAjz6fyuBFRj0zh2PNWY/vP3+FE4TWBFA=; b=Efu2Ml4tEtH3KCvIu6URPx9Zp/jzK+3nRR5uZv1453cN8qiUNmkiqxGPMLJPsTJgNC 3+1hB+IcqrcYuNwPpADR/TCpnj0r002hsuEK/czMWBnHZEkNwb8L8rTQ2vz3/DoKpsf5 hddAp+2vho++n9C/PoVw4sGHOEmLX1A1LlJi3N5IgUcj0GtG8kr79vEY7VMTwbLFwyTE a398JpfOp6z8OjlyxfjWZfkZXaTIOmV8X58wOyYu6tTBc777HGzwDpV0MinXluMm7bPV YuXIL5qe+uFMUkZGO9uf89sWMlkm7Pq08n1x/zX1saCsxYnt4cXe14BvlBLOyPpJfG4j 7duA== 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:mime-version:content-transfer-encoding; bh=ms5yYseASytAjz6fyuBFRj0zh2PNWY/vP3+FE4TWBFA=; b=GTzmK8EB4Wz5nkffWNop/T4ZL0PFeVUppV1ig02DzbW58C0UdDluFVuI2pZ4AsIzpd hqo2JXg58i2b6hXjIopeZW7GfaxqYy5E80//sxE6d0IcLxlDUy9wOLzXFhSkZMU/UIxp bvAR/iL/SPEYK3C0f6KjJS2/+U1nJh+dS8gIkFsKSA5Ohd/dTS/7tADG9Uu4YDCdsomM siU81Fo0vxjGUqsTEz+ihhkxSaHsZ+BPsN1nmwAA/Pl3Hv2psHabIXVy7rvgvGcN6gY8 byLvUSnCsSFK8717wQkT9vnEAKTjOfSiPOdoj6SXdXTvtGKoGt9z8Hr7QmkPxyusWqXU ZYaQ== X-Gm-Message-State: APjAAAXnfYEzZ7gWDs4+j5v20OEOdS81m2Cz6RmOQvx7arznOD3wNWj1 tipoN7omyRAcNRF1bhChl06IA0Hs X-Google-Smtp-Source: APXvYqyeJZUIHz+MfQhYPiPiN9eY40k5/qc05LGDxHHd1twd5g9bP8uAd9C5WjZmh653MupLA+EXjQ== X-Received: by 2002:a17:902:b287:: with SMTP id u7mr4325682plr.65.1571758228944; Tue, 22 Oct 2019 08:30:28 -0700 (PDT) Received: from localhost.lan (c-67-185-54-80.hsd1.wa.comcast.net. [67.185.54.80]) by smtp.gmail.com with ESMTPSA id z63sm6066128pgb.75.2019.10.22.08.30.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2019 08:30:27 -0700 (PDT) From: Andrey Smirnov To: linux-crypto@vger.kernel.org Cc: Andrey Smirnov , Chris Healy , Lucas Stach , =?utf-8?q?Horia_Geant=C4=83?= , Herbert Xu , Iuliana Prodan , linux-kernel@vger.kernel.org Subject: [PATCH v2 3/6] crypto: caam - use devres to de-initialize the RNG Date: Tue, 22 Oct 2019 08:30:10 -0700 Message-Id: <20191022153013.3692-4-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191022153013.3692-1-andrew.smirnov@gmail.com> References: <20191022153013.3692-1-andrew.smirnov@gmail.com> MIME-Version: 1.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Use devres to de-initialize the RNG and drop explicit de-initialization code in caam_remove(). Signed-off-by: Andrey Smirnov Cc: Chris Healy Cc: Lucas Stach Cc: Horia Geantă Cc: Herbert Xu Cc: Iuliana Prodan Cc: linux-crypto@vger.kernel.org Cc: linux-kernel@vger.kernel.org Reviewed-by: Horia Geantă --- drivers/crypto/caam/ctrl.c | 130 ++++++++++++++++++++----------------- 1 file changed, 70 insertions(+), 60 deletions(-) diff --git a/drivers/crypto/caam/ctrl.c b/drivers/crypto/caam/ctrl.c index 254963498abc..f8c75a999913 100644 --- a/drivers/crypto/caam/ctrl.c +++ b/drivers/crypto/caam/ctrl.c @@ -175,6 +175,73 @@ static inline int run_descriptor_deco0(struct device *ctrldev, u32 *desc, return 0; } +/* + * deinstantiate_rng - builds and executes a descriptor on DECO0, + * which deinitializes the RNG block. + * @ctrldev - pointer to device + * @state_handle_mask - bitmask containing the instantiation status + * for the RNG4 state handles which exist in + * the RNG4 block: 1 if it's been instantiated + * + * Return: - 0 if no error occurred + * - -ENOMEM if there isn't enough memory to allocate the descriptor + * - -ENODEV if DECO0 couldn't be acquired + * - -EAGAIN if an error occurred when executing the descriptor + */ +static int deinstantiate_rng(struct device *ctrldev, int state_handle_mask) +{ + u32 *desc, status; + int sh_idx, ret = 0; + + desc = kmalloc(CAAM_CMD_SZ * 3, GFP_KERNEL); + if (!desc) + return -ENOMEM; + + for (sh_idx = 0; sh_idx < RNG4_MAX_HANDLES; sh_idx++) { + /* + * If the corresponding bit is set, then it means the state + * handle was initialized by us, and thus it needs to be + * deinitialized as well + */ + if ((1 << sh_idx) & state_handle_mask) { + /* + * Create the descriptor for deinstantating this state + * handle + */ + build_deinstantiation_desc(desc, sh_idx); + + /* Try to run it through DECO0 */ + ret = run_descriptor_deco0(ctrldev, desc, &status); + + if (ret || + (status && status != JRSTA_SSRC_JUMP_HALT_CC)) { + dev_err(ctrldev, + "Failed to deinstantiate RNG4 SH%d\n", + sh_idx); + break; + } + dev_info(ctrldev, "Deinstantiated RNG4 SH%d\n", sh_idx); + } + } + + kfree(desc); + + return ret; +} + +static void devm_deinstantiate_rng(void *data) +{ + struct device *ctrldev = data; + struct caam_drv_private *ctrlpriv = dev_get_drvdata(ctrldev); + + /* + * De-initialize RNG state handles initialized by this driver. + * In case of SoCs with Management Complex, RNG is managed by MC f/w. + */ + if (ctrlpriv->rng4_sh_init) + deinstantiate_rng(ctrldev, ctrlpriv->rng4_sh_init); +} + /* * instantiate_rng - builds and executes a descriptor on DECO0, * which initializes the RNG block. @@ -247,59 +314,9 @@ static int instantiate_rng(struct device *ctrldev, int state_handle_mask, kfree(desc); - return ret; -} - -/* - * deinstantiate_rng - builds and executes a descriptor on DECO0, - * which deinitializes the RNG block. - * @ctrldev - pointer to device - * @state_handle_mask - bitmask containing the instantiation status - * for the RNG4 state handles which exist in - * the RNG4 block: 1 if it's been instantiated - * - * Return: - 0 if no error occurred - * - -ENOMEM if there isn't enough memory to allocate the descriptor - * - -ENODEV if DECO0 couldn't be acquired - * - -EAGAIN if an error occurred when executing the descriptor - */ -static int deinstantiate_rng(struct device *ctrldev, int state_handle_mask) -{ - u32 *desc, status; - int sh_idx, ret = 0; - - desc = kmalloc(CAAM_CMD_SZ * 3, GFP_KERNEL); - if (!desc) - return -ENOMEM; - - for (sh_idx = 0; sh_idx < RNG4_MAX_HANDLES; sh_idx++) { - /* - * If the corresponding bit is set, then it means the state - * handle was initialized by us, and thus it needs to be - * deinitialized as well - */ - if ((1 << sh_idx) & state_handle_mask) { - /* - * Create the descriptor for deinstantating this state - * handle - */ - build_deinstantiation_desc(desc, sh_idx); - - /* Try to run it through DECO0 */ - ret = run_descriptor_deco0(ctrldev, desc, &status); - - if (ret || - (status && status != JRSTA_SSRC_JUMP_HALT_CC)) { - dev_err(ctrldev, - "Failed to deinstantiate RNG4 SH%d\n", - sh_idx); - break; - } - dev_info(ctrldev, "Deinstantiated RNG4 SH%d\n", sh_idx); - } - } - - kfree(desc); + if (!ret) + ret = devm_add_action_or_reset(ctrldev, devm_deinstantiate_rng, + ctrldev); return ret; } @@ -320,13 +337,6 @@ static int caam_remove(struct platform_device *pdev) caam_qi_shutdown(ctrldev); #endif - /* - * De-initialize RNG state handles initialized by this driver. - * In case of SoCs with Management Complex, RNG is managed by MC f/w. - */ - if (!ctrlpriv->mc_en && ctrlpriv->rng4_sh_init) - deinstantiate_rng(ctrldev, ctrlpriv->rng4_sh_init); - return 0; } From patchwork Tue Oct 22 15:30:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 11204719 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AD70014E5 for ; Tue, 22 Oct 2019 15:30:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8187021920 for ; Tue, 22 Oct 2019 15:30:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FV/G6B86" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730720AbfJVPac (ORCPT ); Tue, 22 Oct 2019 11:30:32 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:43881 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732328AbfJVPac (ORCPT ); Tue, 22 Oct 2019 11:30:32 -0400 Received: by mail-pl1-f196.google.com with SMTP id v5so3789554ply.10; Tue, 22 Oct 2019 08:30:31 -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 :mime-version:content-transfer-encoding; bh=Q8gWc5J/oCoXIx5BDQrMSebjO4yMPwjpyADtE3ynQqA=; b=FV/G6B86QblOcvwX8xLacb4A5cbeKWR7XsgcSLGLjZAteBvZD/0DL0QvNXmH9j3X5J KcVxC2u6xjiRFZtAG1KK787z8OhfUBttZddImowWDyFhx+/JFv4uZVjvnsgGuVp4mqGJ SUi9NGCHtAJz7Zo9cM4SAzBw+75cp+XUAkLEbhBXV1xEyqzjbI4vIu7FLOw0T6kcz2MG o/9WSGFwJSWsdVNoaj3SXFsLlj1rCMU4QcKJY6BPJSpKCvAcBmkwg3OksHbfN3Lo8Iut MydDm6CYHalYl2rXK73iiKHI/aVLHtgN+3xVmGRjduzp7p4Wctf3QoH4wrOTX+RPRsoX XS/g== 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:mime-version:content-transfer-encoding; bh=Q8gWc5J/oCoXIx5BDQrMSebjO4yMPwjpyADtE3ynQqA=; b=h4u0goMzzS6/raPgUgWk2b2aToIIUIkOAfXjdQjmFYWkImQMY0jm7F4/aSspieBljp lP7af48d2GRShIk46ohOgETAWYOhTlHb7GD+WVhSJ6XJfB/2Ut1BKsqL3CakwrQ2zX2d uZCGwIk1og7dxBsyXozeqgI2aGQviWG1IurcdeacQ/ERmZJJ/tLsrkZm4hJScRuKhRvF VoxIBgyz7sgdqkiRFS//3v4q/TKtm0irO8gj3CX6zZkSWMvctVUNYfSdiNm3hqoQ3wu7 mKeAJHZgD7wRuv3hFdy5VoHfNJJwZuY70WCnDmx2armi5nFixPhiNMXW2tnI/m9KmE+v GWnQ== X-Gm-Message-State: APjAAAXODA1RcKqbl+kLqUl4s0ehMexxn4969XQ7WUf0lQZZWTWSZKow UW2l/DGI5vIyCLugroiL9/QF/wL+ X-Google-Smtp-Source: APXvYqzYnHFhxF0RHgswSV8/p/C/lR8uqfu8jZjkCrwMYVFhxfr1gz7ora3bFK9GRqDg+9i5LPi5Jg== X-Received: by 2002:a17:902:fe0f:: with SMTP id g15mr1398239plj.224.1571758230500; Tue, 22 Oct 2019 08:30:30 -0700 (PDT) Received: from localhost.lan (c-67-185-54-80.hsd1.wa.comcast.net. [67.185.54.80]) by smtp.gmail.com with ESMTPSA id z63sm6066128pgb.75.2019.10.22.08.30.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2019 08:30:29 -0700 (PDT) From: Andrey Smirnov To: linux-crypto@vger.kernel.org Cc: Andrey Smirnov , =?utf-8?q?Horia_Geant=C4=83?= , Chris Healy , Lucas Stach , Herbert Xu , Iuliana Prodan , linux-kernel@vger.kernel.org Subject: [PATCH v2 4/6] crypto: caam - use devres to de-initialize QI Date: Tue, 22 Oct 2019 08:30:11 -0700 Message-Id: <20191022153013.3692-5-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191022153013.3692-1-andrew.smirnov@gmail.com> References: <20191022153013.3692-1-andrew.smirnov@gmail.com> MIME-Version: 1.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Use devres to de-initialize the QI and drop explicit de-initialization code in caam_remove(). Signed-off-by: Andrey Smirnov Reviewed-by: Horia Geantă Cc: Chris Healy Cc: Lucas Stach Cc: Horia Geantă Cc: Herbert Xu Cc: Iuliana Prodan Cc: linux-crypto@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- drivers/crypto/caam/ctrl.c | 14 +------------- drivers/crypto/caam/intern.h | 3 --- drivers/crypto/caam/qi.c | 8 ++++++-- drivers/crypto/caam/qi.h | 1 - 4 files changed, 7 insertions(+), 19 deletions(-) diff --git a/drivers/crypto/caam/ctrl.c b/drivers/crypto/caam/ctrl.c index f8c75a999913..7cdb48c7e28e 100644 --- a/drivers/crypto/caam/ctrl.c +++ b/drivers/crypto/caam/ctrl.c @@ -332,11 +332,6 @@ static int caam_remove(struct platform_device *pdev) /* Remove platform devices under the crypto node */ of_platform_depopulate(ctrldev); -#ifdef CONFIG_CAAM_QI - if (ctrlpriv->qi_init) - caam_qi_shutdown(ctrldev); -#endif - return 0; } @@ -769,7 +764,7 @@ static int caam_probe(struct platform_device *pdev) ret = of_platform_populate(nprop, caam_match, NULL, dev); if (ret) { dev_err(dev, "JR platform devices creation error\n"); - goto shutdown_qi; + return ret; } ring = 0; @@ -930,13 +925,6 @@ static int caam_probe(struct platform_device *pdev) caam_remove: caam_remove(pdev); return ret; - -shutdown_qi: -#ifdef CONFIG_CAAM_QI - if (ctrlpriv->qi_init) - caam_qi_shutdown(dev); -#endif - return ret; } static struct platform_driver caam_driver = { diff --git a/drivers/crypto/caam/intern.h b/drivers/crypto/caam/intern.h index 359eb76d1259..c7c10c90464b 100644 --- a/drivers/crypto/caam/intern.h +++ b/drivers/crypto/caam/intern.h @@ -81,9 +81,6 @@ struct caam_drv_private { */ u8 total_jobrs; /* Total Job Rings in device */ u8 qi_present; /* Nonzero if QI present in device */ -#ifdef CONFIG_CAAM_QI - u8 qi_init; /* Nonzero if QI has been initialized */ -#endif u8 mc_en; /* Nonzero if MC f/w is active */ int secvio_irq; /* Security violation interrupt number */ int virt_en; /* Virtualization enabled in CAAM */ diff --git a/drivers/crypto/caam/qi.c b/drivers/crypto/caam/qi.c index 378f627e1d64..dacf2fa4aa8e 100644 --- a/drivers/crypto/caam/qi.c +++ b/drivers/crypto/caam/qi.c @@ -500,9 +500,10 @@ void caam_drv_ctx_rel(struct caam_drv_ctx *drv_ctx) } EXPORT_SYMBOL(caam_drv_ctx_rel); -void caam_qi_shutdown(struct device *qidev) +static void caam_qi_shutdown(void *data) { int i; + struct device *qidev = data; struct caam_qi_priv *priv = &qipriv; const cpumask_t *cpus = qman_affine_cpus(); @@ -761,7 +762,10 @@ int caam_qi_init(struct platform_device *caam_pdev) ×_congested, &caam_fops_u64_ro); #endif - ctrlpriv->qi_init = 1; + err = devm_add_action_or_reset(qidev, caam_qi_shutdown, ctrlpriv); + if (err) + return err; + dev_info(qidev, "Linux CAAM Queue I/F driver initialised\n"); return 0; } diff --git a/drivers/crypto/caam/qi.h b/drivers/crypto/caam/qi.h index db0549549e3b..848958951f68 100644 --- a/drivers/crypto/caam/qi.h +++ b/drivers/crypto/caam/qi.h @@ -147,7 +147,6 @@ int caam_drv_ctx_update(struct caam_drv_ctx *drv_ctx, u32 *sh_desc); void caam_drv_ctx_rel(struct caam_drv_ctx *drv_ctx); int caam_qi_init(struct platform_device *pdev); -void caam_qi_shutdown(struct device *dev); /** * qi_cache_alloc - Allocate buffers from CAAM-QI cache From patchwork Tue Oct 22 15:30:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 11204723 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D227113BD for ; Tue, 22 Oct 2019 15:30:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B13BB218AE for ; Tue, 22 Oct 2019 15:30:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="twr9OH5r" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732346AbfJVPam (ORCPT ); Tue, 22 Oct 2019 11:30:42 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:35713 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732338AbfJVPad (ORCPT ); Tue, 22 Oct 2019 11:30:33 -0400 Received: by mail-pf1-f196.google.com with SMTP id 205so10875478pfw.2; Tue, 22 Oct 2019 08:30:33 -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 :mime-version:content-transfer-encoding; bh=a7lQln2Sn3ga5wzLGGjdEAkfx3q9Gt4gdmnzplHbZZI=; b=twr9OH5rmelYAVJxvbLwuEbfW7DorGSn1XUE/WWgYTM5Pz5/NUhgfjcEwsWe/gi5ap 7vzQLwHjKRMT2EnqrEKzYZSRFJdYUeq0wG9rYBF94015ItMyZE5mQDeyHblitcnae1a4 8K6ABiYyV/D4PPVTm8WoQNiCXTHaMNv6Tt3swJN/m42fLW8GbLElQUiO2zQXPeAfIHy2 e7Q2jQycF0btkTzK4W6npQT2gnzyGxUPjVwhr0RgB7N+38e6eugyK0I3vns7oJkOb8G0 SY0VrmGVXmH7kpwKus7qdNWqY0U62XZUpWIgfMmNruNQFTv+g6eeHSwanMxCBNzPPUa1 rK5w== 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:mime-version:content-transfer-encoding; bh=a7lQln2Sn3ga5wzLGGjdEAkfx3q9Gt4gdmnzplHbZZI=; b=V4oCbHcBp1ylHFvWWvxkL6x7FQwnLQX3mQEXzmrE3sV/kP6w0bzvdntnzeLiuL8WpR B9oy+WSy5LkEuQxqsQenn6KkanKgSDK4QO/iKKUVYxpMmHjEkHQ09wNWaOgINRyy26F/ K2DfIIC2vjE2HqnYsDsj6gXDz9eGB5FFa8HiK8s1D7/r35K/z6/IS+6flyebiP3NpTSK 5hSzokDAORx5CbnPT421JLOrPW8ZFjDrorAv0yHTcC4ZcVNADZpslQI08VNaDW51v0+x k/HOtf7nWnxNXLhXdpQB767NTfPt3BzUEbtGglVus0btPIArny4lwjUSgDWGwJ55RfOq YiUQ== X-Gm-Message-State: APjAAAVc5sW9SyhHvIJK5tsX4Q090WxhVG71OFPwD/tVb38p3hyIu7ot VvJqSj8YDXD83cq6cw/KptXhAGbC X-Google-Smtp-Source: APXvYqwNIRFnMtl/3wnDddhjlXRdWZN+1lbNhvkSKUI0M2LaKl6WJKoCqZOiWVk1vLi1BJS85PoAyQ== X-Received: by 2002:a65:504b:: with SMTP id k11mr4451139pgo.13.1571758232064; Tue, 22 Oct 2019 08:30:32 -0700 (PDT) Received: from localhost.lan (c-67-185-54-80.hsd1.wa.comcast.net. [67.185.54.80]) by smtp.gmail.com with ESMTPSA id z63sm6066128pgb.75.2019.10.22.08.30.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2019 08:30:30 -0700 (PDT) From: Andrey Smirnov To: linux-crypto@vger.kernel.org Cc: Andrey Smirnov , =?utf-8?q?Horia_Geant=C4=83?= , Chris Healy , Lucas Stach , Herbert Xu , Iuliana Prodan , linux-kernel@vger.kernel.org Subject: [PATCH v2 5/6] crypto: caam - use devres to populate platform devices Date: Tue, 22 Oct 2019 08:30:12 -0700 Message-Id: <20191022153013.3692-6-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191022153013.3692-1-andrew.smirnov@gmail.com> References: <20191022153013.3692-1-andrew.smirnov@gmail.com> MIME-Version: 1.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Use devres to de-initialize the RNG and drop explicit de-initialization code in caam_remove(). Signed-off-by: Andrey Smirnov Reviewed-by: Horia Geantă Cc: Chris Healy Cc: Lucas Stach Cc: Horia Geantă Cc: Herbert Xu Cc: Iuliana Prodan Cc: linux-crypto@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- drivers/crypto/caam/ctrl.c | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/drivers/crypto/caam/ctrl.c b/drivers/crypto/caam/ctrl.c index 7cdb48c7e28e..0540df59ed8a 100644 --- a/drivers/crypto/caam/ctrl.c +++ b/drivers/crypto/caam/ctrl.c @@ -321,20 +321,6 @@ static int instantiate_rng(struct device *ctrldev, int state_handle_mask, return ret; } -static int caam_remove(struct platform_device *pdev) -{ - struct device *ctrldev; - struct caam_drv_private *ctrlpriv; - - ctrldev = &pdev->dev; - ctrlpriv = dev_get_drvdata(ctrldev); - - /* Remove platform devices under the crypto node */ - of_platform_depopulate(ctrldev); - - return 0; -} - /* * kick_trng - sets the various parameters for enabling the initialization * of the RNG4 block in CAAM @@ -761,7 +747,7 @@ static int caam_probe(struct platform_device *pdev) #endif } - ret = of_platform_populate(nprop, caam_match, NULL, dev); + ret = devm_of_platform_populate(dev); if (ret) { dev_err(dev, "JR platform devices creation error\n"); return ret; @@ -783,8 +769,7 @@ static int caam_probe(struct platform_device *pdev) /* If no QI and no rings specified, quit and go home */ if ((!ctrlpriv->qi_present) && (!ctrlpriv->total_jobrs)) { dev_err(dev, "no queues configured, terminating\n"); - ret = -ENOMEM; - goto caam_remove; + return -ENOMEM; } if (ctrlpriv->era < 10) @@ -847,7 +832,7 @@ static int caam_probe(struct platform_device *pdev) } while ((ret == -EAGAIN) && (ent_delay < RTSDCTL_ENT_DLY_MAX)); if (ret) { dev_err(dev, "failed to instantiate RNG"); - goto caam_remove; + return ret; } /* * Set handles init'ed by this module as the complement of the @@ -921,10 +906,6 @@ static int caam_probe(struct platform_device *pdev) &ctrlpriv->ctl_tdsk_wrap); #endif return 0; - -caam_remove: - caam_remove(pdev); - return ret; } static struct platform_driver caam_driver = { @@ -933,7 +914,6 @@ static struct platform_driver caam_driver = { .of_match_table = caam_match, }, .probe = caam_probe, - .remove = caam_remove, }; module_platform_driver(caam_driver); From patchwork Tue Oct 22 15:30:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 11204721 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CF9C413BD for ; Tue, 22 Oct 2019 15:30:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AE05721920 for ; Tue, 22 Oct 2019 15:30:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="oMhXR7Bx" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731847AbfJVPah (ORCPT ); Tue, 22 Oct 2019 11:30:37 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:44038 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732346AbfJVPae (ORCPT ); Tue, 22 Oct 2019 11:30:34 -0400 Received: by mail-pl1-f194.google.com with SMTP id q15so8510373pll.11; Tue, 22 Oct 2019 08:30:34 -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 :mime-version:content-transfer-encoding; bh=o+sow5wxNZdtv/L0uGDR7GrBdlDuvFkYP55JUcWV34M=; b=oMhXR7BxM2Ef7uaenq8Y+w8nxSXor07S9bnJu8DVA2Zl5nG96lalkKxypLtiy5CmEs ulBbkTKRnZqfjbdE4svnUuiSfe10US5vbqOiJDiyDJOhwIwZ9O9ganX6RfbiBkqpbLpW jFuK52vsgimFBwl/wqz4y94lCxmQP9ilvr+0/OFDTQ7l5CIfrfo06qG186LfRvs9D5hk o+cxmfS3Rvzi7btLBPPKO1aURn0fyP9LI++KpSwmhfjQ2XmgWS96oardbAbobQheF4n0 UaMvehJzs3PKT+Urw0/WQVh61osGgtBCGKc4jzETI3Mfvk+tUQkmj4ynx4X1pGFhpKan M2Gg== 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:mime-version:content-transfer-encoding; bh=o+sow5wxNZdtv/L0uGDR7GrBdlDuvFkYP55JUcWV34M=; b=FpSopeVQTaAQyf22JforAkvWmnImxrkL1PtUcCt+UfOY0cUrDVrVmAr+h6kn3WPzi+ a3S7pUZadFDxEsvAg5iJzKGK7kUxsQT2NgJ2Hg1zLD5jDv+ylI5vAgzR+/bKHdDZbwrY x4ZLRsoPtsI0dCdq8ZLDeGBjNOKRb5BAAETbpKhU36zOUjl19dza2h4MlIf/dRX4CkrO TNScwzO47snFKyBaOm5umaXiaBjSYnsoOx/9FiWgAmxb7Ajk59uqiIxyr7vv+ShfIRQV yXZ1KmRsv42KWuE34PP/izjvM5JW/t1rLz2fCAa3pDYxNvxYsQTDaBZCGb7iDlfzVL2m slsA== X-Gm-Message-State: APjAAAXA2TM1pEVY7t/zmKzwOA5Iq6SB/X2FZAiyjCNiGc7KZ2NRY/4Q V9SNHpISkz6JLKPCSBaE8xSskz88 X-Google-Smtp-Source: APXvYqxbdGkH+W8KITVj9N4GRuKyKEPK0WjwBct1ALh5sHyuWNw33zHFmP9Lyhiiw99eFC1rFlIyRA== X-Received: by 2002:a17:902:7481:: with SMTP id h1mr4368071pll.126.1571758233634; Tue, 22 Oct 2019 08:30:33 -0700 (PDT) Received: from localhost.lan (c-67-185-54-80.hsd1.wa.comcast.net. [67.185.54.80]) by smtp.gmail.com with ESMTPSA id z63sm6066128pgb.75.2019.10.22.08.30.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2019 08:30:32 -0700 (PDT) From: Andrey Smirnov To: linux-crypto@vger.kernel.org Cc: Andrey Smirnov , Chris Healy , Lucas Stach , =?utf-8?q?Horia_Geant=C4=83?= , Herbert Xu , Iuliana Prodan , linux-kernel@vger.kernel.org Subject: [PATCH v2 6/6] crypto: caam - populate platform devices last Date: Tue, 22 Oct 2019 08:30:13 -0700 Message-Id: <20191022153013.3692-7-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191022153013.3692-1-andrew.smirnov@gmail.com> References: <20191022153013.3692-1-andrew.smirnov@gmail.com> MIME-Version: 1.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Move the call to devm_of_platform_populate() at the end of caam_probe(), so we won't try to add any child devices until all of the initialization is finished successfully. Signed-off-by: Andrey Smirnov Cc: Chris Healy Cc: Lucas Stach Cc: Horia Geantă Cc: Herbert Xu Cc: Iuliana Prodan Cc: linux-crypto@vger.kernel.org Cc: linux-kernel@vger.kernel.org Reviewed-by: Horia Geantă --- drivers/crypto/caam/ctrl.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/crypto/caam/ctrl.c b/drivers/crypto/caam/ctrl.c index 0540df59ed8a..d7c3c3805693 100644 --- a/drivers/crypto/caam/ctrl.c +++ b/drivers/crypto/caam/ctrl.c @@ -747,12 +747,6 @@ static int caam_probe(struct platform_device *pdev) #endif } - ret = devm_of_platform_populate(dev); - if (ret) { - dev_err(dev, "JR platform devices creation error\n"); - return ret; - } - ring = 0; for_each_available_child_of_node(nprop, np) if (of_device_is_compatible(np, "fsl,sec-v4.0-job-ring") || @@ -905,7 +899,12 @@ static int caam_probe(struct platform_device *pdev) debugfs_create_blob("tdsk", S_IRUSR | S_IRGRP | S_IROTH, ctrlpriv->ctl, &ctrlpriv->ctl_tdsk_wrap); #endif - return 0; + + ret = devm_of_platform_populate(dev); + if (ret) + dev_err(dev, "JR platform devices creation error\n"); + + return ret; } static struct platform_driver caam_driver = {