From patchwork Wed Feb 23 16:00:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 545854 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 55189C433EF for ; Wed, 23 Feb 2022 16:06:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235779AbiBWQGq (ORCPT ); Wed, 23 Feb 2022 11:06:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239208AbiBWQGp (ORCPT ); Wed, 23 Feb 2022 11:06:45 -0500 Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id AF888C4849 for ; Wed, 23 Feb 2022 08:06:17 -0800 (PST) X-IronPort-AV: E=Sophos;i="5.88,391,1635174000"; d="scan'208";a="111356432" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie5.idc.renesas.com with ESMTP; 24 Feb 2022 01:01:15 +0900 Received: from localhost.localdomain (unknown [10.226.93.140]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id 5D7934004923; Thu, 24 Feb 2022 01:01:13 +0900 (JST) From: Biju Das To: Wim Van Sebroeck , Guenter Roeck , Philipp Zabel Cc: Biju Das , linux-watchdog@vger.kernel.org, Geert Uytterhoeven , Chris Paterson , Biju Das , Prabhakar Mahadev Lad , linux-renesas-soc@vger.kernel.org Subject: [PATCH v4 4/6] watchdog: rzg2l_wdt: Add error check for reset_control_deassert Date: Wed, 23 Feb 2022 16:00:58 +0000 Message-Id: <20220223160100.23543-5-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220223160100.23543-1-biju.das.jz@bp.renesas.com> References: <20220223160100.23543-1-biju.das.jz@bp.renesas.com> Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org If reset_control_deassert() fails, then we won't be able to access the device registers. Therefore check the return code of reset_control_deassert() and bailout in case of error. While at it change reset_control_assert->reset_control_reset in rzg2l_wdt_stop() and remove unnecessary reset_control_deassert() from rzg2l_wdt_start(). Signed-off-by: Biju Das --- v3->v4: * Made reset usage counter balanced * Updated commit description v2->v3: * Patch reordering from Patch 2 -> Patch 3 * Updated commit description v1->v2: * Updated commit description and removed Rb tag from Guenter, since there is code change * Replaced reset_control_assert with reset_control_reset in stop and removed reset_control_deassert() from start. --- drivers/watchdog/rzg2l_wdt.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/watchdog/rzg2l_wdt.c b/drivers/watchdog/rzg2l_wdt.c index 48dfe6e5e64f..73b667ed3e99 100644 --- a/drivers/watchdog/rzg2l_wdt.c +++ b/drivers/watchdog/rzg2l_wdt.c @@ -88,7 +88,6 @@ static int rzg2l_wdt_start(struct watchdog_device *wdev) { struct rzg2l_wdt_priv *priv = watchdog_get_drvdata(wdev); - reset_control_deassert(priv->rstc); pm_runtime_get_sync(wdev->parent); /* Initialize time out */ @@ -108,7 +107,7 @@ static int rzg2l_wdt_stop(struct watchdog_device *wdev) struct rzg2l_wdt_priv *priv = watchdog_get_drvdata(wdev); pm_runtime_put(wdev->parent); - reset_control_assert(priv->rstc); + reset_control_reset(priv->rstc); return 0; } @@ -204,7 +203,10 @@ static int rzg2l_wdt_probe(struct platform_device *pdev) return dev_err_probe(&pdev->dev, PTR_ERR(priv->rstc), "failed to get cpg reset"); - reset_control_deassert(priv->rstc); + ret = reset_control_deassert(priv->rstc); + if (ret) + return dev_err_probe(dev, ret, "failed to deassert"); + pm_runtime_enable(&pdev->dev); priv->wdev.info = &rzg2l_wdt_ident;