Skip to content

Commit 694b16b

Browse files
Alan CoxWim Van Sebroeck
authored andcommitted
[WATCHDOG 53/57] wafer5823wdt: Clean up, coding style, switch to unlocked_ioctl
Review and switch to unlocked_ioctl Signed-off-by: Alan Cox <alan@redhat.com> Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
1 parent 84af401 commit 694b16b

File tree

1 file changed

+46
-34
lines changed

1 file changed

+46
-34
lines changed

drivers/watchdog/wafer5823wdt.c

Lines changed: 46 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@
3636
#include <linux/reboot.h>
3737
#include <linux/init.h>
3838
#include <linux/spinlock.h>
39-
#include <asm/io.h>
40-
#include <asm/uaccess.h>
39+
#include <linux/io.h>
40+
#include <linux/uaccess.h>
4141

4242
#define WATCHDOG_NAME "Wafer 5823 WDT"
4343
#define PFX WATCHDOG_NAME ": "
@@ -61,11 +61,15 @@ static int wdt_start = 0x443;
6161

6262
static int timeout = WD_TIMO; /* in seconds */
6363
module_param(timeout, int, 0);
64-
MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds. 1<= timeout <=255, default=" __MODULE_STRING(WD_TIMO) ".");
64+
MODULE_PARM_DESC(timeout,
65+
"Watchdog timeout in seconds. 1 <= timeout <= 255, default="
66+
__MODULE_STRING(WD_TIMO) ".");
6567

