Skip to content

Commit

Permalink
watchdog: shwdt: Migrate from reboot notifier to platform shutdown.
Browse files Browse the repository at this point in the history
It's possible to do the same work via the platform driver shutdown
method, so wire that up and dump the reboot notifier.

Signed-off-by: Paul Mundt <lethal@linux-sh.org>
  • Loading branch information
Paul Mundt committed May 10, 2012
1 parent 7ee94d9 commit 4096812
Showing 1 changed file with 12 additions and 31 deletions.
43 changes: 12 additions & 31 deletions drivers/watchdog/shwdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* Watchdog driver for integrated watchdog in the SuperH processors.
*
* Copyright (C) 2001 - 2010 Paul Mundt <lethal@linux-sh.org>
* Copyright (C) 2001 - 2012 Paul Mundt <lethal@linux-sh.org>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
Expand All @@ -27,8 +27,6 @@
#include <linux/types.h>
#include <linux/miscdevice.h>
#include <linux/watchdog.h>
#include <linux/reboot.h>
#include <linux/notifier.h>
#include <linux/ioport.h>
#include <linux/fs.h>
#include <linux/mm.h>
Expand Down Expand Up @@ -293,17 +291,6 @@ static long sh_wdt_ioctl(struct file *file, unsigned int cmd,
return 0;
}

static int sh_wdt_notify_sys(struct notifier_block *this,
unsigned long code, void *unused)
{
struct sh_wdt *wdt = platform_get_drvdata(sh_wdt_dev);

if (code == SYS_DOWN || code == SYS_HALT)
sh_wdt_stop(wdt);

return NOTIFY_DONE;
}

static const struct file_operations sh_wdt_fops = {
.owner = THIS_MODULE,
.llseek = no_llseek,
Expand All @@ -320,10 +307,6 @@ static const struct watchdog_info sh_wdt_info = {
.identity = "SH WDT",
};

static struct notifier_block sh_wdt_notifier = {
.notifier_call = sh_wdt_notify_sys,
};

static struct miscdevice sh_wdt_miscdev = {
.minor = WATCHDOG_MINOR,
.name = "watchdog",
Expand Down Expand Up @@ -365,21 +348,14 @@ static int __devinit sh_wdt_probe(struct platform_device *pdev)
goto out_err;
}

rc = register_reboot_notifier(&sh_wdt_notifier);
if (unlikely(rc)) {
dev_err(&pdev->dev,
"Can't register reboot notifier (err=%d)\n", rc);
goto out_unmap;
}

sh_wdt_miscdev.parent = wdt->dev;

rc = misc_register(&sh_wdt_miscdev);
if (unlikely(rc)) {
dev_err(&pdev->dev,
"Can't register miscdev on minor=%d (err=%d)\n",
sh_wdt_miscdev.minor, rc);
goto out_unreg;
goto out_unmap;
}

init_timer(&wdt->timer);
Expand All @@ -394,8 +370,6 @@ static int __devinit sh_wdt_probe(struct platform_device *pdev)

return 0;

out_unreg:
unregister_reboot_notifier(&sh_wdt_notifier);
out_unmap:
devm_iounmap(&pdev->dev, wdt->base);
out_err:
Expand All @@ -417,22 +391,29 @@ static int __devexit sh_wdt_remove(struct platform_device *pdev)

sh_wdt_dev = NULL;

unregister_reboot_notifier(&sh_wdt_notifier);
devm_release_mem_region(&pdev->dev, res->start, resource_size(res));
devm_iounmap(&pdev->dev, wdt->base);
devm_kfree(&pdev->dev, wdt);

return 0;
}

static void sh_wdt_shutdown(struct platform_device *pdev)
{
struct sh_wdt *wdt = platform_get_drvdata(pdev);

sh_wdt_stop(wdt);
}

static struct platform_driver sh_wdt_driver = {
.driver = {
.name = DRV_NAME,
.owner = THIS_MODULE,
},

.probe = sh_wdt_probe,
.remove = __devexit_p(sh_wdt_remove),
.probe = sh_wdt_probe,
.remove = __devexit_p(sh_wdt_remove),
.shutdown = sh_wdt_shutdown,
};

static int __init sh_wdt_init(void)
Expand Down

0 comments on commit 4096812

Please sign in to comment.