[PATCH v4 1/2] watchdog: dw_wdt: use devm_reset_control_get_optional_shared_deasserted

From: Artem Shimko

Date: Sat Oct 24 2026 - 10:09:39 EST


Replace devm_reset_control_get_optional_shared() with
devm_reset_control_get_optional_shared_deasserted() to let the
device-managed API handle reset line deassertion and assertion
automatically.

The driver currently manages the reset control manually: it calls
reset_control_deassert() during probe and reset_control_assert() in
error paths and remove. This is error-prone and requires explicit
cleanup in multiple places.

Switching to the _deasserted variant deasserts the reset line on
acquisition and asserts it again when the device is removed, which
allows removing the out_assert_rst label along with the related
assertions in the probe error paths and in dw_wdt_drv_remove().

Tested-by: Igor Velkov <iav@xxxxxx>
Reviewed-by: Tzung-Bi Shih <tzungbi@xxxxxxxxxx>
Signed-off-by: Artem Shimko <a.shimko.dev@xxxxxxxxx>
---
drivers/watchdog/dw_wdt.c | 13 +++----------
1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/drivers/watchdog/dw_wdt.c b/drivers/watchdog/dw_wdt.c
index 39031445d754..ebd27ee684d1 100644
--- a/drivers/watchdog/dw_wdt.c
+++ b/drivers/watchdog/dw_wdt.c
@@ -588,7 +588,7 @@ static int dw_wdt_drv_probe(struct platform_device *pdev)
if (IS_ERR(dw_wdt->pclk))
return PTR_ERR(dw_wdt->pclk);

- dw_wdt->rst = devm_reset_control_get_optional_shared(&pdev->dev, NULL);
+ dw_wdt->rst = devm_reset_control_get_optional_shared_deasserted(dev, NULL);
if (IS_ERR(dw_wdt->rst))
return PTR_ERR(dw_wdt->rst);

@@ -617,11 +617,9 @@ static int dw_wdt_drv_probe(struct platform_device *pdev)
dw_wdt->wdd.info = &dw_wdt_ident;
}

- reset_control_deassert(dw_wdt->rst);
-
ret = dw_wdt_init_timeouts(dw_wdt, dev);
if (ret)
- goto out_assert_rst;
+ return ret;

wdd = &dw_wdt->wdd;
wdd->ops = &dw_wdt_ops;
@@ -655,15 +653,11 @@ static int dw_wdt_drv_probe(struct platform_device *pdev)

ret = watchdog_register_device(wdd);
if (ret)
- goto out_assert_rst;
+ return ret;

dw_wdt_dbgfs_init(dw_wdt);

return 0;
-
-out_assert_rst:
- reset_control_assert(dw_wdt->rst);
- return ret;
}

static void dw_wdt_drv_remove(struct platform_device *pdev)
@@ -673,7 +667,6 @@ static void dw_wdt_drv_remove(struct platform_device *pdev)
dw_wdt_dbgfs_clear(dw_wdt);

watchdog_unregister_device(&dw_wdt->wdd);
- reset_control_assert(dw_wdt->rst);
}

#ifdef CONFIG_OF
--
2.43.0