From patchwork Sun Mar 26 07:06:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 75023 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp800231vqo; Sun, 26 Mar 2023 00:17:59 -0700 (PDT) X-Google-Smtp-Source: AKy350YQV9E1nZWHA/hB2Qp/oPGDgxVKnRJWo+Gdl4GmszaRyUwvy2/6ykzFTm84dL5Z5Lrgz02y X-Received: by 2002:a17:906:37c8:b0:870:58ae:842e with SMTP id o8-20020a17090637c800b0087058ae842emr8663347ejc.24.1679815078980; Sun, 26 Mar 2023 00:17:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679815078; cv=none; d=google.com; s=arc-20160816; b=Ya0ojm6dpiozPvxbYyypLU2oyIwp7X4W8R48vTALtqSOFgQt8LiIAWaaeN/Fq3MwgZ XbJPku7EBLJbb51xrd9vjvWHn06RPDHKqsuPey/TFivUnqoisChn25IWFOpnDN7ytSRk vT4x4ORy2q6WEucDYBxWqAqZ9upiuyG/s4hmiUDs2Ns6NyD3LpmP5Ob+hlZkaQbBGJdp JcDT1EzwxSzXsD0cOWZ0JD/55bwBstandpDVY+pYkmJLCrEaoXZmXgUg4h3K+XPG0dgt 7WOV8T14dJ6Oh8zJR01PRQCBu1EoE69iUbRAI7fpyc33ar7152uPWfkRXmnF8bxEqgRf q6Fw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=LKrj2piAWlORt5BN9q733Ta4kmQSumeaQkLbz+WUPPI=; b=XsfGAyYYXpiqsVbzei9GySOncl3ueXwfUgbL2bcUv6fJ9K2MrrK6DRbrNG10h2e8wq IKivIoaHk0or7PIRTzCpXVxVy6Hcu5KKBmSJpfTny/s4dG7Fnjbs9ucd+AJGf603H/Qd nGw6Q147c7TRT0nA6lWJz5lkckuSaZ6GzMEUGxInoqj/lqoBAuqv7jgYu0rn/RCRuT0o GGAU1Qg1I0itNw4mih8HMXHT3y+Yo9Ssvkg68dpxECfmgMzztFVUNBdOotVu0ZrUjMFk PNf7BxRXwBrkzSr/aWRma3CfN2pJ7J8gzjJWhdh8CG6UV5KwyNsdVI+WH/a/tnvMcyMx fReQ== 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 q18-20020a170906145200b0092fb40179efsi16493177ejc.733.2023.03.26.00.17.35; Sun, 26 Mar 2023 00:17:58 -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 S230206AbjCZHGy (ORCPT + 99 others); Sun, 26 Mar 2023 03:06:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59704 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229458AbjCZHGv (ORCPT ); Sun, 26 Mar 2023 03:06:51 -0400 Received: from smtp.smtpout.orange.fr (smtp-18.smtpout.orange.fr [80.12.242.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5FD0049F5 for ; Sun, 26 Mar 2023 00:06:50 -0700 (PDT) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id gKSipZ5u2E500gKSmpnFFA; Sun, 26 Mar 2023 09:06:49 +0200 X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sun, 26 Mar 2023 09:06:49 +0200 X-ME-IP: 86.243.2.178 From: Christophe JAILLET To: Vinod Koul Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , dmaengine@vger.kernel.org Subject: [PATCH 2/2] dmaengine: mv_xor_v2: Use some clk_ helper functions to simplify code Date: Sun, 26 Mar 2023 09:06:38 +0200 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: <201170dff832a3c496d125772e10070cd834ebf2.1679814350.git.christophe.jaillet@wanadoo.fr> References: <201170dff832a3c496d125772e10070cd834ebf2.1679814350.git.christophe.jaillet@wanadoo.fr> MIME-Version: 1.0 X-Spam-Status: No, score=-0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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?1761413776469553034?= X-GMAIL-MSGID: =?utf-8?q?1761413776469553034?= Use devm_clk_get_[optional_]enabled() instead of hand writing it. It saves some LoC. Signed-off-by: Christophe JAILLET --- Code could be simplified even further and xor_dev->reg_clk and xor_dev->clk could be removed as well. --- drivers/dma/mv_xor_v2.c | 35 +++++++---------------------------- 1 file changed, 7 insertions(+), 28 deletions(-) diff --git a/drivers/dma/mv_xor_v2.c b/drivers/dma/mv_xor_v2.c index 0991b8265829..cea8aa946f9c 100644 --- a/drivers/dma/mv_xor_v2.c +++ b/drivers/dma/mv_xor_v2.c @@ -739,32 +739,18 @@ static int mv_xor_v2_probe(struct platform_device *pdev) if (ret) return ret; - xor_dev->reg_clk = devm_clk_get(&pdev->dev, "reg"); - if (PTR_ERR(xor_dev->reg_clk) != -ENOENT) { - if (!IS_ERR(xor_dev->reg_clk)) { - ret = clk_prepare_enable(xor_dev->reg_clk); - if (ret) - return ret; - } else { - return PTR_ERR(xor_dev->reg_clk); - } - } + xor_dev->reg_clk = devm_clk_get_optional_enabled(&pdev->dev, "reg"); + if (IS_ERR(xor_dev->reg_clk)) + return PTR_ERR(xor_dev->reg_clk); - xor_dev->clk = devm_clk_get(&pdev->dev, NULL); - if (PTR_ERR(xor_dev->clk) == -EPROBE_DEFER) { - ret = -EPROBE_DEFER; - goto disable_reg_clk; - } - if (!IS_ERR(xor_dev->clk)) { - ret = clk_prepare_enable(xor_dev->clk); - if (ret) - goto disable_reg_clk; - } + xor_dev->clk = devm_clk_get_enabled(&pdev->dev, NULL); + if (IS_ERR(xor_dev->clk)) + return PTR_ERR(xor_dev->clk); ret = platform_msi_domain_alloc_irqs(&pdev->dev, 1, mv_xor_v2_set_msi_msg); if (ret) - goto disable_clk; + return ret; xor_dev->irq = msi_get_virq(&pdev->dev, 0); @@ -866,10 +852,6 @@ static int mv_xor_v2_probe(struct platform_device *pdev) xor_dev->hw_desq_virt, xor_dev->hw_desq); free_msi_irqs: platform_msi_domain_free_irqs(&pdev->dev); -disable_clk: - clk_disable_unprepare(xor_dev->clk); -disable_reg_clk: - clk_disable_unprepare(xor_dev->reg_clk); return ret; } @@ -889,9 +871,6 @@ static int mv_xor_v2_remove(struct platform_device *pdev) tasklet_kill(&xor_dev->irq_tasklet); - clk_disable_unprepare(xor_dev->clk); - clk_disable_unprepare(xor_dev->reg_clk); - return 0; }