From patchwork Wed Apr 26 06:52:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 87644 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp53146vqo; Wed, 26 Apr 2023 00:06:09 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6BLlOclaRvRtjtF9FO7C8lcyPnn1b8rV79KbBg9sOXAYAx+AxYX4jti/2Yh43+oUcck+QK X-Received: by 2002:a05:6a20:8401:b0:f6:d60d:dbc2 with SMTP id c1-20020a056a20840100b000f6d60ddbc2mr2575704pzd.28.1682492769391; Wed, 26 Apr 2023 00:06:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682492769; cv=none; d=google.com; s=arc-20160816; b=zMxbM8tG3pmloI6pp6q3V2tCFUUFglLjT4c/JHZD7ypYOtUrzB82nICjk7KBUYH/Fq 1UWqWZEUegTdfKrbCX3/FdRHezTJKnPO6rmRr1vUGmDXBsAYcCMnVGFGKZaglKKcvCtL rPxJwXWIf+tiFKg6qqbuiE6vf6BdERIJv+dEggjmOJl27aWIDkmZRC04UbDWglBVf0Cv 1k37YI3Y9kctMjck4hI4CiqodD5TFS3Iir6ZmOjYgvIEVqInD73x/VSHkWJ2/HhF95pm uCiplkzekEZeJrYpwhnIFOhmZ+sbTfKIyrqis0wUITVDYJ/uySeMfiXCBeATNs6ERvpv vJOg== 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:dkim-signature; bh=KAtKMyZd7naxOW+Rdd07F5idduJev/3DNob3RYZOyX4=; b=raEHy9WL+WT8aQjB2kaE2G1oWVTjdFV2vKcw4pmV2pcIlFSonY3bg/f9Lnj2P5UKwh w/Z9o69Qv0n/KKmbsflbnWwPeC4dqJ/ewwZI4Wrp63UGvFkoUQNUgCf3NWdVkCE/qN3D pQKRJU+cPRaukdB/7hjoRpc4zFwMKNEkCmGEtLF2EnM3nyIOm3jxk1akdDAmEKnonkGe SXXN5jvsfc/0AldcBpFp+9zVPKuy5z/eTF/8x7d13G8XaR0zxnxYm4GLPgSv0yX6+Mfj OQELythPL7eE060L2jAQDEvLZMdee3MDg1jJ4gvP7iY2Jw7fIQrY/Z/P58IrRAhUK3Ml vBJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=jtcYJmJz; 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 c19-20020a621c13000000b0063b8b114678si15526919pfc.393.2023.04.26.00.05.55; Wed, 26 Apr 2023 00:06:09 -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; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=jtcYJmJz; 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 S239544AbjDZGxX (ORCPT + 99 others); Wed, 26 Apr 2023 02:53:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239361AbjDZGxU (ORCPT ); Wed, 26 Apr 2023 02:53:20 -0400 Received: from smtp.smtpout.orange.fr (smtp-22.smtpout.orange.fr [80.12.242.22]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B23230C1 for ; Tue, 25 Apr 2023 23:53:07 -0700 (PDT) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id rZ1RpwxQZMX1TrZ1Rpoi5U; Wed, 26 Apr 2023 08:53:05 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1682491985; bh=KAtKMyZd7naxOW+Rdd07F5idduJev/3DNob3RYZOyX4=; h=From:To:Cc:Subject:Date; b=jtcYJmJzwcQembazxEh1mO1fWZlBgEiuhDv3/vLwH2iUAI4V/z95jF5L9LY4f9NZv si+K/7yFFq3Q40CA0IXnCQRaFpeWL0E9oZayGh/WBL8PnmOIk/HkBeeXiDRZNCUfK+ 7/tw9+Zg/0wISwhCG+qE2ANsbfBthzZBFAnOfbfUqPCW4k9TAGqS0lLye2TOg1c5YF KnaFAweV5CYgYxr9brt301VM67gBl5aJIzr7fwHvKizLctjMwJRrj4ivokDlbm6Vxc 4HIYWw564uGM0GJnlMve910B3V9GiDm/8CbePGw7nLbAuxA1GtndlpvqT80urrAdD1 L99XAbt5Z8CYw== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Wed, 26 Apr 2023 08:53:05 +0200 X-ME-IP: 86.243.2.178 From: Christophe JAILLET To: Wim Van Sebroeck , Guenter Roeck , Philipp Zabel , Steffen Trumtrar Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , Wim Van Sebroeck , linux-watchdog@vger.kernel.org Subject: [PATCH 1/2] watchdog: dw_wdt: Fix the error handling path of dw_wdt_drv_probe() Date: Wed, 26 Apr 2023 08:52:48 +0200 Message-Id: X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE 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?1764221538195000459?= X-GMAIL-MSGID: =?utf-8?q?1764221538195000459?= The commit in Fixes has only updated the remove function and missed the error handling path of the probe. Add the missing reset_control_assert() call. Fixes: 65a3b6935d92 ("watchdog: dw_wdt: get reset lines from dt") Signed-off-by: Christophe JAILLET Reviewed-by: Philipp Zabel Reviewed-by: Guenter Roeck --- drivers/watchdog/dw_wdt.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/watchdog/dw_wdt.c b/drivers/watchdog/dw_wdt.c index 6f88bd81f8a1..a1354a59eb37 100644 --- a/drivers/watchdog/dw_wdt.c +++ b/drivers/watchdog/dw_wdt.c @@ -635,7 +635,7 @@ static int dw_wdt_drv_probe(struct platform_device *pdev) ret = dw_wdt_init_timeouts(dw_wdt, dev); if (ret) - goto out_disable_clk; + goto out_assert_rst; wdd = &dw_wdt->wdd; wdd->ops = &dw_wdt_ops; @@ -667,12 +667,15 @@ static int dw_wdt_drv_probe(struct platform_device *pdev) ret = watchdog_register_device(wdd); if (ret) - goto out_disable_pclk; + goto out_assert_rst; dw_wdt_dbgfs_init(dw_wdt); return 0; +out_assert_rst: + reset_control_assert(dw_wdt->rst); + out_disable_pclk: clk_disable_unprepare(dw_wdt->pclk); From patchwork Wed Apr 26 06:52:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 87639 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp50394vqo; Wed, 26 Apr 2023 00:00:48 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6SzAchwGc7hB/M1zcJhzujgW5GtP9UH1Gs1kI4jHts6tPShyrw0psB5V2aQ26oRFz3hbkA X-Received: by 2002:aa7:8608:0:b0:63b:7bab:26ff with SMTP id p8-20020aa78608000000b0063b7bab26ffmr1560425pfn.16.1682492447899; Wed, 26 Apr 2023 00:00:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682492447; cv=none; d=google.com; s=arc-20160816; b=DOpvPG2jWJ19HPkvLqzcRDFi9YZBLVgBhXuAH7pLDQTHUku4J+y2eaQhp8CANJIgRz RjtZQkugnlJi40b3hSbPn4p8HpKWVrvTsRsEzMay8lbJHcy72M2RD0SfD5ax0meKTUqr Li4/+PYsfx68Rtu4zg5i9p9spB/huadYcqt6FAP4z9WKnL1J8Ynu9+hRAeQGzwIcko1K szfS/kgZkbNrcXixoSykn0IiMrOURN8PwyvjRkx38pKBOW9ZJm43QBm+WcdNzxoYDE16 jwGJ5YAqb/Vqb9cxwo4p/fYTtQiQizPM0UqAEczcdJhhhMnOjBP2nWR6XtrWgVk7Ul8J 9s0w== 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 :dkim-signature; bh=1oZNVU72onEvSJlf/nOroZTsWdZQ0dSMk+VCwOmUX5M=; b=bxbsIdJZQUBF+QdINckuUY+jfOWH2/jyrrSvkdLC0gRXKQ7MM2KL8ozlTlwZVGpQSB YpdiGYa6+n/PT4d1YlOt9QnnYHDMToL5h0iy9K+f7LbCoORRgS9faiKpMgJXZqiRW9FG Chfy01T9xneGNqnNMZiyUv87PcT0U6IUuIBeIYT3OwdFQ+kgeyi9tsIjFfcTBXXGKgXV g609GIRApUISrbsEZB0r7SKH59KwhT5nuXEbGpiU87Rl+7FMCe/m7HpOFPHljyPP2pki Y0IOS6jX2wed7ckXxo7eNW5snQ98TOJEA1qqG1HGafRCTWzncjpCzcd9NLLVRUKqE9ak MW7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=bcamRcTY; 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 i24-20020a63e458000000b00502e7159b0fsi16093404pgk.175.2023.04.26.00.00.32; Wed, 26 Apr 2023 00:00:47 -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; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=bcamRcTY; 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 S239572AbjDZGxZ (ORCPT + 99 others); Wed, 26 Apr 2023 02:53:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239463AbjDZGxV (ORCPT ); Wed, 26 Apr 2023 02:53:21 -0400 Received: from smtp.smtpout.orange.fr (smtp-21.smtpout.orange.fr [80.12.242.21]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 678F730EC for ; Tue, 25 Apr 2023 23:53:12 -0700 (PDT) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id rZ1RpwxQZMX1TrZ1apoi7l; Wed, 26 Apr 2023 08:53:11 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1682491991; bh=1oZNVU72onEvSJlf/nOroZTsWdZQ0dSMk+VCwOmUX5M=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=bcamRcTYVPndFoKl1kVcGFPLlxC2EWR4gMfWdK2XWNXPos8dELczxHav2CKTgNg5f kuSImMQ7ExiyItxpHLpWUxvPdsb9Ei8OBmqA0MisQOcfyeLGtFHvH459Q2tOHdwgPM m9LteJ9Gb8lCVvjfC7CyhMwFc+7n6bFbH6q7Hc+PbRnXauohEOncx5smMN4fIsFkk8 bAfXWs90p7aTLR5fOUK3kcltxU1KJW+Lhq57fsFJm8QeAP6b5jOTu0jmivpdq8Oy/w 4tcsMzGU2yXx6HV4NawaUFkdzdKgj4HNDvCwhW2HnDcfvwYz/N95w2CKfFGtXcyI1/ 8qDNcPo2sexSg== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Wed, 26 Apr 2023 08:53:11 +0200 X-ME-IP: 86.243.2.178 From: Christophe JAILLET To: Wim Van Sebroeck , Guenter Roeck Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , linux-watchdog@vger.kernel.org Subject: [PATCH 2/2] watchdog: dw_wdt: Simplify clk management Date: Wed, 26 Apr 2023 08:52:49 +0200 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham 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?1764221201248547683?= X-GMAIL-MSGID: =?utf-8?q?1764221201248547683?= Use devm_clk_get_enabled() instead of hand-writing it. This saves some LoC. Signed-off-by: Christophe JAILLET Reviewed-by: Guenter Roeck --- This change the order the resources will be released, so review with care. --- drivers/watchdog/dw_wdt.c | 44 ++++++++++----------------------------- 1 file changed, 11 insertions(+), 33 deletions(-) diff --git a/drivers/watchdog/dw_wdt.c b/drivers/watchdog/dw_wdt.c index a1354a59eb37..84dca3695f86 100644 --- a/drivers/watchdog/dw_wdt.c +++ b/drivers/watchdog/dw_wdt.c @@ -566,22 +566,16 @@ static int dw_wdt_drv_probe(struct platform_device *pdev) * to the common timer/bus clocks configuration, in which the very * first found clock supply both timer and APB signals. */ - dw_wdt->clk = devm_clk_get(dev, "tclk"); + dw_wdt->clk = devm_clk_get_enabled(dev, "tclk"); if (IS_ERR(dw_wdt->clk)) { - dw_wdt->clk = devm_clk_get(dev, NULL); + dw_wdt->clk = devm_clk_get_enabled(dev, NULL); if (IS_ERR(dw_wdt->clk)) return PTR_ERR(dw_wdt->clk); } - ret = clk_prepare_enable(dw_wdt->clk); - if (ret) - return ret; - dw_wdt->rate = clk_get_rate(dw_wdt->clk); - if (dw_wdt->rate == 0) { - ret = -EINVAL; - goto out_disable_clk; - } + if (dw_wdt->rate == 0) + return -EINVAL; /* * Request APB clock if device is configured with async clocks mode. @@ -590,21 +584,13 @@ static int dw_wdt_drv_probe(struct platform_device *pdev) * so the pclk phandle reference is left optional. If it couldn't be * found we consider the device configured in synchronous clocks mode. */ - dw_wdt->pclk = devm_clk_get_optional(dev, "pclk"); - if (IS_ERR(dw_wdt->pclk)) { - ret = PTR_ERR(dw_wdt->pclk); - goto out_disable_clk; - } - - ret = clk_prepare_enable(dw_wdt->pclk); - if (ret) - goto out_disable_clk; + dw_wdt->pclk = devm_clk_get_optional_enabled(dev, "pclk"); + if (IS_ERR(dw_wdt->pclk)) + return PTR_ERR(dw_wdt->pclk); dw_wdt->rst = devm_reset_control_get_optional_shared(&pdev->dev, NULL); - if (IS_ERR(dw_wdt->rst)) { - ret = PTR_ERR(dw_wdt->rst); - goto out_disable_pclk; - } + if (IS_ERR(dw_wdt->rst)) + return PTR_ERR(dw_wdt->rst); /* Enable normal reset without pre-timeout by default. */ dw_wdt_update_mode(dw_wdt, DW_WDT_RMOD_RESET); @@ -621,12 +607,12 @@ static int dw_wdt_drv_probe(struct platform_device *pdev) IRQF_SHARED | IRQF_TRIGGER_RISING, pdev->name, dw_wdt); if (ret) - goto out_disable_pclk; + return ret; dw_wdt->wdd.info = &dw_wdt_pt_ident; } else { if (ret == -EPROBE_DEFER) - goto out_disable_pclk; + return ret; dw_wdt->wdd.info = &dw_wdt_ident; } @@ -675,12 +661,6 @@ static int dw_wdt_drv_probe(struct platform_device *pdev) out_assert_rst: reset_control_assert(dw_wdt->rst); - -out_disable_pclk: - clk_disable_unprepare(dw_wdt->pclk); - -out_disable_clk: - clk_disable_unprepare(dw_wdt->clk); return ret; } @@ -692,8 +672,6 @@ static void dw_wdt_drv_remove(struct platform_device *pdev) watchdog_unregister_device(&dw_wdt->wdd); reset_control_assert(dw_wdt->rst); - clk_disable_unprepare(dw_wdt->pclk); - clk_disable_unprepare(dw_wdt->clk); } #ifdef CONFIG_OF