6668
static int nowayout = WATCHDOG_NOWAYOUT;
6769
module_param(nowayout, int, 0);
68-
MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
70+
MODULE_PARM_DESC(nowayout,
71+
"Watchdog cannot be stopped once started (default="
72+
__MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
6973

7074
static void wafwdt_ping(void)
7175
{
@@ -90,7 +94,8 @@ wafwdt_stop(void)
9094
inb_p(wdt_stop);
9195
}
9296

93-
static ssize_t wafwdt_write(struct file *file, const char __user *buf, size_t count, loff_t * ppos)
97+
static ssize_t wafwdt_write(struct file *file, const char __user *buf,
98+
size_t count, loff_t *ppos)
9499
{
95100
/* See if we got the magic character 'V' and reload the timer */
96101
if (count) {
@@ -100,7 +105,8 @@ static ssize_t wafwdt_write(struct file *file, const char __user *buf, size_t co
100105
/* In case it was set long ago */
101106
expect_close = 0;
102107

103-
/* scan to see whether or not we got the magic character */
108+
/* scan to see whether or not we got the magic
109+
character */
104110
for (i = 0; i != count; i++) {
105111
char c;
106112
if (get_user(c, buf + i))
@@ -109,27 +115,29 @@ static ssize_t wafwdt_write(struct file *file, const char __user *buf, size_t co
109115
expect_close = 42;
110116
}
111117
}
112-
/* Well, anyhow someone wrote to us, we should return that favour */
118+
/* Well, anyhow someone wrote to us, we should
119+
return that favour */
113120
wafwdt_ping();
114121
}
115122
return count;
116123
}
117124

118-
static int wafwdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
119-
unsigned long arg)
125+
static long wafwdt_ioctl(struct file *file, unsigned int cmd,
126+
unsigned long arg)
120127
{
121128
int new_timeout;
122129
void __user *argp = (void __user *)arg;
123130
int __user *p = argp;
124-
static struct watchdog_info ident = {
125-
.options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE,
131+
static const struct watchdog_info ident = {
132+
.options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT |
133+
WDIOF_MAGICCLOSE,
126134
.firmware_version = 1,
127135
.identity = "Wafer 5823 WDT",
128136
};
129137

130138
switch (cmd) {
131139
case WDIOC_GETSUPPORT:
132-
if (copy_to_user(argp, &ident, sizeof (ident)))
140+
if (copy_to_user(argp, &ident, sizeof(ident)))
133141
return -EFAULT;
134142
break;
135143

@@ -194,10 +202,11 @@ static int wafwdt_open(struct inode *inode, struct file *file)
194202
static int
195203
wafwdt_close(struct inode *inode, struct file *file)
196204
{
197-
if (expect_close == 42) {
205+
if (expect_close == 42)
198206
wafwdt_stop();
199-
} else {
200-
printk(KERN_CRIT PFX "WDT device closed unexpectedly. WDT will not stop!\n");
207+
else {
208+
printk(KERN_CRIT PFX
209+
"WDT device closed unexpectedly. WDT will not stop!\n");
201210
wafwdt_ping();
202211
}
203212
clear_bit(0, &wafwdt_is_open);
@@ -209,12 +218,11 @@ wafwdt_close(struct inode *inode, struct file *file)
209218
* Notifier for system down
210219
*/
211220

212-
static int wafwdt_notify_sys(struct notifier_block *this, unsigned long code, void *unused)
221+
static int wafwdt_notify_sys(struct notifier_block *this, unsigned long code,
222+
void *unused)
213223
{
214-
if (code == SYS_DOWN || code == SYS_HALT) {
215-
/* Turn the WDT off */
224+
if (code == SYS_DOWN || code == SYS_HALT)
216225
wafwdt_stop();
217-
}
218226
return NOTIFY_DONE;
219227
}
220228

@@ -226,7 +234,7 @@ static const struct file_operations wafwdt_fops = {
226234
.owner = THIS_MODULE,
227235
.llseek = no_llseek,
228236
.write = wafwdt_write,
229-
.ioctl = wafwdt_ioctl,
237+
.unlocked_ioctl = wafwdt_ioctl,
230238
.open = wafwdt_open,
231239
.release = wafwdt_close,
232240
};
@@ -250,45 +258,49 @@ static int __init wafwdt_init(void)
250258
{
251259
int ret;
252260

253-
printk(KERN_INFO "WDT driver for Wafer 5823 single board computer initialising.\n");
261+
printk(KERN_INFO
262+
"WDT driver for Wafer 5823 single board computer initialising.\n");
254263

255264
if (timeout < 1 || timeout > 255) {
256265
timeout = WD_TIMO;
257-
printk (KERN_INFO PFX "timeout value must be 1<=x<=255, using %d\n",
258-
timeout);
266+
printk(KERN_INFO PFX
267+
"timeout value must be 1 <= x <= 255, using %d\n",
268+
timeout);
259269
}
260270

261271
if (wdt_stop != wdt_start) {
262-
if(!request_region(wdt_stop, 1, "Wafer 5823 WDT")) {
263-
printk (KERN_ERR PFX "I/O address 0x%04x already in use\n",
264-
wdt_stop);
272+
if (!request_region(wdt_stop, 1, "Wafer 5823 WDT")) {
273+
printk(KERN_ERR PFX
274+
"I/O address 0x%04x already in use\n",
275+
wdt_stop);
265276
ret = -EIO;
266277
goto error;
267278
}
268279
}
269280

270-
if(!request_region(wdt_start, 1, "Wafer 5823 WDT")) {
271-
printk (KERN_ERR PFX "I/O address 0x%04x already in use\n",
281+
if (!request_region(wdt_start, 1, "Wafer 5823 WDT")) {
282+
printk(KERN_ERR PFX "I/O address 0x%04x already in use\n",
272283
wdt_start);
273284
ret = -EIO;
274285
goto error2;
275286
}
276287

277288
ret = register_reboot_notifier(&wafwdt_notifier);
278289
if (ret != 0) {
279-
printk (KERN_ERR PFX "cannot register reboot notifier (err=%d)\n",
280-
ret);
290+
printk(KERN_ERR PFX
291+
"cannot register reboot notifier (err=%d)\n", ret);
281292
goto error3;
282293
}
283294

284295
ret = misc_register(&wafwdt_miscdev);
285296
if (ret != 0) {
286-
printk (KERN_ERR PFX "cannot register miscdev on minor=%d (err=%d)\n",
287-
WATCHDOG_MINOR, ret);
297+
printk(KERN_ERR PFX
298+
"cannot register miscdev on minor=%d (err=%d)\n",
299+
WATCHDOG_MINOR, ret);
288300
goto error4;
289301
}
290302

291-
printk (KERN_INFO PFX "initialized. timeout=%d sec (nowayout=%d)\n",
303+
printk(KERN_INFO PFX "initialized. timeout=%d sec (nowayout=%d)\n",
292304
timeout, nowayout);
293305

294306
return ret;
@@ -307,7 +319,7 @@ static void __exit wafwdt_exit(void)
307319
{
308320
misc_deregister(&wafwdt_miscdev);
309321
unregister_reboot_notifier(&wafwdt_notifier);
310-
if(wdt_stop != wdt_start)
322+
if (wdt_stop != wdt_start)
311323
release_region(wdt_stop, 1);
312324
release_region(wdt_start, 1);
313325
}

0 commit comments

Comments
 (0)