From: Stefan Roese Date: Mon, 8 Apr 2019 11:28:34 +0200 Subject: [U-Boot] [PATCH 2/2 v2] watchdog: cadence: Remove driver specific "timeout-sec" handling In-Reply-To: <20190408092834.29756-1-sr@denx.de> References: <20190408092834.29756-1-sr@denx.de> Message-ID: <20190408092834.29756-2-sr@denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Now that we have a generic DT property "timeout-sec" handling, the driver specific implementation can be dropped. This patch also changes the timeout restriction to the min and max values (clipping). Before this patch, the value provided via "timeout-sec" was used if the parameter was too high or low. Now the driver specific min and max values are used instead. Signed-off-by: Stefan Roese Cc: Michal Simek --- v2: - New patch drivers/watchdog/cdns_wdt.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/drivers/watchdog/cdns_wdt.c b/drivers/watchdog/cdns_wdt.c index fc85fbcec2..3ba3c8501c 100644 --- a/drivers/watchdog/cdns_wdt.c +++ b/drivers/watchdog/cdns_wdt.c @@ -23,7 +23,6 @@ struct cdns_regs { struct cdns_wdt_priv { bool rst; - u32 timeout; struct cdns_regs *regs; }; @@ -142,10 +141,9 @@ static int cdns_wdt_start(struct udevice *dev, u64 timeout, ulong flags) return -1; } - if ((timeout < CDNS_WDT_MIN_TIMEOUT) || - (timeout > CDNS_WDT_MAX_TIMEOUT)) { - timeout = priv->timeout; - } + /* Restrict timeout to min and max value */ + timeout = max_t(u64, timeout, CDNS_WDT_MIN_TIMEOUT); + timeout = min_t(u64, timeout, CDNS_WDT_MAX_TIMEOUT); debug("%s: CLK_FREQ %ld, timeout %lld\n", __func__, clk_f, timeout); @@ -235,12 +233,9 @@ static int cdns_wdt_ofdata_to_platdata(struct udevice *dev) if (IS_ERR(priv->regs)) return PTR_ERR(priv->regs); - priv->timeout = dev_read_u32_default(dev, "timeout-sec", - CDNS_WDT_DEFAULT_TIMEOUT); - priv->rst = dev_read_bool(dev, "reset-on-timeout"); - debug("%s: timeout %d, reset %d\n", __func__, priv->timeout, priv->rst); + debug("%s: reset %d\n", __func__, priv->rst); return 0; } -- 2.21.0