diff options
author | Paul Mundt <lethal@linux-sh.org> | 2010-05-23 21:55:59 -0400 |
---|---|---|
committer | Paul Mundt <lethal@linux-sh.org> | 2010-05-25 04:28:14 -0400 |
commit | b1fa888e0124763e5bafda074874fc7ac0f2f23f (patch) | |
tree | ffadfe1bf14b0ae80dc3c93a65722e360d876ff4 | |
parent | 8a37f520523df971bd3f926d8bd45ead37e857e8 (diff) |
watchdog: shwdt: Kill off mmap stub and superfluous comments.
The wdt mmaping thing was a special-cased hack that nothing in the wild
depends on, so just kill it off. While at it, sanitize the superfluous
comments in preparation for a driver rewrite and overhauled interface.
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
-rw-r--r-- | drivers/watchdog/Kconfig | 8 | ||||
-rw-r--r-- | drivers/watchdog/shwdt.c | 138 |
2 files changed, 2 insertions, 144 deletions
diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig index b87ba23442d2..8828d8ffd353 100644 --- a/drivers/watchdog/Kconfig +++ b/drivers/watchdog/Kconfig | |||
@@ -948,14 +948,6 @@ config SH_WDT | |||
948 | To compile this driver as a module, choose M here: the | 948 | To compile this driver as a module, choose M here: the |
949 | module will be called shwdt. | 949 | module will be called shwdt. |
950 | 950 | ||
951 | config SH_WDT_MMAP | ||
952 | bool "Allow mmap of SH WDT" | ||
953 | default n | ||
954 | depends on SH_WDT | ||
955 | help | ||
956 | If you say Y here, user applications will be able to mmap the | ||
957 | WDT/CPG registers. | ||
958 | |||
959 | # SPARC Architecture | 951 | # SPARC Architecture |
960 | 952 | ||
961 | # SPARC64 Architecture | 953 | # SPARC64 Architecture |
diff --git a/drivers/watchdog/shwdt.c b/drivers/watchdog/shwdt.c index a03f84e5ee1f..bee1f5865825 100644 --- a/drivers/watchdog/shwdt.c +++ b/drivers/watchdog/shwdt.c | |||
@@ -1,9 +1,9 @@ | |||
1 | /* | 1 | /* |
2 | * drivers/char/watchdog/shwdt.c | 2 | * drivers/watchdog/shwdt.c |
3 | * | 3 | * |
4 | * Watchdog driver for integrated watchdog in the SuperH processors. | 4 | * Watchdog driver for integrated watchdog in the SuperH processors. |
5 | * | 5 | * |
6 | * Copyright (C) 2001, 2002, 2003 Paul Mundt <lethal@linux-sh.org> | 6 | * Copyright (C) 2001 - 2010 Paul Mundt <lethal@linux-sh.org> |
7 | * | 7 | * |
8 | * This program is free software; you can redistribute it and/or modify it | 8 | * This program is free software; you can redistribute it and/or modify it |
9 | * under the terms of the GNU General Public License as published by the | 9 | * under the terms of the GNU General Public License as published by the |
@@ -76,14 +76,8 @@ static DEFINE_SPINLOCK(shwdt_lock); | |||
76 | 76 | ||
77 | #define WATCHDOG_HEARTBEAT 30 /* 30 sec default heartbeat */ | 77 | #define WATCHDOG_HEARTBEAT 30 /* 30 sec default heartbeat */ |
78 | static int heartbeat = WATCHDOG_HEARTBEAT; /* in seconds */ | 78 | static int heartbeat = WATCHDOG_HEARTBEAT; /* in seconds */ |
79 | |||
80 | static int nowayout = WATCHDOG_NOWAYOUT; | 79 | static int nowayout = WATCHDOG_NOWAYOUT; |
81 | 80 | ||
82 | /** | ||
83 | * sh_wdt_start - Start the Watchdog | ||
84 | * | ||
85 | * Starts the watchdog. | ||
86 | */ | ||
87 | static void sh_wdt_start(void) | 81 | static void sh_wdt_start(void) |
88 | { | 82 | { |
89 | __u8 csr; | 83 | __u8 csr; |
@@ -114,15 +108,6 @@ static void sh_wdt_start(void) | |||
114 | sh_wdt_write_csr(csr); | 108 | sh_wdt_write_csr(csr); |
115 | 109 | ||
116 | #ifdef CONFIG_CPU_SH2 | 110 | #ifdef CONFIG_CPU_SH2 |
117 | /* | ||
118 | * Whoever came up with the RSTCSR semantics must've been smoking | ||
119 | * some of the good stuff, since in addition to the WTCSR/WTCNT write | ||
120 | * brain-damage, it's managed to fuck things up one step further.. | ||
121 | * | ||
122 | * If we need to clear the WOVF bit, the upper byte has to be 0xa5.. | ||
123 | * but if we want to touch RSTE or RSTS, the upper byte has to be | ||
124 | * 0x5a.. | ||
125 | */ | ||
126 | csr = sh_wdt_read_rstcsr(); | 111 | csr = sh_wdt_read_rstcsr(); |
127 | csr &= ~RSTCSR_RSTS; | 112 | csr &= ~RSTCSR_RSTS; |
128 | sh_wdt_write_rstcsr(csr); | 113 | sh_wdt_write_rstcsr(csr); |
@@ -130,10 +115,6 @@ static void sh_wdt_start(void) | |||
130 | spin_unlock_irqrestore(&shwdt_lock, flags); | 115 | spin_unlock_irqrestore(&shwdt_lock, flags); |
131 | } | 116 | } |
132 | 117 | ||
133 | /** | ||
134 | * sh_wdt_stop - Stop the Watchdog | ||
135 | * Stops the watchdog. | ||
136 | */ | ||
137 | static void sh_wdt_stop(void) | 118 | static void sh_wdt_stop(void) |
138 | { | 119 | { |
139 | __u8 csr; | 120 | __u8 csr; |
@@ -149,10 +130,6 @@ static void sh_wdt_stop(void) | |||
149 | spin_unlock_irqrestore(&shwdt_lock, flags); | 130 | spin_unlock_irqrestore(&shwdt_lock, flags); |
150 | } | 131 | } |
151 | 132 | ||
152 | /** | ||
153 | * sh_wdt_keepalive - Keep the Userspace Watchdog Alive | ||
154 | * The Userspace watchdog got a KeepAlive: schedule the next heartbeat. | ||
155 | */ | ||
156 | static inline void sh_wdt_keepalive(void) | 133 | static inline void sh_wdt_keepalive(void) |
157 | { | 134 | { |
158 | unsigned long flags; | 135 | unsigned long flags; |
@@ -162,10 +139,6 @@ static inline void sh_wdt_keepalive(void) | |||
162 | spin_unlock_irqrestore(&shwdt_lock, flags); | 139 | spin_unlock_irqrestore(&shwdt_lock, flags); |
163 | } | 140 | } |
164 | 141 | ||
165 | /** | ||
166 | * sh_wdt_set_heartbeat - Set the Userspace Watchdog heartbeat | ||
167 | * Set the Userspace Watchdog heartbeat | ||
168 | */ | ||
169 | static int sh_wdt_set_heartbeat(int t) | 142 | static int sh_wdt_set_heartbeat(int t) |
170 | { | 143 | { |
171 | unsigned long flags; | 144 | unsigned long flags; |
@@ -179,12 +152,6 @@ static int sh_wdt_set_heartbeat(int t) | |||
179 | return 0; | 152 | return 0; |
180 | } | 153 | } |
181 | 154 | ||
182 | /** | ||
183 | * sh_wdt_ping - Ping the Watchdog | ||
184 | * @data: Unused | ||
185 | * | ||
186 | * Clears overflow bit, resets timer counter. | ||
187 | */ | ||
188 | static void sh_wdt_ping(unsigned long data) | 155 | static void sh_wdt_ping(unsigned long data) |
189 | { | 156 | { |
190 | unsigned long flags; | 157 | unsigned long flags; |
@@ -206,13 +173,6 @@ static void sh_wdt_ping(unsigned long data) | |||
206 | spin_unlock_irqrestore(&shwdt_lock, flags); | 173 | spin_unlock_irqrestore(&shwdt_lock, flags); |
207 | } | 174 | } |
208 | 175 | ||
209 | /** | ||
210 | * sh_wdt_open - Open the Device | ||
211 | * @inode: inode of device | ||
212 | * @file: file handle of device | ||
213 | * | ||
214 | * Watchdog device is opened and started. | ||
215 | */ | ||
216 | static int sh_wdt_open(struct inode *inode, struct file *file) | 176 | static int sh_wdt_open(struct inode *inode, struct file *file) |
217 | { | 177 | { |
218 | if (test_and_set_bit(0, &shwdt_is_open)) | 178 | if (test_and_set_bit(0, &shwdt_is_open)) |
@@ -225,13 +185,6 @@ static int sh_wdt_open(struct inode *inode, struct file *file) | |||
225 | return nonseekable_open(inode, file); | 185 | return nonseekable_open(inode, file); |
226 | } | 186 | } |
227 | 187 | ||
228 | /** | ||
229 | * sh_wdt_close - Close the Device | ||
230 | * @inode: inode of device | ||
231 | * @file: file handle of device | ||
232 | * | ||
233 | * Watchdog device is closed and stopped. | ||
234 | */ | ||
235 | static int sh_wdt_close(struct inode *inode, struct file *file) | 188 | static int sh_wdt_close(struct inode *inode, struct file *file) |
236 | { | 189 | { |
237 | if (shwdt_expect_close == 42) { | 190 | if (shwdt_expect_close == 42) { |
@@ -248,15 +201,6 @@ static int sh_wdt_close(struct inode *inode, struct file *file) | |||
248 | return 0; | 201 | return 0; |
249 | } | 202 | } |
250 | 203 | ||
251 | /** | ||
252 | * sh_wdt_write - Write to Device | ||
253 | * @file: file handle of device | ||
254 | * @buf: buffer to write | ||
255 | * @count: length of buffer | ||
256 | * @ppos: offset | ||
257 | * | ||
258 | * Pings the watchdog on write. | ||
259 | */ | ||
260 | static ssize_t sh_wdt_write(struct file *file, const char *buf, | 204 | static ssize_t sh_wdt_write(struct file *file, const char *buf, |
261 | size_t count, loff_t *ppos) | 205 | size_t count, loff_t *ppos) |
262 | { | 206 | { |
@@ -280,64 +224,6 @@ static ssize_t sh_wdt_write(struct file *file, const char *buf, | |||
280 | return count; | 224 | return count; |
281 | } | 225 | } |
282 | 226 | ||
283 | /** | ||
284 | * sh_wdt_mmap - map WDT/CPG registers into userspace | ||
285 | * @file: file structure for the device | ||
286 | * @vma: VMA to map the registers into | ||
287 | * | ||
288 | * A simple mmap() implementation for the corner cases where the counter | ||
289 | * needs to be mapped in userspace directly. Due to the relatively small | ||
290 | * size of the area, neighbouring registers not necessarily tied to the | ||
291 | * CPG will also be accessible through the register page, so this remains | ||
292 | * configurable for users that really know what they're doing. | ||
293 | * | ||
294 | * Additionaly, the register page maps in the CPG register base relative | ||
295 | * to the nearest page-aligned boundary, which requires that userspace do | ||
296 | * the appropriate CPU subtype math for calculating the page offset for | ||
297 | * the counter value. | ||
298 | */ | ||
299 | static int sh_wdt_mmap(struct file *file, struct vm_area_struct *vma) | ||
300 | { | ||
301 | int ret = -ENOSYS; | ||
302 | |||
303 | #ifdef CONFIG_SH_WDT_MMAP | ||
304 | unsigned long addr; | ||
305 | |||
306 | /* Only support the simple cases where we map in a register page. */ | ||
307 | if (((vma->vm_end - vma->vm_start) != PAGE_SIZE) || vma->vm_pgoff) | ||
308 | return -EINVAL; | ||
309 | |||
310 | /* | ||
311 | * Pick WTCNT as the start, it's usually the first register after the | ||
312 | * FRQCR, and neither one are generally page-aligned out of the box. | ||
313 | */ | ||
314 | addr = WTCNT & ~(PAGE_SIZE - 1); | ||
315 | |||
316 | vma->vm_flags |= VM_IO; | ||
317 | vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); | ||
318 | |||
319 | if (io_remap_pfn_range(vma, vma->vm_start, addr >> PAGE_SHIFT, | ||
320 | PAGE_SIZE, vma->vm_page_prot)) { | ||
321 | printk(KERN_ERR PFX "%s: io_remap_pfn_range failed\n", | ||
322 | __func__); | ||
323 | return -EAGAIN; | ||
324 | } | ||
325 | |||
326 | ret = 0; | ||
327 | #endif | ||
328 | |||
329 | return ret; | ||
330 | } | ||
331 | |||
332 | /** | ||
333 | * sh_wdt_ioctl - Query Device | ||
334 | * @file: file handle of device | ||
335 | * @cmd: watchdog command | ||
336 | * @arg: argument | ||
337 | * | ||
338 | * Query basic information from the device or ping it, as outlined by the | ||
339 | * watchdog API. | ||
340 | */ | ||
341 | static long sh_wdt_ioctl(struct file *file, unsigned int cmd, | 227 | static long sh_wdt_ioctl(struct file *file, unsigned int cmd, |
342 | unsigned long arg) | 228 | unsigned long arg) |
343 | { | 229 | { |
@@ -386,15 +272,6 @@ static long sh_wdt_ioctl(struct file *file, unsigned int cmd, | |||
386 | return 0; | 272 | return 0; |
387 | } | 273 | } |
388 | 274 | ||
389 | /** | ||
390 | * sh_wdt_notify_sys - Notifier Handler | ||
391 | * @this: notifier block | ||
392 | * @code: notifier event | ||
393 | * @unused: unused | ||
394 | * | ||
395 | * Handles specific events, such as turning off the watchdog during a | ||
396 | * shutdown event. | ||
397 | */ | ||
398 | static int sh_wdt_notify_sys(struct notifier_block *this, | 275 | static int sh_wdt_notify_sys(struct notifier_block *this, |
399 | unsigned long code, void *unused) | 276 | unsigned long code, void *unused) |
400 | { | 277 | { |
@@ -411,7 +288,6 @@ static const struct file_operations sh_wdt_fops = { | |||
411 | .unlocked_ioctl = sh_wdt_ioctl, | 288 | .unlocked_ioctl = sh_wdt_ioctl, |
412 | .open = sh_wdt_open, | 289 | .open = sh_wdt_open, |
413 | .release = sh_wdt_close, | 290 | .release = sh_wdt_close, |
414 | .mmap = sh_wdt_mmap, | ||
415 | }; | 291 | }; |
416 | 292 | ||
417 | static const struct watchdog_info sh_wdt_info = { | 293 | static const struct watchdog_info sh_wdt_info = { |
@@ -431,11 +307,6 @@ static struct miscdevice sh_wdt_miscdev = { | |||
431 | .fops = &sh_wdt_fops, | 307 | .fops = &sh_wdt_fops, |
432 | }; | 308 | }; |
433 | 309 | ||
434 | /** | ||
435 | * sh_wdt_init - Initialize module | ||
436 | * Registers the device and notifier handler. Actual device | ||
437 | * initialization is handled by sh_wdt_open(). | ||
438 | */ | ||
439 | static int __init sh_wdt_init(void) | 310 | static int __init sh_wdt_init(void) |
440 | { | 311 | { |
441 | int rc; | 312 | int rc; |
@@ -477,11 +348,6 @@ static int __init sh_wdt_init(void) | |||
477 | return 0; | 348 | return 0; |
478 | } | 349 | } |
479 | 350 | ||
480 | /** | ||
481 | * sh_wdt_exit - Deinitialize module | ||
482 | * Unregisters the device and notifier handler. Actual device | ||
483 | * deinitialization is handled by sh_wdt_close(). | ||
484 | */ | ||
485 | static void __exit sh_wdt_exit(void) | 351 | static void __exit sh_wdt_exit(void) |
486 | { | 352 | { |
487 | misc_deregister(&sh_wdt_miscdev); | 353 | misc_deregister(&sh_wdt_miscdev); |