/* Calculates the watchdog counter value (WDV) to be installed in the watchdog timer.  */
int wdt_sam_convert_timeout(uint32_t timeout, uint32_t sclk)
/* Calculates the watchdog counter value (WDV) to be installed in the watchdog timer.  */
int wdt_sam_convert_timeout(uint32_t timeout, uint32_t sclk)
{
	uint32_t max, min;
	timeout = timeout * 1000U;
	min =  (SAM_PRESCALAR * 1000000) / sclk;
	max = min * WDT_MAX_VALUE;
	if ((timeout < min) || (timeout > max)) {
		LOG_ERR("Invalid timeout value allowed range:"
			"%d ms to %d ms", min / 1000U, max / 1000U);
		return -EINVAL;
	}
	return WDT_MR_WDV(timeout / min);
}