drivers: watchdog: sam0: Check if timeout is valid
The upper limit of the timeout should not be 0. tests/drivers/watchdog/wdt_basic_api checks for this and fails as the driver currently only checks that the timout does not exceed the upper bound. This also makes it check the lower bound, so that the test passes. Signed-off-by: Benjamin Valentin <benjamin.valentin@ml-pa.com>
This commit is contained in:
parent
37d494778e
commit
29deef2def
1 changed files with 5 additions and 0 deletions
|
@ -117,6 +117,11 @@ static int wdt_sam0_install_timeout(struct device *dev,
|
||||||
return -ENOTSUP;
|
return -ENOTSUP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cfg->window.max == 0) {
|
||||||
|
LOG_ERR("Upper limit timeout out of range");
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
per = wdt_sam0_timeout_to_wdt_period(cfg->window.max);
|
per = wdt_sam0_timeout_to_wdt_period(cfg->window.max);
|
||||||
if (per > WDT_CONFIG_PER_16K_Val) {
|
if (per > WDT_CONFIG_PER_16K_Val) {
|
||||||
LOG_ERR("Upper limit timeout out of range");
|
LOG_ERR("Upper limit timeout out of range");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue