From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: Anson Huang <Anson.Huang@nxp.com>
Cc: wim@linux-watchdog.org, linux@roeck-us.net, shawnguo@kernel.org,
s.hauer@pengutronix.de, kernel@pengutronix.de,
festevam@gmail.com, linux-watchdog@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, Linux-imx@nxp.com
Subject: Re: [PATCH] watchdog: imx2_wdt: Drop .remove callback
Date: Mon, 24 Feb 2020 11:22:11 +0100 [thread overview]
Message-ID: <20200224102211.clzqw4vtzc4nz5df@pengutronix.de> (raw)
In-Reply-To: <1582512687-13312-1-git-send-email-Anson.Huang@nxp.com>
On Mon, Feb 24, 2020 at 10:51:27AM +0800, Anson Huang wrote:
> .remove callback implementation doesn' call clk_disable_unprepare() which
> is buggy, actually, we can just use devm_watchdog_register_device() and
> devm_add_action_or_reset() to handle all necessary operations for remove
> action, then .remove callback can be dropped.
>
> Signed-off-by: Anson Huang <Anson.Huang@nxp.com>
> ---
> drivers/watchdog/imx2_wdt.c | 37 ++++++++++---------------------------
> 1 file changed, 10 insertions(+), 27 deletions(-)
>
> diff --git a/drivers/watchdog/imx2_wdt.c b/drivers/watchdog/imx2_wdt.c
> index f8d58bf..1fe472f 100644
> --- a/drivers/watchdog/imx2_wdt.c
> +++ b/drivers/watchdog/imx2_wdt.c
> @@ -244,6 +244,11 @@ static const struct regmap_config imx2_wdt_regmap_config = {
> .max_register = 0x8,
> };
>
> +static void imx2_wdt_action(void *data)
> +{
> + clk_disable_unprepare(data);
Does this have the effect of stopping the watchdog? Maybe we can have a
more expressive function name here (imx2_wdt_stop_clk or similar)?
Is there some watchdog core policy that tells if the watchdog should be
stopped on unload?
> +}
> +
> static int __init imx2_wdt_probe(struct platform_device *pdev)
> {
> struct device *dev = &pdev->dev;
> @@ -292,6 +297,10 @@ static int __init imx2_wdt_probe(struct platform_device *pdev)
> if (ret)
> return ret;
>
> + ret = devm_add_action_or_reset(dev, imx2_wdt_action, wdev->clk);
> + if (ret)
> + return ret;
> +
> regmap_read(wdev->regmap, IMX2_WDT_WRSR, &val);
> wdog->bootstatus = val & IMX2_WDT_WRSR_TOUT ? WDIOF_CARDRESET : 0;
>
> @@ -315,32 +324,7 @@ static int __init imx2_wdt_probe(struct platform_device *pdev)
> */
> regmap_write(wdev->regmap, IMX2_WDT_WMCR, 0);
>
> - ret = watchdog_register_device(wdog);
> - if (ret)
> - goto disable_clk;
> -
> - dev_info(dev, "timeout %d sec (nowayout=%d)\n",
> - wdog->timeout, nowayout);
Does the core put this info in the kernel log? If not dropping it isn't
obviously right enough to be done en passant.
> - return 0;
> -
> -disable_clk:
> - clk_disable_unprepare(wdev->clk);
> - return ret;
> -}
> -
> -static int __exit imx2_wdt_remove(struct platform_device *pdev)
> -{
> - struct watchdog_device *wdog = platform_get_drvdata(pdev);
> - struct imx2_wdt_device *wdev = watchdog_get_drvdata(wdog);
> -
> - watchdog_unregister_device(wdog);
> -
> - if (imx2_wdt_is_running(wdev)) {
> - imx2_wdt_ping(wdog);
> - dev_crit(&pdev->dev, "Device removed: Expect reboot!\n");
> - }
I also wonder about this one. This changes the timing behaviour and so
IMHO shouldn't be done as a side effect of a cleanup patch.
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | https://www.pengutronix.de/ |
next prev parent reply other threads:[~2020-02-24 10:22 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-24 2:51 Anson Huang
2020-02-24 4:04 ` Guenter Roeck
2020-02-24 10:22 ` Uwe Kleine-König [this message]
2020-02-24 11:44 ` Anson Huang
2020-02-24 14:15 ` Guenter Roeck
2020-02-24 18:25 ` Uwe Kleine-König
2020-02-24 18:30 ` Guenter Roeck
2020-02-25 0:31 ` Anson Huang
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=20200224102211.clzqw4vtzc4nz5df@pengutronix.de \
--to=u.kleine-koenig@pengutronix.de \
--cc=Anson.Huang@nxp.com \
--cc=Linux-imx@nxp.com \
--cc=festevam@gmail.com \
--cc=kernel@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-watchdog@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@kernel.org \
--cc=wim@linux-watchdog.org \
/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
all inboxes | Powered by JetHome®