Skip to content

Commit 98e4a29

Browse files
AxelLinWim Van Sebroeck
authored andcommitted
watchdog: da9055: Don't update wdt_dev->timeout in da9055_wdt_set_timeout error path
Otherwise, WDIOC_GETTIMEOUT returns wrong value if set_timeout fails. This patch also removes unnecessary ret variable in da9055_wdt_ping function. Signed-off-by: Axel Lin <axel.lin@ingics.com> Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
1 parent ee8c94a commit 98e4a29

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

drivers/watchdog/da9055_wdt.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,20 +72,21 @@ static int da9055_wdt_set_timeout(struct watchdog_device *wdt_dev,
7272
DA9055_TWDSCALE_MASK,
7373
da9055_wdt_maps[i].reg_val <<
7474
DA9055_TWDSCALE_SHIFT);
75-
if (ret < 0)
75+
if (ret < 0) {
7676
dev_err(da9055->dev,
7777
"Failed to update timescale bit, %d\n", ret);
78+
return ret;
79+
}
7880

7981
wdt_dev->timeout = timeout;
8082

81-
return ret;
83+
return 0;
8284
}
8385

8486
static int da9055_wdt_ping(struct watchdog_device *wdt_dev)
8587
{
8688
struct da9055_wdt_data *driver_data = watchdog_get_drvdata(wdt_dev);
8789
struct da9055 *da9055 = driver_data->da9055;
88-
int ret;
8990

9091
/*
9192
* We have a minimum time for watchdog window called TWDMIN. A write
@@ -94,10 +95,8 @@ static int da9055_wdt_ping(struct watchdog_device *wdt_dev)
9495
mdelay(DA9055_TWDMIN);
9596

9697
/* Reset the watchdog timer */
97-
ret = da9055_reg_update(da9055, DA9055_REG_CONTROL_E,
98-
DA9055_WATCHDOG_MASK, 1);
99-
100-
return ret;
98+
return da9055_reg_update(da9055, DA9055_REG_CONTROL_E,
99+
DA9055_WATCHDOG_MASK, 1);
101100
}
102101

103102
static void da9055_wdt_release_resources(struct kref *r)

0 commit comments

Comments
 (0)