Linux Watchdog driver development
 help / color / mirror / Atom feed
From: Paul Cercueil <paul@crapouillou.net>
To: Guenter Roeck <linux@roeck-us.net>
Cc: Ralf Baechle <ralf@linux-mips.org>,
	Rob Herring <robh+dt@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Wim Van Sebroeck <wim@iguana.be>,
	devicetree@vger.kernel.org, linux-mips@linux-mips.org,
	linux-kernel@vger.kernel.org, linux-watchdog@vger.kernel.org
Subject: Re: [PATCH 2/7] watchdog: jz4740: Use devm_* functions
Date: Thu, 28 Dec 2017 21:22:18 +0100	[thread overview]
Message-ID: <1514492538.6093.1@smtp.crapouillou.net> (raw)
In-Reply-To: <994187b3-113c-88ef-8ebd-cd57d0c833a0@roeck-us.net>



Le jeu. 28 déc. 2017 à 21:19, Guenter Roeck <linux@roeck-us.net> a 
écrit :
> On 12/28/2017 11:59 AM, Paul Cercueil wrote:
>> Hi Guenter,
>> 
>> Le jeu. 28 déc. 2017 à 18:48, Guenter Roeck <linux@roeck-us.net> a 
>> écrit :
>>> On 12/28/2017 08:29 AM, Paul Cercueil wrote:
>>>> - Use devm_clk_get instead of clk_get
>>>> - Use devm_watchdog_register_device instead of 
>>>> watchdog_register_device
>>>> 
>>>> Signed-off-by: Paul Cercueil <paul@crapouillou.net>
>>>> ---
>>>>   drivers/watchdog/jz4740_wdt.c | 27 ++++++++-------------------
>>>>   1 file changed, 8 insertions(+), 19 deletions(-)
>>>> 
>>>> diff --git a/drivers/watchdog/jz4740_wdt.c 
>>>> b/drivers/watchdog/jz4740_wdt.c
>>>> index 6955deb100ef..92d6ca8ceb49 100644
>>>> --- a/drivers/watchdog/jz4740_wdt.c
>>>> +++ b/drivers/watchdog/jz4740_wdt.c
>>>> @@ -178,40 +178,29 @@ static int jz4740_wdt_probe(struct 
>>>> platform_device *pdev)
>>>>   \x7f      res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>>>>       drvdata->base = devm_ioremap_resource(&pdev->dev, res);
>>>> -    if (IS_ERR(drvdata->base)) {
>>>> -        ret = PTR_ERR(drvdata->base);
>>>> -        goto err_out;
>>>> -    }
>>>> +    if (IS_ERR(drvdata->base))
>>>> +        return PTR_ERR(drvdata->base);
>>>>   \x7f-    drvdata->rtc_clk = clk_get(&pdev->dev, "rtc");
>>>> +    drvdata->rtc_clk = devm_clk_get(&pdev->dev, "rtc");
>>>>       if (IS_ERR(drvdata->rtc_clk)) {
>>>>           dev_err(&pdev->dev, "cannot find RTC clock\n");
>>>> -        ret = PTR_ERR(drvdata->rtc_clk);
>>>> -        goto err_out;
>>>> +        return PTR_ERR(drvdata->rtc_clk);
>>>>       }
>>>>   \x7f-    ret = watchdog_register_device(&drvdata->wdt);
>>>> +    ret = devm_watchdog_register_device(&pdev->dev, 
>>>> &drvdata->wdt);
>>>>       if (ret < 0)
>>>> -        goto err_disable_clk;
>>>> +        return ret;
>>>>   \x7f      platform_set_drvdata(pdev, drvdata);
>>>> -    return 0;
>>>>   \x7f-err_disable_clk:
>>>> -    clk_put(drvdata->rtc_clk);
>>>> -err_out:
>>>> -    return ret;
>>>> +    return 0;
>>>>   }
>>>>   \x7f  static int jz4740_wdt_remove(struct platform_device *pdev)
>>>>   {
>>>>       struct jz4740_wdt_drvdata *drvdata = 
>>>> platform_get_drvdata(pdev);
>>>>   \x7f-    jz4740_wdt_stop(&drvdata->wdt);
>>>> -    watchdog_unregister_device(&drvdata->wdt);
>>>> -    clk_put(drvdata->rtc_clk);
>>>> -
>>>> -    return 0;
>>>> +    return jz4740_wdt_stop(&drvdata->wdt);
>>> 
>>> If the watchdog is running, the module can not be unloaded. Even if 
>>> that wasn't
>>> the case, this defeats both WDIOF_MAGICCLOSE and 
>>> watchdog_set_nowayout().
>>> Are you sure this is what you want ? If so, please call
>>> watchdog_stop_on_unregister() before registration; this clarifies 
>>> that this
>>> is what you want, and you can drop the remove function.
>>> 
>>> Thanks,
>>> Guenter
>> 
>> This patch does not change the behaviour. We always used that driver 
>> built-in; what
>> should the behaviour be when unloading the module? Keep the watchdog 
>> hardware running
>> if configured for 'nowayout'?
>> 
> 
> One can still unload the driver. If you are fine with 
> bypassing/dfeating nowayout
> and WDIOF_MAGICCLOSE, may I ask why those are enabled in the first 
> place ?
> 

Who knows? That code is very old :)
I'm fine with removing the remove() function completely, if you think 
it makes more sense.

