aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/watchdog
diff options
context:
space:
mode:
authorWim Van Sebroeck <wim@iguana.be>2007-01-10 17:23:44 -0500
committerWim Van Sebroeck <wim@iguana.be>2007-01-10 17:23:44 -0500
commit76c11f0442257099cbb474301f2ffff38649d3d3 (patch)
tree4f8ba1b5f3ef7379b7ef237addda4448468f5f3f /drivers/char/watchdog
parentf3dc07330c3e43a8d365eaa74693e320e6ed79d9 (diff)
[WATCHDOG] acquirewdt.c - clean before platform_device patches
Clean the current code before we convert the driver to a platform_device. This clean consists of: - document the includes - make sure that the printk's use the module/driver-name - do the exit of the module exactly the opposite of the init of the module Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
Diffstat (limited to 'drivers/char/watchdog')
-rw-r--r--drivers/char/watchdog/acquirewdt.c74
1 files changed, 41 insertions, 33 deletions
diff --git a/drivers/char/watchdog/acquirewdt.c b/drivers/char/watchdog/acquirewdt.c
index 154d67e591e5..a968f84c353e 100644
--- a/drivers/char/watchdog/acquirewdt.c
+++ b/drivers/char/watchdog/acquirewdt.c
@@ -48,46 +48,52 @@
48 * It can be 1, 2, 10, 20, 110 or 220 seconds. 48 * It can be 1, 2, 10, 20, 110 or 220 seconds.
49 */ 49 */
50 50
51#include <linux/module.h> 51/*
52#include <linux/moduleparam.h> 52 * Includes, defines, variables, module parameters, ...
53#include <linux/types.h> 53 */
54#include <linux/miscdevice.h>
55#include <linux/watchdog.h>
56#include <linux/fs.h>
57#include <linux/ioport.h>
58#include <linux/notifier.h>
59#include <linux/reboot.h>
60#include <linux/init.h>
61
62#include <asm/io.h>
63#include <asm/uaccess.h>
64#include <asm/system.h>
65 54
55/* Includes */
56#include <linux/module.h> /* For module specific items */
57#include <linux/moduleparam.h> /* For new moduleparam's */
58#include <linux/types.h> /* For standard types (like size_t) */
59#include <linux/errno.h> /* For the -ENODEV/... values */
60#include <linux/kernel.h> /* For printk/panic/... */
61#include <linux/miscdevice.h> /* For MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR) */
62#include <linux/watchdog.h> /* For the watchdog specific items */
63#include <linux/fs.h> /* For file operations */
64#include <linux/ioport.h> /* For io-port access */
65#include <linux/notifier.h> /* For reboot notifier */
66#include <linux/reboot.h> /* For reboot notifier */
67#include <linux/init.h> /* For __init/__exit/... */
68
69#include <asm/uaccess.h> /* For copy_to_user/put_user/... */
70#include <asm/io.h> /* For inb/outb/... */
71
72/* Module information */
73#define DRV_NAME "acquirewdt"
74#define PFX DRV_NAME ": "
66#define WATCHDOG_NAME "Acquire WDT" 75#define WATCHDOG_NAME "Acquire WDT"
67#define PFX WATCHDOG_NAME ": "
68#define WATCHDOG_HEARTBEAT 0 /* There is no way to see what the correct time-out period is */ 76#define WATCHDOG_HEARTBEAT 0 /* There is no way to see what the correct time-out period is */
69 77
78/* internal variables */
70static unsigned long acq_is_open; 79static unsigned long acq_is_open;
71static char expect_close; 80static char expect_close;
72 81
73/* 82/* module parameters */
74 * You must set these - there is no sane way to probe for this board. 83static int wdt_stop = 0x43; /* You must set this - there is no sane way to probe for this board. */
75 */
76
77static int wdt_stop = 0x43;
78module_param(wdt_stop, int, 0); 84module_param(wdt_stop, int, 0);
79MODULE_PARM_DESC(wdt_stop, "Acquire WDT 'stop' io port (default 0x43)"); 85MODULE_PARM_DESC(wdt_stop, "Acquire WDT 'stop' io port (default 0x43)");
80 86
81static int wdt_start = 0x443; 87static int wdt_start = 0x443; /* You must set this - there is no sane way to probe for this board. */
82module_param(wdt_start, int, 0); 88module_param(wdt_start, int, 0);
83MODULE_PARM_DESC(wdt_start, "Acquire WDT 'start' io port (default 0x443)"); 89MODULE_PARM_DESC(wdt_start, "Acquire WDT 'start' io port (default 0x443)");
84 90
85static int nowayout = WATCHDOG_NOWAYOUT; 91static int nowayout = WATCHDOG_NOWAYOUT;
86module_param(nowayout, int, 0); 92module_param(nowayout, int, 0);
87MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=CONFIG_WATCHDOG_NOWAYOUT)"); 93MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
88 94
89/* 95/*
90 * Kernel methods. 96 * Watchdog Operations
91 */ 97 */
92 98
93static void acq_keepalive(void) 99static void acq_keepalive(void)
@@ -103,7 +109,7 @@ static void acq_stop(void)
103} 109}
104 110
105/* 111/*
106 * /dev/watchdog handling. 112 * /dev/watchdog handling
107 */ 113 */
108 114
109static ssize_t acq_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) 115static ssize_t acq_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos)
@@ -143,7 +149,7 @@ static int acq_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
143 { 149 {
144 .options = WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE, 150 .options = WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE,
145 .firmware_version = 1, 151 .firmware_version = 1,
146 .identity = "Acquire WDT", 152 .identity = WATCHDOG_NAME,
147 }; 153 };
148 154
149 switch(cmd) 155 switch(cmd)
@@ -240,11 +246,10 @@ static const struct file_operations acq_fops = {
240 .release = acq_close, 246 .release = acq_close,
241}; 247};
242 248
243static struct miscdevice acq_miscdev= 249static struct miscdevice acq_miscdev = {
244{ 250 .minor = WATCHDOG_MINOR,
245 .minor = WATCHDOG_MINOR, 251 .name = "watchdog",
246 .name = "watchdog", 252 .fops = &acq_fops,
247 .fops = &acq_fops,
248}; 253};
249 254
250/* 255/*
@@ -252,11 +257,14 @@ static struct miscdevice acq_miscdev=
252 * turn the timebomb registers off. 257 * turn the timebomb registers off.
253 */ 258 */
254 259
255static struct notifier_block acq_notifier = 260static struct notifier_block acq_notifier = {
256{
257 .notifier_call = acq_notify_sys, 261 .notifier_call = acq_notify_sys,
258}; 262};
259 263
264/*
265 * Init & exit routines
266 */
267
260static int __init acq_init(void) 268static int __init acq_init(void)
261{ 269{
262 int ret; 270 int ret;
@@ -313,9 +321,9 @@ static void __exit acq_exit(void)
313{ 321{
314 misc_deregister(&acq_miscdev); 322 misc_deregister(&acq_miscdev);
315 unregister_reboot_notifier(&acq_notifier); 323 unregister_reboot_notifier(&acq_notifier);
324 release_region(wdt_start,1);
316 if(wdt_stop != wdt_start) 325 if(wdt_stop != wdt_start)
317 release_region(wdt_stop,1); 326 release_region(wdt_stop,1);
318 release_region(wdt_start,1);
319} 327}
320 328
321module_init(acq_init); 329module_init(acq_init);