Skip to content

Commit 436867b

Browse files
Anson-HuangWim Van Sebroeck
authored andcommitted
watchdog: imx2_wdt: Drop .remove callback
.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 <[email protected]> Reviewed-by: Guenter Roeck <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Guenter Roeck <[email protected]> Signed-off-by: Wim Van Sebroeck <[email protected]>
1 parent 9232c80 commit 436867b

File tree

1 file changed

+10
-27
lines changed

1 file changed

+10
-27
lines changed

drivers/watchdog/imx2_wdt.c

Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,11 @@ static const struct regmap_config imx2_wdt_regmap_config = {
244244
.max_register = 0x8,
245245
};
246246

247+
static void imx2_wdt_action(void *data)
248+
{
249+
clk_disable_unprepare(data);
250+
}
251+
247252
static int __init imx2_wdt_probe(struct platform_device *pdev)
248253
{
249254
struct device *dev = &pdev->dev;
@@ -292,6 +297,10 @@ static int __init imx2_wdt_probe(struct platform_device *pdev)
292297
if (ret)
293298
return ret;
294299

300+
ret = devm_add_action_or_reset(dev, imx2_wdt_action, wdev->clk);
301+
if (ret)
302+
return ret;
303+
295304
regmap_read(wdev->regmap, IMX2_WDT_WRSR, &val);
296305
wdog->bootstatus = val & IMX2_WDT_WRSR_TOUT ? WDIOF_CARDRESET : 0;
297306

@@ -315,32 +324,7 @@ static int __init imx2_wdt_probe(struct platform_device *pdev)
315324
*/
316325
regmap_write(wdev->regmap, IMX2_WDT_WMCR, 0);
317326

318-
ret = watchdog_register_device(wdog);
319-
if (ret)
320-
goto disable_clk;
321-
322-
dev_info(dev, "timeout %d sec (nowayout=%d)\n",
323-
wdog->timeout, nowayout);
324-
325-
return 0;
326-
327-
disable_clk:
328-
clk_disable_unprepare(wdev->clk);
329-
return ret;
330-
}
331-
332-
static int __exit imx2_wdt_remove(struct platform_device *pdev)
333-
{
334-
struct watchdog_device *wdog = platform_get_drvdata(pdev);
335-
struct imx2_wdt_device *wdev = watchdog_get_drvdata(wdog);
336-
337-
watchdog_unregister_device(wdog);
338-
339-
if (imx2_wdt_is_running(wdev)) {
340-
imx2_wdt_ping(wdog);
341-
dev_crit(&pdev->dev, "Device removed: Expect reboot!\n");
342-
}
343-
return 0;
327+
return devm_watchdog_register_device(dev, wdog);
344328
}
345329

346330
static void imx2_wdt_shutdown(struct platform_device *pdev)
@@ -417,7 +401,6 @@ static const struct of_device_id imx2_wdt_dt_ids[] = {
417401
MODULE_DEVICE_TABLE(of, imx2_wdt_dt_ids);
418402

419403
static struct platform_driver imx2_wdt_driver = {
420-
.remove = __exit_p(imx2_wdt_remove),
421404
.shutdown = imx2_wdt_shutdown,
422405
.driver = {
423406
.name = DRIVER_NAME,

0 commit comments

Comments
 (0)