From patchwork Sun Mar 26 14:14:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 75081 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp969394vqo; Sun, 26 Mar 2023 07:33:06 -0700 (PDT) X-Google-Smtp-Source: AKy350YDKZixBBfWA4LLBvxoShxCu54nEKYJgUS9/FJX5AyAM4UA4kw3vHoMUWxHecEPW4dOwKi1 X-Received: by 2002:a17:90b:33c7:b0:23d:4ffc:43e with SMTP id lk7-20020a17090b33c700b0023d4ffc043emr8715346pjb.38.1679841185976; Sun, 26 Mar 2023 07:33:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679841185; cv=none; d=google.com; s=arc-20160816; b=xjpOD6cHb767OFP+TJiQ/4Hip6we/UUKAhiqMtG8GdSq8n1dyqgkeQFT1aAmvBiA1/ IbPV1bvyS1dms5Qq9RdoKvpjudCwSmK7Wuq9oOgU4sz/QVCiaXvTk3MuCkOxUqTayVut A+p2T0j3gop+FnHwbjpdzGLB2FevvmdfVhJI4kNPgLpJAjMvTSkztTJ4FLQk0bdqjcXp heMxPvnpw+FpK/Fv65wI5pYHSG3cYxQrI04FsFqWYfBEzyFRrG9WqWYnNd7O+tMF9kZs n4IFhgB4SXLqQGG2ijkjmm3gchElV9ixc8jUYaWCeSeWpU9h0XuBmHSlEkywOS9GnGgS NcmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=ZNR12fyZHLUAechhv2Lx67V6m/EstUVE8bA5W9UmIlQ=; b=DgLa9oIU57RbLuYBQkNJcX9PxLzFhMhJUfzj5Fg5/Ji7zVjU4AuhMHxwHWjo3M2r9r Nng9+YNuOMNZrd0dJ2O6Ufdpx2XKsONzPSdyDKymZeg9UIDRTk0jm+kbG9WHM4jmUIiT 77fvbhP/3m2Ry1WrMXYkDfBmzAYLTjBJf8/zg1xzGR6+O+eTG4DktguGPgGy15E8Nuks tfxbDYMxQ0OD7hs2hcggZu9myRWRTlZqWyrQ7HCzubVw/9w2+yyU5TUWG/dZEwa7WdQF RRts9F7ft3GMimaxxL6l+NxRPie4Zq/D7kCds8ZafljRNkIo0oJK/APsczR2SgX6PkrU xN+Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mr11-20020a17090b238b00b00233773a522esi8381048pjb.49.2023.03.26.07.32.53; Sun, 26 Mar 2023 07:33:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232156AbjCZOOj (ORCPT + 99 others); Sun, 26 Mar 2023 10:14:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232073AbjCZOOh (ORCPT ); Sun, 26 Mar 2023 10:14:37 -0400 Received: from smtp.smtpout.orange.fr (smtp-25.smtpout.orange.fr [80.12.242.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6C871B9 for ; Sun, 26 Mar 2023 07:14:35 -0700 (PDT) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id gR8fpDUyw985CgR8fpq2Ia; Sun, 26 Mar 2023 16:14:34 +0200 X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sun, 26 Mar 2023 16:14:34 +0200 X-ME-IP: 86.243.2.178 From: Christophe JAILLET To: Herbert Xu , "David S. Miller" , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , linux-crypto@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH] crypto: mxs-dcp - Use the devm_clk_get_optional_enabled() helper Date: Sun, 26 Mar 2023 16:14:25 +0200 Message-Id: X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761441151345141382?= X-GMAIL-MSGID: =?utf-8?q?1761441151345141382?= Use devm_clk_get_optional_enabled() instead of hand writing it. This saves some loC and improves the semantic. update the error handling path and the remove function accordingly. Signed-off-by: Christophe JAILLET --- drivers/crypto/mxs-dcp.c | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/drivers/crypto/mxs-dcp.c b/drivers/crypto/mxs-dcp.c index 1c11946a4f0b..f6b7bce0e656 100644 --- a/drivers/crypto/mxs-dcp.c +++ b/drivers/crypto/mxs-dcp.c @@ -1022,21 +1022,15 @@ static int mxs_dcp_probe(struct platform_device *pdev) sdcp->coh = PTR_ALIGN(sdcp->coh, DCP_ALIGNMENT); /* DCP clock is optional, only used on some SOCs */ - sdcp->dcp_clk = devm_clk_get(dev, "dcp"); - if (IS_ERR(sdcp->dcp_clk)) { - if (sdcp->dcp_clk != ERR_PTR(-ENOENT)) - return PTR_ERR(sdcp->dcp_clk); - sdcp->dcp_clk = NULL; - } - ret = clk_prepare_enable(sdcp->dcp_clk); - if (ret) - return ret; + sdcp->dcp_clk = devm_clk_get_optional_enabled(dev, "dcp"); + if (IS_ERR(sdcp->dcp_clk)) + return PTR_ERR(sdcp->dcp_clk); /* Restart the DCP block. */ ret = stmp_reset_block(sdcp->base); if (ret) { dev_err(dev, "Failed reset\n"); - goto err_disable_unprepare_clk; + return ret; } /* Initialize control register. */ @@ -1076,7 +1070,7 @@ static int mxs_dcp_probe(struct platform_device *pdev) if (IS_ERR(sdcp->thread[DCP_CHAN_HASH_SHA])) { dev_err(dev, "Error starting SHA thread!\n"); ret = PTR_ERR(sdcp->thread[DCP_CHAN_HASH_SHA]); - goto err_disable_unprepare_clk; + return ret; } sdcp->thread[DCP_CHAN_CRYPTO] = kthread_run(dcp_chan_thread_aes, @@ -1134,9 +1128,6 @@ static int mxs_dcp_probe(struct platform_device *pdev) err_destroy_sha_thread: kthread_stop(sdcp->thread[DCP_CHAN_HASH_SHA]); -err_disable_unprepare_clk: - clk_disable_unprepare(sdcp->dcp_clk); - return ret; } @@ -1156,8 +1147,6 @@ static int mxs_dcp_remove(struct platform_device *pdev) kthread_stop(sdcp->thread[DCP_CHAN_HASH_SHA]); kthread_stop(sdcp->thread[DCP_CHAN_CRYPTO]); - clk_disable_unprepare(sdcp->dcp_clk); - platform_set_drvdata(pdev, NULL); global_sdcp = NULL;