Thanks,
-Paul

  reply	other threads:[~2017-12-28 20:22 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-28 16:29 [PATCH 0/7] jz4740 watchdog driver & platform cleanups Paul Cercueil
2017-12-28 16:29 ` [PATCH 1/7] watchdog: JZ4740: Disable clock after stopping counter Paul Cercueil
2017-12-28 18:38   ` Guenter Roeck
2017-12-30 13:51   ` [PATCH v2 1/8] " Paul Cercueil
2017-12-30 13:51     ` [PATCH v2 2/8] watchdog: jz4740: Use devm_* functions Paul Cercueil
2017-12-30 16:08       ` Guenter Roeck
2017-12-30 13:51     ` [PATCH v2 3/8] watchdog: JZ4740: Register a restart handler Paul Cercueil
2018-01-20  7:31       ` PrasannaKumar Muralidharan
2018-01-20 15:45         ` Guenter Roeck
2018-01-20 16:04           ` PrasannaKumar Muralidharan
2018-01-20 17:56             ` Guenter Roeck
2017-12-30 13:51     ` [PATCH v2 4/8] watchdog: JZ4740: Drop module remove function Paul Cercueil
2017-12-30 16:08       ` Guenter Roeck
2018-01-20  7:41       ` PrasannaKumar Muralidharan
2018-01-20 15:50         ` Guenter Roeck
2018-01-20 15:59           ` PrasannaKumar Muralidharan
2017-12-30 13:51     ` [PATCH v2 5/8] MIPS: jz4740: dts: Add bindings for the jz4740-wdt driver Paul Cercueil
2018-01-02 16:37       ` PrasannaKumar Muralidharan
2018-01-02 16:48         ` Paul Cercueil
2018-01-03  4:46           ` Guenter Roeck
2018-01-03 12:01             ` Paul Cercueil
2018-01-03 14:28             ` PrasannaKumar Muralidharan
2017-12-30 13:51     ` [PATCH v2 6/8] MIPS: jz4780: dts: Fix watchdog node Paul Cercueil
2018-03-05 18:25       ` James Hogan
2017-12-30 13:51     ` [PATCH v2 7/8] MIPS: qi_lb60: Enable the jz4740-wdt driver Paul Cercueil
2018-03-05 18:28       ` James Hogan
2017-12-30 13:51     ` [PATCH v2 8/8] MIPS: jz4740: Drop old platform reset code Paul Cercueil
2018-03-05 18:31       ` James Hogan
2017-12-28 16:29 ` [PATCH 2/7] watchdog: jz4740: Use devm_* functions Paul Cercueil
2017-12-28 17:48   ` Guenter Roeck
2017-12-28 19:59     ` Paul Cercueil
2017-12-28 20:19       ` Guenter Roeck
2017-12-28 20:22         ` Paul Cercueil [this message]
2017-12-28 21:03           ` Guenter Roeck
2017-12-28 18:40   ` Guenter Roeck
2017-12-28 16:29 ` [PATCH 3/7] watchdog: JZ4740: Register a restart handler Paul Cercueil
2017-12-28 18:40   ` Guenter Roeck
2017-12-28 16:29 ` [PATCH 4/7] MIPS: jz4740: dts: Add bindings for the jz4740-wdt driver Paul Cercueil
2017-12-28 16:29 ` [PATCH 5/7] MIPS: jz4780: dts: Fix watchdog node Paul Cercueil
2017-12-28 17:33   ` Mathieu Malaterre
2017-12-28 16:29 ` [PATCH 6/7] MIPS: qi_lb60: Enable the jz4740-wdt driver Paul Cercueil
2017-12-28 16:29 ` [PATCH 7/7] MIPS: jz4740: Drop old platform reset code Paul Cercueil

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1514492538.6093.1@smtp.crapouillou.net \
    --to=paul@crapouillou.net \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@linux-mips.org \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=mark.rutland@arm.com \
    --cc=ralf@linux-mips.org \
    --cc=robh+dt@kernel.org \
    --cc=wim@iguana.be \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox