From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756426AbeATPp6 (ORCPT ); Sat, 20 Jan 2018 10:45:58 -0500 Received: from mail-pf0-f193.google.com ([209.85.192.193]:36043 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756334AbeATPpu (ORCPT ); Sat, 20 Jan 2018 10:45:50 -0500 X-Google-Smtp-Source: AH8x2255K+9bCpPYIHQ/rMYcVtW1WjqPQ3kW4mlxf6PmGiVs1bIfUrqUmtQYL3BSd1u/mzfenF6tdQ== Subject: Re: [PATCH v2 3/8] watchdog: JZ4740: Register a restart handler To: PrasannaKumar Muralidharan , Paul Cercueil Cc: Ralf Baechle , Rob Herring , Mark Rutland , Wim Van Sebroeck , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , Linux-MIPS , open list , linux-watchdog@vger.kernel.org References: <20171228162939.3928-2-paul@crapouillou.net> <20171230135108.6834-1-paul@crapouillou.net> <20171230135108.6834-3-paul@crapouillou.net> From: Guenter Roeck Message-ID: <20061de8-fa1f-93eb-eb9b-089c699018aa@roeck-us.net> Date: Sat, 20 Jan 2018 07:45:46 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01/19/2018 11:31 PM, PrasannaKumar Muralidharan wrote: > Hi Paul, > > On 30 December 2017 at 19:21, Paul Cercueil wrote: >> The watchdog driver can restart the system by simply configuring the >> hardware for a timeout of 0 seconds. >> >> Signed-off-by: Paul Cercueil >> Reviewed-by: Guenter Roeck >> --- >> drivers/watchdog/jz4740_wdt.c | 9 +++++++++ >> 1 file changed, 9 insertions(+) >> >> v2: No change >> >> diff --git a/drivers/watchdog/jz4740_wdt.c b/drivers/watchdog/jz4740_wdt.c >> index 92d6ca8ceb49..fa7f49a3212c 100644 >> --- a/drivers/watchdog/jz4740_wdt.c >> +++ b/drivers/watchdog/jz4740_wdt.c >> @@ -130,6 +130,14 @@ static int jz4740_wdt_stop(struct watchdog_device *wdt_dev) >> return 0; >> } >> >> +static int jz4740_wdt_restart(struct watchdog_device *wdt_dev, >> + unsigned long action, void *data) >> +{ >> + wdt_dev->timeout = 0; >> + jz4740_wdt_start(wdt_dev); >> + return 0; >> +} >> + >> static const struct watchdog_info jz4740_wdt_info = { >> .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE, >> .identity = "jz4740 Watchdog", >> @@ -141,6 +149,7 @@ static const struct watchdog_ops jz4740_wdt_ops = { >> .stop = jz4740_wdt_stop, >> .ping = jz4740_wdt_ping, >> .set_timeout = jz4740_wdt_set_timeout, >> + .restart = jz4740_wdt_restart, >> }; >> >> #ifdef CONFIG_OF >> -- >> 2.11.0 >> >> > > Noticed that min_timeout of the watchdog device is set to 1 but this > function calls start with timeout set to 0. Even though this works I > feel it is better to set min_timeout to 0. > No. That would be wrong. If you want to be pedantic, write a new function __jz4740_wdt_set_timeout(u16 clock_div, u16 timeout_value) and call it instead, but don't mess with min_timeout. Guenter