Skip to content

Commit dae67a2

Browse files
Alan CoxWim Van Sebroeck
authored andcommitted
[WATCHDOG 54/57] wdrtas: 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 694b16b commit dae67a2

File tree

1 file changed

+41
-62
lines changed

1 file changed

+41
-62
lines changed

drivers/watchdog/wdrtas.c

Lines changed: 41 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@
3535
#include <linux/reboot.h>
3636
#include <linux/types.h>
3737
#include <linux/watchdog.h>
38+
#include <linux/uaccess.h>
3839

3940
#include <asm/rtas.h>
40-
#include <asm/uaccess.h>
4141

4242
#define WDRTAS_MAGIC_CHAR 42
4343
#define WDRTAS_SUPPORTED_MASK (WDIOF_SETTIMEOUT | \
@@ -56,7 +56,7 @@ static int wdrtas_nowayout = 0;
5656
#endif
5757

5858
static atomic_t wdrtas_miscdev_open = ATOMIC_INIT(0);
59-
static char wdrtas_expect_close = 0;
59+
static char wdrtas_expect_close;
6060

6161
static int wdrtas_interval;
6262

@@ -86,8 +86,8 @@ static char wdrtas_logbuffer[WDRTAS_LOGBUFFER_LEN];
8686
* RTAS function set-indicator (surveillance). The unit of interval is
8787
* seconds.
8888
*/
89-
static int
90-
wdrtas_set_interval(int interval)
89+
90+
static int wdrtas_set_interval(int interval)
9191
{
9292
long result;
9393
static int print_msg = 10;
@@ -97,7 +97,7 @@ wdrtas_set_interval(int interval)
9797

9898
result = rtas_call(wdrtas_token_set_indicator, 3, 1, NULL,
9999
WDRTAS_SURVEILLANCE_IND, 0, interval);
100-
if ( (result < 0) && (print_msg) ) {
100+
if (result < 0 && print_msg) {
101101
printk(KERN_ERR "wdrtas: setting the watchdog to %i "
102102
"timeout failed: %li\n", interval, result);
103103
print_msg--;
@@ -116,16 +116,14 @@ wdrtas_set_interval(int interval)
116116
* as reported by the RTAS function ibm,get-system-parameter. The unit
117117
* of the return value is seconds.
118118
*/
119-
static int
120-
wdrtas_get_interval(int fallback_value)
119+
static int wdrtas_get_interval(int fallback_value)
121120
{
122121
long result;
123122
char value[4];
124123

125124
result = rtas_call(wdrtas_token_get_sp, 3, 1, NULL,
126125
WDRTAS_SP_SPI, (void *)__pa(&value), 4);
127-
if ( (value[0] != 0) || (value[1] != 2) || (value[3] != 0) ||
128-
(result < 0) ) {
126+
if (value[0] != 0 || value[1] != 2 || value[3] != 0 || result < 0) {
129127
printk(KERN_WARNING "wdrtas: could not get sp_spi watchdog "
130128
"timeout (%li). Continuing\n", result);
131129
return fallback_value;
@@ -141,8 +139,7 @@ wdrtas_get_interval(int fallback_value)
141139
* wdrtas_timer_start starts the watchdog by calling the RTAS function
142140
* set-interval (surveillance)
143141
*/
144-
static void
145-
wdrtas_timer_start(void)
142+
static void wdrtas_timer_start(void)
146143
{
147144
wdrtas_set_interval(wdrtas_interval);
148145
}
@@ -153,8 +150,7 @@ wdrtas_timer_start(void)
153150
* wdrtas_timer_stop stops the watchdog timer by calling the RTAS function
154151
* set-interval (surveillance)
155152
*/
156-
static void
157-
wdrtas_timer_stop(void)
153+
static void wdrtas_timer_stop(void)
158154
{
159155
wdrtas_set_interval(0);
160156
}
@@ -165,8 +161,7 @@ wdrtas_timer_stop(void)
165161
* wdrtas_log_scanned_event prints a message to the log buffer dumping
166162
* the results of the last event-scan call
167163
*/
168-
static void
169-
wdrtas_log_scanned_event(void)
164+
static void wdrtas_log_scanned_event(void)
170165
{
171166
int i;
172167

@@ -175,13 +170,13 @@ wdrtas_log_scanned_event(void)
175170
"%02x %02x %02x %02x %02x %02x %02x %02x "
176171
"%02x %02x %02x %02x %02x %02x %02x %02x\n",
177172
(i / 16) + 1, (WDRTAS_LOGBUFFER_LEN / 16),
178-
wdrtas_logbuffer[i + 0], wdrtas_logbuffer[i + 1],
179-
wdrtas_logbuffer[i + 2], wdrtas_logbuffer[i + 3],
180-
wdrtas_logbuffer[i + 4], wdrtas_logbuffer[i + 5],
181-
wdrtas_logbuffer[i + 6], wdrtas_logbuffer[i + 7],
182-
wdrtas_logbuffer[i + 8], wdrtas_logbuffer[i + 9],
183-
wdrtas_logbuffer[i + 10], wdrtas_logbuffer[i + 11],
184-
wdrtas_logbuffer[i + 12], wdrtas_logbuffer[i + 13],
173+
wdrtas_logbuffer[i + 0], wdrtas_logbuffer[i + 1],
174+
wdrtas_logbuffer[i + 2], wdrtas_logbuffer[i + 3],
175+
wdrtas_logbuffer[i + 4], wdrtas_logbuffer[i + 5],
176+
wdrtas_logbuffer[i + 6], wdrtas_logbuffer[i + 7],
177+
wdrtas_logbuffer[i + 8], wdrtas_logbuffer[i + 9],
178+
wdrtas_logbuffer[i + 10], wdrtas_logbuffer[i + 11],
179+
wdrtas_logbuffer[i + 12], wdrtas_logbuffer[i + 13],
185180
wdrtas_logbuffer[i + 14], wdrtas_logbuffer[i + 15]);
186181
}
187182

@@ -192,8 +187,7 @@ wdrtas_log_scanned_event(void)
192187
* RTAS function event-scan and repeats these calls as long as there are
193188
* events available. All events will be dumped.
194189
*/
195-
static void
196-
wdrtas_timer_keepalive(void)
190+
static void wdrtas_timer_keepalive(void)
197191
{
198192
long result;
199193

@@ -218,8 +212,7 @@ wdrtas_timer_keepalive(void)
218212
* wdrtas_get_temperature returns the current temperature in Fahrenheit. It
219213
* uses the RTAS call get-sensor-state, token 3 to do so
220214
*/
221-
static int
222-
wdrtas_get_temperature(void)
215+
static int wdrtas_get_temperature(void)
223216
{
224217
long result;
225218
int temperature = 0;
@@ -243,8 +236,7 @@ wdrtas_get_temperature(void)
243236
* returns a bitmask of defines WDIOF_... as defined in
244237
* include/linux/watchdog.h
245238
*/
246-
static int
247-
wdrtas_get_status(void)
239+
static int wdrtas_get_status(void)
248240
{
249241
return 0; /* TODO */
250242
}
@@ -255,8 +247,7 @@ wdrtas_get_status(void)
255247
* returns a bitmask of defines WDIOF_... as defined in
256248
* include/linux/watchdog.h, indicating why the watchdog rebooted the system
257249
*/
258-
static int
259-
wdrtas_get_boot_status(void)
250+
static int wdrtas_get_boot_status(void)
260251
{
261252
return 0; /* TODO */
262253
}
@@ -276,8 +267,7 @@ wdrtas_get_boot_status(void)
276267
* character 'V'. This character allows the watchdog device to be closed
277268
* properly.
278269
*/
279-
static ssize_t
280-
wdrtas_write(struct file *file, const char __user *buf,
270+
static ssize_t wdrtas_write(struct file *file, const char __user *buf,
281271
size_t len, loff_t *ppos)
282272
{
283273
int i;
@@ -306,7 +296,6 @@ wdrtas_write(struct file *file, const char __user *buf,
306296

307297
/**
308298
* wdrtas_ioctl - ioctl function for the watchdog device
309-
* @inode: inode structure
310299
* @file: file structure
311300
* @cmd: command for ioctl
312301
* @arg: argument pointer
@@ -315,9 +304,9 @@ wdrtas_write(struct file *file, const char __user *buf,
315304
*
316305
* wdrtas_ioctl implements the watchdog API ioctls
317306
*/
318-
static int
319-
wdrtas_ioctl(struct inode *inode, struct file *file,
320-
unsigned int cmd, unsigned long arg)
307+
308+
static long wdrtas_ioctl(struct file *file, unsigned int cmd,
309+
unsigned long arg)
321310
{
322311
int __user *argp = (void __user *)arg;
323312
int i;
@@ -357,9 +346,9 @@ wdrtas_ioctl(struct inode *inode, struct file *file,
357346
wdrtas_timer_keepalive();
358347
wdrtas_timer_start();
359348
}
349+
/* not implemented. Done by H8
360350
if (i & WDIOS_TEMPPANIC) {
361-
/* not implemented. Done by H8 */
362-
}
351+
} */
363352
return 0;
364353

365354
case WDIOC_KEEPALIVE:
@@ -399,8 +388,7 @@ wdrtas_ioctl(struct inode *inode, struct file *file,
399388
*
400389
* function called when watchdog device is opened
401390
*/
402-
static int
403-
wdrtas_open(struct inode *inode, struct file *file)
391+
static int wdrtas_open(struct inode *inode, struct file *file)
404392
{
405393
/* only open once */
406394
if (atomic_inc_return(&wdrtas_miscdev_open) > 1) {
@@ -423,8 +411,7 @@ wdrtas_open(struct inode *inode, struct file *file)
423411
*
424412
* close function. Always succeeds
425413
*/
426-
static int
427-
wdrtas_close(struct inode *inode, struct file *file)
414+
static int wdrtas_close(struct inode *inode, struct file *file)
428415
{
429416
/* only stop watchdog, if this was announced using 'V' before */
430417
if (wdrtas_expect_close == WDRTAS_MAGIC_CHAR)
@@ -453,8 +440,7 @@ wdrtas_close(struct inode *inode, struct file *file)
453440
* wdrtas_temp_read gives the temperature to the users by copying this
454441
* value as one byte into the user space buffer. The unit is Fahrenheit...
455442
*/
456-
static ssize_t
457-
wdrtas_temp_read(struct file *file, char __user *buf,
443+
static ssize_t wdrtas_temp_read(struct file *file, char __user *buf,
458444
size_t count, loff_t *ppos)
459445
{
460446
int temperature = 0;
@@ -478,8 +464,7 @@ wdrtas_temp_read(struct file *file, char __user *buf,
478464
*
479465
* function called when temperature device is opened
480466
*/
481-
static int
482-
wdrtas_temp_open(struct inode *inode, struct file *file)
467+
static int wdrtas_temp_open(struct inode *inode, struct file *file)
483468
{
484469
return nonseekable_open(inode, file);
485470
}
@@ -493,8 +478,7 @@ wdrtas_temp_open(struct inode *inode, struct file *file)
493478
*
494479
* close function. Always succeeds
495480
*/
496-
static int
497-
wdrtas_temp_close(struct inode *inode, struct file *file)
481+
static int wdrtas_temp_close(struct inode *inode, struct file *file)
498482
{
499483
return 0;
500484
}
@@ -509,10 +493,10 @@ wdrtas_temp_close(struct inode *inode, struct file *file)
509493
*
510494
* wdrtas_reboot stops the watchdog in case of a reboot
511495
*/
512-
static int
513-
wdrtas_reboot(struct notifier_block *this, unsigned long code, void *ptr)
496+
static int wdrtas_reboot(struct notifier_block *this,
497+
unsigned long code, void *ptr)
514498
{
515-
if ( (code==SYS_DOWN) || (code==SYS_HALT) )
499+
if (code == SYS_DOWN || code == SYS_HALT)
516500
wdrtas_timer_stop();
517501

518502
return NOTIFY_DONE;
@@ -524,7 +508,7 @@ static const struct file_operations wdrtas_fops = {
524508
.owner = THIS_MODULE,
525509
.llseek = no_llseek,
526510
.write = wdrtas_write,
527-
.ioctl = wdrtas_ioctl,
511+
.unlocked_ioctl = wdrtas_ioctl,
528512
.open = wdrtas_open,
529513
.release = wdrtas_close,
530514
};
@@ -562,8 +546,7 @@ static struct notifier_block wdrtas_notifier = {
562546
* this watchdog driver. It tolerates, if "get-sensor-state" and
563547
* "ibm,get-system-parameter" are not available.
564548
*/
565-
static int
566-
wdrtas_get_tokens(void)
549+
static int wdrtas_get_tokens(void)
567550
{
568551
wdrtas_token_get_sensor_state = rtas_token("get-sensor-state");
569552
if (wdrtas_token_get_sensor_state == RTAS_UNKNOWN_SERVICE) {
@@ -603,8 +586,7 @@ wdrtas_get_tokens(void)
603586
* wdrtas_register_devs unregisters the watchdog and temperature watchdog
604587
* misc devs
605588
*/
606-
static void
607-
wdrtas_unregister_devs(void)
589+
static void wdrtas_unregister_devs(void)
608590
{
609591
misc_deregister(&wdrtas_miscdev);
610592
if (wdrtas_token_get_sensor_state != RTAS_UNKNOWN_SERVICE)
@@ -619,8 +601,7 @@ wdrtas_unregister_devs(void)
619601
* wdrtas_register_devs registers the watchdog and temperature watchdog
620602
* misc devs
621603
*/
622-
static int
623-
wdrtas_register_devs(void)
604+
static int wdrtas_register_devs(void)
624605
{
625606
int result;
626607

@@ -651,8 +632,7 @@ wdrtas_register_devs(void)
651632
*
652633
* registers the file handlers and the reboot notifier
653634
*/
654-
static int __init
655-
wdrtas_init(void)
635+
static int __init wdrtas_init(void)
656636
{
657637
if (wdrtas_get_tokens())
658638
return -ENODEV;
@@ -680,8 +660,7 @@ wdrtas_init(void)
680660
*
681661
* unregisters the file handlers and the reboot notifier
682662
*/
683-
static void __exit
684-
wdrtas_exit(void)
663+
static void __exit wdrtas_exit(void)
685664
{
686665
if (!wdrtas_nowayout)
687666
wdrtas_timer_stop();

0 commit comments

Comments
 (0)