diff mbox series

[RFT] watchdog: da9063_wdt: parse DT for timeout value, too

Message ID 20190414110933.30529-1-wsa+renesas@sang-engineering.com (mailing list archive)
State Accepted
Headers show
Series [RFT] watchdog: da9063_wdt: parse DT for timeout value, too | expand

Commit Message

Wolfram Sang April 14, 2019, 11:09 a.m. UTC
And make sure the final obtained value gets properly scaled. Remove two
empty lines to group the initialization blocks while we are here.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---

Tested with a Renesas Lager board (R-Car H2, DA9063AD), checking the initial
timeout value via sysfs. I didn't test handover from bootloader because my
bootloader neither supports WDT or I2C out of the box.

 drivers/watchdog/da9063_wdt.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

Comments

Guenter Roeck April 14, 2019, 2:52 p.m. UTC | #1
On 4/14/19 4:09 AM, Wolfram Sang wrote:
> And make sure the final obtained value gets properly scaled. Remove two
> empty lines to group the initialization blocks while we are here.
> 
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>

Reviewed-by: Guenter Roeck <linux@roeck-us.net>

> ---
> 
> Tested with a Renesas Lager board (R-Car H2, DA9063AD), checking the initial
> timeout value via sysfs. I didn't test handover from bootloader because my
> bootloader neither supports WDT or I2C out of the box.
> 
>   drivers/watchdog/da9063_wdt.c | 10 ++++++----
>   1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/watchdog/da9063_wdt.c b/drivers/watchdog/da9063_wdt.c
> index 06eb9070203c..3d65e92a4e3f 100644
> --- a/drivers/watchdog/da9063_wdt.c
> +++ b/drivers/watchdog/da9063_wdt.c
> @@ -208,18 +208,20 @@ static int da9063_wdt_probe(struct platform_device *pdev)
>   	wdd->min_timeout = DA9063_WDT_MIN_TIMEOUT;
>   	wdd->max_timeout = DA9063_WDT_MAX_TIMEOUT;
>   	wdd->min_hw_heartbeat_ms = DA9063_RESET_PROTECTION_MS;
> -	wdd->timeout = DA9063_WDG_TIMEOUT;
>   	wdd->parent = dev;
> -
>   	wdd->status = WATCHDOG_NOWAYOUT_INIT_STATUS;
>   
>   	watchdog_set_restart_priority(wdd, 128);
> -
>   	watchdog_set_drvdata(wdd, da9063);
>   
> +	/* Set default timeout, maybe override it with DT value, scale it */
> +	wdd->timeout = DA9063_WDG_TIMEOUT;
> +	watchdog_init_timeout(wdd, 0, dev);
> +	da9063_wdt_set_timeout(wdd, wdd->timeout);
> +
>   	/* Change the timeout to the default value if the watchdog is running */
>   	if (da9063_wdt_is_running(da9063)) {
> -		da9063_wdt_update_timeout(da9063, DA9063_WDG_TIMEOUT);
> +		da9063_wdt_update_timeout(da9063, wdd->timeout);
>   		set_bit(WDOG_HW_RUNNING, &wdd->status);
>   	}
>   
>
Steve Twiss April 16, 2019, 10:21 a.m. UTC | #2
On 14 April 2019 12:10, Wolfram Sang wrote:

> Subject: [PATCH RFT] watchdog: da9063_wdt: parse DT for timeout value, too
> 
> And make sure the final obtained value gets properly scaled. Remove two
> empty lines to group the initialization blocks while we are here.
> 
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> ---
> 
> Tested with a Renesas Lager board (R-Car H2, DA9063AD), checking the initial
> timeout value via sysfs. I didn't test handover from bootloader because my
> bootloader neither supports WDT or I2C out of the box.

Tested on git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git
* watchdog-next                 6829e6ef3f22 [origin/watchdog-next] watchdog: pnx4008: readout watchdog state

Tested-by: Steve Twiss <stwiss.opensource@diasemi.com>

Regards,
Steve
diff mbox series

Patch

diff --git a/drivers/watchdog/da9063_wdt.c b/drivers/watchdog/da9063_wdt.c
index 06eb9070203c..3d65e92a4e3f 100644
--- a/drivers/watchdog/da9063_wdt.c
+++ b/drivers/watchdog/da9063_wdt.c
@@ -208,18 +208,20 @@  static int da9063_wdt_probe(struct platform_device *pdev)
 	wdd->min_timeout = DA9063_WDT_MIN_TIMEOUT;
 	wdd->max_timeout = DA9063_WDT_MAX_TIMEOUT;
 	wdd->min_hw_heartbeat_ms = DA9063_RESET_PROTECTION_MS;
-	wdd->timeout = DA9063_WDG_TIMEOUT;
 	wdd->parent = dev;
-
 	wdd->status = WATCHDOG_NOWAYOUT_INIT_STATUS;
 
 	watchdog_set_restart_priority(wdd, 128);
-
 	watchdog_set_drvdata(wdd, da9063);
 
+	/* Set default timeout, maybe override it with DT value, scale it */
+	wdd->timeout = DA9063_WDG_TIMEOUT;
+	watchdog_init_timeout(wdd, 0, dev);
+	da9063_wdt_set_timeout(wdd, wdd->timeout);
+
 	/* Change the timeout to the default value if the watchdog is running */
 	if (da9063_wdt_is_running(da9063)) {
-		da9063_wdt_update_timeout(da9063, DA9063_WDG_TIMEOUT);
+		da9063_wdt_update_timeout(da9063, wdd->timeout);
 		set_bit(WDOG_HW_RUNNING, &wdd->status);
 	}