[PATCH] watchdog: atcwdt200: fix return value when watchdog is enabled

kr494167@gmail.com posted 1 patch 2 days, 5 hours ago
There is a newer version of this series
drivers/watchdog/atcwdt200_wdt.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
[PATCH] watchdog: atcwdt200: fix return value when watchdog is enabled
Posted by kr494167@gmail.com 2 days, 5 hours ago
From: Surendra Singh Chouhan <kr494167@gmail.com>

atcwdt_get_int_timer_type() returned TMR_UNKNOWN (enum value 3) when
CTRL_WDT_EN was set in the control register.

Because atcwdt_probe() checks "ret = atcwdt_get_int_timer_type(drv_data);
if (ret) return ret;", returning TMR_UNKNOWN caused probe() to return 3
instead of a valid negative error code.

Fix this by setting drv_data->int_timer_type to TMR_UNKNOWN and returning
-EBUSY via dev_err_probe() when the watchdog is already enabled.

Fixes: e4e0848ad046 ("watchdog: atcwdt200: Add driver for Andes ATCWDT200")
Signed-off-by: Surendra Singh Chouhan <kr494167@gmail.com>
---
 drivers/watchdog/atcwdt200_wdt.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/watchdog/atcwdt200_wdt.c b/drivers/watchdog/atcwdt200_wdt.c
index 8e3b18aea368..b91c748b3603 100644
--- a/drivers/watchdog/atcwdt200_wdt.c
+++ b/drivers/watchdog/atcwdt200_wdt.c
@@ -274,7 +274,9 @@ static int atcwdt_get_int_timer_type(struct atcwdt_drv *drv_data)
 	regmap_read(drv_data->regmap, REG_CTRL, &val);
 	if (val & CTRL_WDT_EN) {
 		spin_unlock(&drv_data->lock);
-		return TMR_UNKNOWN;
+		drv_data->int_timer_type = TMR_UNKNOWN;
+		return dev_err_probe(dev, -EBUSY,
+				     "Watchdog is enabled, cannot detect timer type\n");
 	}
 
 	/*
-- 
2.55.0