From patchwork Fri Aug 23 09:42:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chunhai Guo X-Patchwork-Id: 821821 Received: from HK2PR02CU002.outbound.protection.outlook.com (mail-eastasiaazon11010050.outbound.protection.outlook.com [52.101.128.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A6CCA20DF4 for ; Fri, 23 Aug 2024 09:31:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.128.50 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724405490; cv=fail; b=lBVas7fcjwuf/0x+SbiBEAJLOQo+MUYVb8r+prJvqRZaH6dcswsv3cq9WWTWl63O9rQGY5Cw/lyXXiYab0Ha4opVzj/N+Qdz+dNMwrQh7TI5BnROZ/1GpdamQoZ2zbTQbn96hWCcCV6WYeaQNDDYQpynCT5oAHYEEfEkMrg7S0I= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724405490; c=relaxed/simple; bh=vMVgDyfnsGDNwFJQYC6/vkj4TrQYDAQyEJ8qX32n1hA=; h=From:To:Cc:Subject:Date:Message-Id:Content-Type:MIME-Version; b=EyfL6NJICCxvKP4rVsb6D4XblB9/3WQBQyjIeaLUreZ6WcJryKPD2ZYkjzCdgW5qwh6Jzyitx+PCR/Utm2qw/rdylEZIxSuUf+/HUyk5GkBZ3KVJ3qfNzhsZmyQPsKC4wh+GFC4APklHDPX36SjX9J2GjeRUIk+etFTrRXiaZfg= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=vivo.com; spf=pass smtp.mailfrom=vivo.com; dkim=pass (2048-bit key) header.d=vivo.com header.i=@vivo.com header.b=mH7m6WEN; arc=fail smtp.client-ip=52.101.128.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=vivo.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=vivo.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=vivo.com header.i=@vivo.com header.b="mH7m6WEN" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=kBOKb9IwShNaij0KykzWkQFN27d/CScTiP0qKJfGyTZf/QIhCZcnzITEPLVwopuSc/yrF4rzZ0wmUqsI0eELLcGuApGBELUdTpdxH1zvY6uON9gZncwegWoSCJzH8DjBQrSZV9ufoMmecUzVJjx29W24yebLXgMxn7VGnLgvWj+HOIt+RFyfJcpi5UmKQHuHSU1BsZ0PT1Tr5ZVigBVAHL7M8JU0I7pp4OPDzdG/7D0QJGsXUce0eu0sJeV9L0HTD8yY3+VN+oE/ny3QppylIWcdoLynS9uUc3OgIGAwwJ1ZOiREwvwZhBywihtISfu0Q7sHyD32Hd6dghGH3OgZJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=z1PkD//2I0dSgC9mpWBmnyqEBXBh5wEztLwUBnq7ahU=; b=gxzuUNmxFK6mlMIVPNzfva0ViXFJGBW/iSnb69d36azE8Mdy6Jr6xaJ7Cc8Qh0VswrSxfljCuIe2mBf/QdXhdFKvJmGsOigkG4oiRntKTcBJLubTNKbbMTxQ8rEpAH7J2hkpREcpRiOwS9jUHXEu5faEh5ovMvVGjt8noMzWggEncwPJdd9ksUQqC+gRaduyZ2FunsBzlMUkF/fbCdAV4s+kNnT53INKtgzoYdeZVZ5+P/rJz/XoRGdie6q9u35RddYzgdn10TcgwYQb1C/8/7wWfPU3IGMircNFBawwh92FxSHp64c7QcvfBYSfT0cDpgrStzih4BlzB+lEaKWIkQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vivo.com; dmarc=pass action=none header.from=vivo.com; dkim=pass header.d=vivo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vivo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=z1PkD//2I0dSgC9mpWBmnyqEBXBh5wEztLwUBnq7ahU=; b=mH7m6WENrD6HeUuTH4c2WrO2C7fRLgcosHOwuH8hZBBq/dvfJTvYKYoUogvft/7BjMt2a/IE66cIPIXeUtXt7bS9hgjji6Hj71aleg1MDox46tjsXa4Nj+7MrNf4kJgeLHyPt3jiNe4xxvPOFopXQmZ4AgXrIvkWZuRcSZf/f5AdJ/RXIaLNcK4t2QopKHAwxKvresQvJTRTJ4Xhq3rEQIpYOmvUISKaBuhtkY7IibR1w2BJPuHbFHSmozxukbE8XLI64h1djqnxJfNXToteBfRVlCVEGpq2MK2VXvdfYC1JlHFPfx+g/M7xPYgqoG5O9kxYGuTcTwc5GZINZFMp9Q== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vivo.com; Received: from TYZPR06MB7096.apcprd06.prod.outlook.com (2603:1096:405:b5::13) by TYZPR06MB6639.apcprd06.prod.outlook.com (2603:1096:400:45b::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7875.21; Fri, 23 Aug 2024 09:31:25 +0000 Received: from TYZPR06MB7096.apcprd06.prod.outlook.com ([fe80::6c3a:9f76:c4a5:c2b]) by TYZPR06MB7096.apcprd06.prod.outlook.com ([fe80::6c3a:9f76:c4a5:c2b%5]) with mapi id 15.20.7897.014; Fri, 23 Aug 2024 09:31:25 +0000 From: Chunhai Guo To: herbert@gondor.apana.org.au, davem@davemloft.net Cc: nicolas.ferre@microchip.com, alexandre.belloni@bootlin.com, claudiu.beznea@tuxon.dev, linux-crypto@vger.kernel.org, Chunhai Guo Subject: [PATCH] crypto: atmel-{aes, sha} - use devm_clk_get_prepared() helpers Date: Fri, 23 Aug 2024 03:42:49 -0600 Message-Id: <20240823094249.2172979-1-guochunhai@vivo.com> X-Mailer: git-send-email 2.25.1 X-ClientProxiedBy: SI1PR02CA0055.apcprd02.prod.outlook.com (2603:1096:4:1f5::16) To TYZPR06MB7096.apcprd06.prod.outlook.com (2603:1096:405:b5::13) Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYZPR06MB7096:EE_|TYZPR06MB6639:EE_ X-MS-Office365-Filtering-Correlation-Id: a467c8e9-ae8d-4cae-4dcc-08dcc3565bd2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|52116014|376014|1800799024|366016|38350700014; X-Microsoft-Antispam-Message-Info: b8ZWWImKrX/ZHMWA3elxN9lHAYOQYf79zSfDrWY5HFGqTgdvxSwBW2PpoW9kr4qS+4eSymDzzAmh1bFMB2XuONFp4EdCsGo4s3It0fCDowGLbs8CWe3mBzcff9ptBbKJt6lmUSc2OBhODpMhDoVoJlCr7/otda6rbPGV1uNBhB8jT04yny+9FJbt2cqVZkAs3VhaMD5TVDL88hHXTDqHgD17uY6cRn60VJ/etb1GECE65IU2h8pNNqcPMtQ1IMHxB4I+bJJwsPTMCT8rr+zlmY4dTjQY9P5yr4HvrKcqdtfyIVgxV6f/gpLnU1EL6vHCO7MpxJt27fox88D4ttRJlp/dWa5COYyrWGpSQsiKdCUxseIq4FJJbdYbjGb/H/MXHHbfUk6tI5rpqMgqant8h0WESjywD7bf+u2pgl9+jNxiW/p7a/sNZCg0XeseL0rbM3Wna6jPCTkpfrS6tX5IJ3kcihVI+xFaLP1I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014)(376014)(1800799024)(366016)(38350700014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: WiRA8pZDji/GceXW6ep9PMqOsiX5ZkMgYmFH+JYm6KSJ0gOM9dqFtvgFpEI5AXQcoC3kTvY1a2fRPb7Kw/f9BgBIU2Vr4N98JQq59JNkfgQEx8y/E8laqm34nYV0TGnwjA0twRtQz4cqPX6ce45cVS5WDBNhLUgvTp+yAO4mYEH7qh/coPcefccy391f1e5NnFCv9O+va52NY4tdv2A8MM8bBeTEaBBP+iOXu6CvDGVRwn/I7lOAr6f41DWF9Jsf8EdMlLe0lFjNDpYT9hxHnFRb/qsHw6KlWkncSlMB8CY15fs0buyqHVnwGhjsifvnM3pIThRxhVpjVNcMhnTWxYF4GhB7xws2L07mSX6vFxKbvWFF7AUkrP6MaIYW3WGSB/iSYEDX9yzR4JPjYm7jkFmw/WfYQocR3AzNeaSykhamhtw6FCTxE6q2ocN4aRTCYWZ5oSbLqS1seBN0IL2N1HQHWfYJMgJSaD6bNvltNBrF8ZmcZOVFsY18KTeUPdGFEgl0tOHhqZxKGYavVKE2bUycwwNCs5c2X23GM03OrNY+fNKqzBLvXlkKsw+sdy+kXeV9ikjbnaegYccCBnlsNplc5Rq/cbpoCoQTgOsMk4Ip2R4Cvr3WiiKn4Ivqz7fgVSXyXCUgUxZ6FPlXaZnqgRKDri7jFMtHyTBMoa0fKJx1OdX3i1fO3hz3k6fVAZw22LsL9JO2suBx4qPSGGcVzNIBLGMcoLguyAeAJ7r3pVlNh0sWwliylXq0830WjuIPIYYTREWoWQI7pQGBjqKDUS6clnuua6oFg2zuHCii4eDMC8jt18H6ykgrOi7ajna4uf3iqWFHPkflDZJ0hDdLfx9fwrdWoki3TZ4K61BbwJraCpOod1vyON16b08NESKGTSChrKCCvXVqmdcdjsL8R4UG3xJ0kARLAaBRSzii8Ow22YJCWA5lbcehsnbD41QRJktWNsjVPt3Oxls33ulRnavzwChIlp7ABsyMdBcIshDoN/UOfQ39sp01eIf+oUyYGCZvMrp53mXpRh0+9oZYkyaSGpfKZR2XymCKx3QYxa/RWmjjBz6bkHm/SbDQlJLTYnj6QsymwGne4LYqjNfekY2bG20Nhv1wa/6v5Wyn+3YpL9qjWOWhl7DuKDzWBAAkCIgKnPTbkGcYXaf8nigKQlK7G5pU4z7s5JTwI6KVQL+VNXhL4l6wwPBmiSzzJnd0D8rd1cCwX1LP4gVIdi96OKTirWBzXVW+5RcLOkTlo8YEL6OzJoggRuD2h67klWroYW5R3nD5W+fgLXyFOCeTPD3Eh+PUGCVtbBMRJ5uriouWxILIOeb81NKv8epRObux1NZBWz4yFxARcmzG5c2TuG3Qx01lgu5+ZFScbgJqidmtz05RFCVIQnS2nHa35XWMqx3EJ0wQ7TBaNzqQQDzcA4NoCtapFNi54o/lhMW0d593yjTGvuSMzAwzLbXXQ9TW6x1M+R0RqvZ7czxjG2NGr3FcIilKI82chTHgKJ+3ZE51+8784cISht0wWanUEE4j/TX5NNJ1tdeI5ClP4beQGrfY1mknP2omMeowor6zMqHib5/WCFm6Q0Q84BlYuhzg X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: a467c8e9-ae8d-4cae-4dcc-08dcc3565bd2 X-MS-Exchange-CrossTenant-AuthSource: TYZPR06MB7096.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Aug 2024 09:31:25.6057 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 923e42dc-48d5-4cbe-b582-1a797a6412ed X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 0dWPbfY92QB7uv+j6aDeoW8dR+h+I2FnV9s1KEhVCtO5Tym+ZcoVlEywaEdqxfN9aBt1xk01B3U/+ft/y1yFyQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYZPR06MB6639 Simplify the code by replacing devm_clk_get() and clk_prepare() with devm_clk_get_prepared(), which also avoids the call to clk_unprepare(). Signed-off-by: Chunhai Guo --- drivers/crypto/atmel-aes.c | 16 ++++------------ drivers/crypto/atmel-sha.c | 14 +++----------- 2 files changed, 7 insertions(+), 23 deletions(-) diff --git a/drivers/crypto/atmel-aes.c b/drivers/crypto/atmel-aes.c index 8bd64fc37e75..0dd90785db9a 100644 --- a/drivers/crypto/atmel-aes.c +++ b/drivers/crypto/atmel-aes.c @@ -2376,33 +2376,29 @@ static int atmel_aes_probe(struct platform_device *pdev) } /* Initializing the clock */ - aes_dd->iclk = devm_clk_get(&pdev->dev, "aes_clk"); + aes_dd->iclk = devm_clk_get_prepared(&pdev->dev, "aes_clk"); if (IS_ERR(aes_dd->iclk)) { dev_err(dev, "clock initialization failed.\n"); err = PTR_ERR(aes_dd->iclk); goto err_tasklet_kill; } - err = clk_prepare(aes_dd->iclk); - if (err) - goto err_tasklet_kill; - err = atmel_aes_hw_version_init(aes_dd); if (err) - goto err_iclk_unprepare; + goto err_tasklet_kill; atmel_aes_get_cap(aes_dd); #if IS_ENABLED(CONFIG_CRYPTO_DEV_ATMEL_AUTHENC) if (aes_dd->caps.has_authenc && !atmel_sha_authenc_is_ready()) { err = -EPROBE_DEFER; - goto err_iclk_unprepare; + goto err_tasklet_kill; } #endif err = atmel_aes_buff_init(aes_dd); if (err) - goto err_iclk_unprepare; + goto err_tasklet_kill; err = atmel_aes_dma_init(aes_dd); if (err) @@ -2429,8 +2425,6 @@ static int atmel_aes_probe(struct platform_device *pdev) atmel_aes_dma_cleanup(aes_dd); err_buff_cleanup: atmel_aes_buff_cleanup(aes_dd); -err_iclk_unprepare: - clk_unprepare(aes_dd->iclk); err_tasklet_kill: tasklet_kill(&aes_dd->done_task); tasklet_kill(&aes_dd->queue_task); @@ -2455,8 +2449,6 @@ static void atmel_aes_remove(struct platform_device *pdev) atmel_aes_dma_cleanup(aes_dd); atmel_aes_buff_cleanup(aes_dd); - - clk_unprepare(aes_dd->iclk); } static struct platform_driver atmel_aes_driver = { diff --git a/drivers/crypto/atmel-sha.c b/drivers/crypto/atmel-sha.c index f4cd6158a4f7..8cc57df25778 100644 --- a/drivers/crypto/atmel-sha.c +++ b/drivers/crypto/atmel-sha.c @@ -2623,27 +2623,23 @@ static int atmel_sha_probe(struct platform_device *pdev) } /* Initializing the clock */ - sha_dd->iclk = devm_clk_get(&pdev->dev, "sha_clk"); + sha_dd->iclk = devm_clk_get_prepared(&pdev->dev, "sha_clk"); if (IS_ERR(sha_dd->iclk)) { dev_err(dev, "clock initialization failed.\n"); err = PTR_ERR(sha_dd->iclk); goto err_tasklet_kill; } - err = clk_prepare(sha_dd->iclk); - if (err) - goto err_tasklet_kill; - err = atmel_sha_hw_version_init(sha_dd); if (err) - goto err_iclk_unprepare; + goto err_tasklet_kill; atmel_sha_get_cap(sha_dd); if (sha_dd->caps.has_dma) { err = atmel_sha_dma_init(sha_dd); if (err) - goto err_iclk_unprepare; + goto err_tasklet_kill; dev_info(dev, "using %s for DMA transfers\n", dma_chan_name(sha_dd->dma_lch_in.chan)); @@ -2669,8 +2665,6 @@ static int atmel_sha_probe(struct platform_device *pdev) spin_unlock(&atmel_sha.lock); if (sha_dd->caps.has_dma) atmel_sha_dma_cleanup(sha_dd); -err_iclk_unprepare: - clk_unprepare(sha_dd->iclk); err_tasklet_kill: tasklet_kill(&sha_dd->queue_task); tasklet_kill(&sha_dd->done_task); @@ -2693,8 +2687,6 @@ static void atmel_sha_remove(struct platform_device *pdev) if (sha_dd->caps.has_dma) atmel_sha_dma_cleanup(sha_dd); - - clk_unprepare(sha_dd->iclk); } static struct platform_driver atmel_sha_driver = {