From patchwork Sat Mar 4 16:56:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 13159971 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B6248C6FA9E for ; Sat, 4 Mar 2023 16:58:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=Jv1qco8mXrrDm5+1cumzSZCDeHdZMct8DQntsmFMEKo=; b=Sej2YGZoTMXe48 AXQWIFiwesxyetuhS5oMeLre6l/WU0aGZj1xfDaed/BgN7b4yNM/HOQk7rtbFTmcVye2w9jvUwqvt dJYKQGrXtGdPw5ULsvz3Jc/pZvpiA+hlI7kOpAABZyx/7yDT6d9CJETisLJiuUexZclpKvSd8JgrC mzteIHi8X6FY4JbQm7f69F4mwGbNBij52TroeNftirPx7uIfZeqBM7MXV39Gr8DMj0J+idl28pdMR I4WKMUw7sfrXpoAzUBLZR+BTZgxVH6pxkCcnS26CYeiwUthm8L6nFLD3oWuTgZSpkrj+jgTURKLxp kLLRqyUT9z/5nS+kOzew==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pYVBx-009Gm6-Ly; Sat, 04 Mar 2023 16:57:05 +0000 Received: from mail-io1-xd33.google.com ([2607:f8b0:4864:20::d33]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pYVBr-009GlW-6Y for linux-arm-kernel@lists.infradead.org; Sat, 04 Mar 2023 16:57:00 +0000 Received: by mail-io1-xd33.google.com with SMTP id b16so2290323iof.11 for ; Sat, 04 Mar 2023 08:56:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1677949016; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:sender:from:to:cc:subject:date:message-id:reply-to; bh=tpSFi8oQ8gJhvBK+1ukBO6QMtwZSSdSaUChPuPzBR3c=; b=Rb4ZNyGKUE3v/LdbeL9momfA58G5zQHoFZ3eElXIlCFDv59pTz9zk/d9GAyQGkyd+N PhlywmLX/4G64ibYGXNPjZlQROv50yG7R3b80N2+nEO6gvMc1e4+z3sBH6G1CErZOorn zwyoKlzOfjfXyTB//5jzMpJuJFWwABEqWhHHW34VxfMVWf1lnYsfSMKjm/Ahr7aXmEaE YOjPpujV00eHUCslDs6BPSBzNHYB1a+lqnf/P8R3eSbmlEN+BND1P69wCfCon0IlZX+x DN/eljo8Q46TqPZkI/9aw8M8/ABKX71fvwr4hdOt7fqFbpxffTWo2Ye1hr8GZz3aTa/L R7kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677949016; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:sender:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=tpSFi8oQ8gJhvBK+1ukBO6QMtwZSSdSaUChPuPzBR3c=; b=HG+njQ61CedhZiay3t91Fnaol5nmWlR6Z7qiWaon5Lv+gPs3XQWKJV1acyAzj/ULdl jfJIAEL+bS3x0ZsegZ8X5ArU+ImDUov9KiW8+ye8NWE9bT1+T8bV98AOFmrEO0KwWMml zmF14dwL4CrqpSYC3snZ58k3WqtjBAVnfGlv4r+k66ujZSz3P7C3cQDdtz8ZyWW+WKpn LClGH7D6C1Ki1W4iQ2pVL+A0QJa95BdShNdcbrg5C4qC8K46gJWeCc55EagQByrrlNW8 QJSFvLa7lxuuc0NrcWX/iqE2nURHpj2ZK55RPDPtu39Sc9hC0+UQoL3Z1S01EF7N24hE IxsQ== X-Gm-Message-State: AO0yUKXV3nazX3je55s6HQpQlwRAvCDyzoXETseeRbBFGJoozx25M/Dj AryPNK2npd2lfGXFZly1GXM= X-Google-Smtp-Source: AK7set83oJcNExK3Eb+T8l1q48j5qW46pOyFnowBwt1rO9/RepcMWvXnXt7Dv94AjLnFOwFjhngDLw== X-Received: by 2002:a6b:c993:0:b0:74c:8f72:291c with SMTP id z141-20020a6bc993000000b0074c8f72291cmr7584839iof.2.1677949016532; Sat, 04 Mar 2023 08:56:56 -0800 (PST) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id f13-20020a5d858d000000b0073f8a470bacsm1672220ioj.16.2023.03.04.08.56.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Mar 2023 08:56:55 -0800 (PST) From: Guenter Roeck To: Krzysztof Kozlowski Cc: Alim Akhtar , Wim Van Sebroeck , linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org, Guenter Roeck , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= Subject: [PATCH 1/2] watchdog: s3c2410_wdt: Use Use devm_clk_get[_optional]_enabled() helpers Date: Sat, 4 Mar 2023 08:56:52 -0800 Message-Id: <20230304165653.2179835-1-linux@roeck-us.net> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230304_085659_286950_05D5BE61 X-CRM114-Status: GOOD ( 17.24 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The devm_clk_get[_optional]_enabled() helpers: - call devm_clk_get[_optional]() - call clk_prepare_enable() and register what is needed in order to call clk_disable_unprepare() when needed, as a managed resource. This simplifies the code and avoids the calls to clk_disable_unprepare(). While at it, use dev_err_probe consistently, and use its return value to return the error code. Cc: Uwe Kleine-König Signed-off-by: Guenter Roeck Reviewed-by: Uwe Kleine-König --- drivers/watchdog/s3c2410_wdt.c | 45 +++++++--------------------------- 1 file changed, 9 insertions(+), 36 deletions(-) diff --git a/drivers/watchdog/s3c2410_wdt.c b/drivers/watchdog/s3c2410_wdt.c index 200ba236a72e..a1fcb79b0b7c 100644 --- a/drivers/watchdog/s3c2410_wdt.c +++ b/drivers/watchdog/s3c2410_wdt.c @@ -661,35 +661,17 @@ static int s3c2410wdt_probe(struct platform_device *pdev) if (IS_ERR(wdt->reg_base)) return PTR_ERR(wdt->reg_base); - wdt->bus_clk = devm_clk_get(dev, "watchdog"); - if (IS_ERR(wdt->bus_clk)) { - dev_err(dev, "failed to find bus clock\n"); - return PTR_ERR(wdt->bus_clk); - } - - ret = clk_prepare_enable(wdt->bus_clk); - if (ret < 0) { - dev_err(dev, "failed to enable bus clock\n"); - return ret; - } + wdt->bus_clk = devm_clk_get_enabled(dev, "watchdog"); + if (IS_ERR(wdt->bus_clk)) + return dev_err_probe(dev, PTR_ERR(wdt->bus_clk), "failed to get bus clock\n"); /* * "watchdog_src" clock is optional; if it's not present -- just skip it * and use "watchdog" clock as both bus and source clock. */ - wdt->src_clk = devm_clk_get_optional(dev, "watchdog_src"); - if (IS_ERR(wdt->src_clk)) { - dev_err_probe(dev, PTR_ERR(wdt->src_clk), - "failed to get source clock\n"); - ret = PTR_ERR(wdt->src_clk); - goto err_bus_clk; - } - - ret = clk_prepare_enable(wdt->src_clk); - if (ret) { - dev_err(dev, "failed to enable source clock\n"); - goto err_bus_clk; - } + wdt->src_clk = devm_clk_get_optional_enabled(dev, "watchdog_src"); + if (IS_ERR(wdt->src_clk)) + return dev_err_probe(dev, PTR_ERR(wdt->src_clk), "failed to get source clock\n"); wdt->wdt_device.min_timeout = 1; wdt->wdt_device.max_timeout = s3c2410wdt_max_timeout(wdt); @@ -710,7 +692,7 @@ static int s3c2410wdt_probe(struct platform_device *pdev) S3C2410_WATCHDOG_DEFAULT_TIME); } else { dev_err(dev, "failed to use default timeout\n"); - goto err_src_clk; + return ret; } } @@ -718,7 +700,7 @@ static int s3c2410wdt_probe(struct platform_device *pdev) pdev->name, pdev); if (ret != 0) { dev_err(dev, "failed to install irq (%d)\n", ret); - goto err_src_clk; + return ret; } watchdog_set_nowayout(&wdt->wdt_device, nowayout); @@ -744,7 +726,7 @@ static int s3c2410wdt_probe(struct platform_device *pdev) ret = watchdog_register_device(&wdt->wdt_device); if (ret) - goto err_src_clk; + return ret; ret = s3c2410wdt_enable(wdt, true); if (ret < 0) @@ -766,12 +748,6 @@ static int s3c2410wdt_probe(struct platform_device *pdev) err_unregister: watchdog_unregister_device(&wdt->wdt_device); - err_src_clk: - clk_disable_unprepare(wdt->src_clk); - - err_bus_clk: - clk_disable_unprepare(wdt->bus_clk); - return ret; } @@ -786,9 +762,6 @@ static int s3c2410wdt_remove(struct platform_device *dev) watchdog_unregister_device(&wdt->wdt_device); - clk_disable_unprepare(wdt->src_clk); - clk_disable_unprepare(wdt->bus_clk); - return 0; }