Commit 927d6961 authored by Wim Van Sebroeck's avatar Wim Van Sebroeck

[WATCHDOG] cpwd.c: Coding style - Clean-up

This brings the cpwd.c watchdog driver in line with the kernel's coding style.
Signed-off-by: default avatarWim Van Sebroeck <wim@iguana.be>
parent d8100c3a
/* cpwd.c - driver implementation for hardware watchdog /* cpwd.c - driver implementation for hardware watchdog
* timers found on Sun Microsystems CP1400 and CP1500 boards. * timers found on Sun Microsystems CP1400 and CP1500 boards.
* *
* This device supports both the generic Linux watchdog * This device supports both the generic Linux watchdog
* interface and Solaris-compatible ioctls as best it is * interface and Solaris-compatible ioctls as best it is
* able. * able.
* *
* NOTE: CP1400 systems appear to have a defective intr_mask * NOTE: CP1400 systems appear to have a defective intr_mask
* register on the PLD, preventing the disabling of * register on the PLD, preventing the disabling of
* timer interrupts. We use a timer to periodically * timer interrupts. We use a timer to periodically
* reset 'stopped' watchdogs on affected platforms. * reset 'stopped' watchdogs on affected platforms.
* *
* Copyright (c) 2000 Eric Brower (ebrower@usa.net) * Copyright (c) 2000 Eric Brower (ebrower@usa.net)
...@@ -43,8 +43,8 @@ ...@@ -43,8 +43,8 @@
#define WD_BLIMIT 0xFFFF #define WD_BLIMIT 0xFFFF
#define WD0_MINOR 212 #define WD0_MINOR 212
#define WD1_MINOR 213 #define WD1_MINOR 213
#define WD2_MINOR 214 #define WD2_MINOR 214
/* Internal driver definitions. */ /* Internal driver definitions. */
#define WD0_ID 0 #define WD0_ID 0
...@@ -91,16 +91,16 @@ struct cpwd { ...@@ -91,16 +91,16 @@ struct cpwd {
static struct cpwd *cpwd_device; static struct cpwd *cpwd_device;
/* Sun uses Altera PLD EPF8820ATC144-4 /* Sun uses Altera PLD EPF8820ATC144-4
* providing three hardware watchdogs: * providing three hardware watchdogs:
* *
* 1) RIC - sends an interrupt when triggered * 1) RIC - sends an interrupt when triggered
* 2) XIR - asserts XIR_B_RESET when triggered, resets CPU * 2) XIR - asserts XIR_B_RESET when triggered, resets CPU
* 3) POR - asserts POR_B_RESET when triggered, resets CPU, backplane, board * 3) POR - asserts POR_B_RESET when triggered, resets CPU, backplane, board
* *
*** Timer register block definition (struct wd_timer_regblk) *** Timer register block definition (struct wd_timer_regblk)
* *
* dcntr and limit registers (halfword access): * dcntr and limit registers (halfword access):
* ------------------- * -------------------
* | 15 | ...| 1 | 0 | * | 15 | ...| 1 | 0 |
* ------------------- * -------------------
...@@ -108,7 +108,8 @@ static struct cpwd *cpwd_device; ...@@ -108,7 +108,8 @@ static struct cpwd *cpwd_device;
* ------------------- * -------------------
* dcntr - Current 16-bit downcounter value. * dcntr - Current 16-bit downcounter value.
* When downcounter reaches '0' watchdog expires. * When downcounter reaches '0' watchdog expires.
* Reading this register resets downcounter with 'limit' value. * Reading this register resets downcounter with
* 'limit' value.
* limit - 16-bit countdown value in 1/10th second increments. * limit - 16-bit countdown value in 1/10th second increments.
* Writing this register begins countdown with input value. * Writing this register begins countdown with input value.
* Reading from this register does not affect counter. * Reading from this register does not affect counter.
...@@ -158,11 +159,11 @@ static int wd0_timeout = 0; ...@@ -158,11 +159,11 @@ static int wd0_timeout = 0;
static int wd1_timeout = 0; static int wd1_timeout = 0;
static int wd2_timeout = 0; static int wd2_timeout = 0;
module_param (wd0_timeout, int, 0); module_param(wd0_timeout, int, 0);
MODULE_PARM_DESC(wd0_timeout, "Default watchdog0 timeout in 1/10secs"); MODULE_PARM_DESC(wd0_timeout, "Default watchdog0 timeout in 1/10secs");
module_param (wd1_timeout, int, 0); module_param(wd1_timeout, int, 0);
MODULE_PARM_DESC(wd1_timeout, "Default watchdog1 timeout in 1/10secs"); MODULE_PARM_DESC(wd1_timeout, "Default watchdog1 timeout in 1/10secs");
module_param (wd2_timeout, int, 0); module_param(wd2_timeout, int, 0);
MODULE_PARM_DESC(wd2_timeout, "Default watchdog2 timeout in 1/10secs"); MODULE_PARM_DESC(wd2_timeout, "Default watchdog2 timeout in 1/10secs");
MODULE_AUTHOR("Eric Brower <ebrower@usa.net>"); MODULE_AUTHOR("Eric Brower <ebrower@usa.net>");
...@@ -201,9 +202,9 @@ static u8 cpwd_readb(void __iomem *addr) ...@@ -201,9 +202,9 @@ static u8 cpwd_readb(void __iomem *addr)
static void cpwd_toggleintr(struct cpwd *p, int index, int enable) static void cpwd_toggleintr(struct cpwd *p, int index, int enable)
{ {
unsigned char curregs = cpwd_readb(p->regs + PLD_IMASK); unsigned char curregs = cpwd_readb(p->regs + PLD_IMASK);
unsigned char setregs = unsigned char setregs =
(index == -1) ? (index == -1) ?
(WD0_INTR_MASK | WD1_INTR_MASK | WD2_INTR_MASK) : (WD0_INTR_MASK | WD1_INTR_MASK | WD2_INTR_MASK) :
(p->devs[index].intr_mask); (p->devs[index].intr_mask);
if (enable == WD_INTR_ON) if (enable == WD_INTR_ON)
...@@ -303,24 +304,24 @@ static int cpwd_getstatus(struct cpwd *p, int index) ...@@ -303,24 +304,24 @@ static int cpwd_getstatus(struct cpwd *p, int index)
unsigned char ret = WD_STOPPED; unsigned char ret = WD_STOPPED;
/* determine STOPPED */ /* determine STOPPED */
if (!stat) if (!stat)
return ret; return ret;
/* determine EXPIRED vs FREERUN vs RUNNING */ /* determine EXPIRED vs FREERUN vs RUNNING */
else if (WD_S_EXPIRED & stat) { else if (WD_S_EXPIRED & stat) {
ret = WD_EXPIRED; ret = WD_EXPIRED;
} else if(WD_S_RUNNING & stat) { } else if (WD_S_RUNNING & stat) {
if (intr & p->devs[index].intr_mask) { if (intr & p->devs[index].intr_mask) {
ret = WD_FREERUN; ret = WD_FREERUN;
} else { } else {
/* Fudge WD_EXPIRED status for defective CP1400-- /* Fudge WD_EXPIRED status for defective CP1400--
* IF timer is running * IF timer is running
* AND brokenstop is set * AND brokenstop is set
* AND an interrupt has been serviced * AND an interrupt has been serviced
* we are WD_EXPIRED. * we are WD_EXPIRED.
* *
* IF timer is running * IF timer is running
* AND brokenstop is set * AND brokenstop is set
* AND no interrupt has been serviced * AND no interrupt has been serviced
* we are WD_FREERUN. * we are WD_FREERUN.
*/ */
...@@ -329,7 +330,8 @@ static int cpwd_getstatus(struct cpwd *p, int index) ...@@ -329,7 +330,8 @@ static int cpwd_getstatus(struct cpwd *p, int index)
if (p->devs[index].runstatus & WD_STAT_SVCD) { if (p->devs[index].runstatus & WD_STAT_SVCD) {
ret = WD_EXPIRED; ret = WD_EXPIRED;
} else { } else {
/* we could as well pretend we are expired */ /* we could as well pretend
* we are expired */
ret = WD_FREERUN; ret = WD_FREERUN;
} }
} else { } else {
...@@ -342,7 +344,7 @@ static int cpwd_getstatus(struct cpwd *p, int index) ...@@ -342,7 +344,7 @@ static int cpwd_getstatus(struct cpwd *p, int index)
if (p->devs[index].runstatus & WD_STAT_SVCD) if (p->devs[index].runstatus & WD_STAT_SVCD)
ret |= WD_SERVICED; ret |= WD_SERVICED;
return(ret); return ret;
} }
static irqreturn_t cpwd_interrupt(int irq, void *dev_id) static irqreturn_t cpwd_interrupt(int irq, void *dev_id)
...@@ -367,22 +369,22 @@ static int cpwd_open(struct inode *inode, struct file *f) ...@@ -367,22 +369,22 @@ static int cpwd_open(struct inode *inode, struct file *f)
struct cpwd *p = cpwd_device; struct cpwd *p = cpwd_device;
lock_kernel(); lock_kernel();
switch(iminor(inode)) { switch (iminor(inode)) {
case WD0_MINOR: case WD0_MINOR:
case WD1_MINOR: case WD1_MINOR:
case WD2_MINOR: case WD2_MINOR:
break; break;
default: default:
unlock_kernel(); unlock_kernel();
return -ENODEV; return -ENODEV;
} }
/* Register IRQ on first open of device */ /* Register IRQ on first open of device */
if (!p->initialized) { if (!p->initialized) {
if (request_irq(p->irq, &cpwd_interrupt, if (request_irq(p->irq, &cpwd_interrupt,
IRQF_SHARED, DRIVER_NAME, p)) { IRQF_SHARED, DRIVER_NAME, p)) {
printk(KERN_ERR PFX "Cannot register IRQ %d\n", printk(KERN_ERR PFX "Cannot register IRQ %d\n",
p->irq); p->irq);
unlock_kernel(); unlock_kernel();
return -EBUSY; return -EBUSY;
...@@ -442,7 +444,7 @@ static long cpwd_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ...@@ -442,7 +444,7 @@ static long cpwd_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
cpwd_starttimer(p, index); cpwd_starttimer(p, index);
} else { } else {
return -EINVAL; return -EINVAL;
} }
break; break;
/* Solaris-compatible IOCTLs */ /* Solaris-compatible IOCTLs */
...@@ -458,7 +460,7 @@ static long cpwd_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ...@@ -458,7 +460,7 @@ static long cpwd_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
case WIOCSTOP: case WIOCSTOP:
if (p->enabled) if (p->enabled)
return(-EINVAL); return -EINVAL;
cpwd_stoptimer(p, index); cpwd_stoptimer(p, index);
break; break;
...@@ -493,7 +495,7 @@ static long cpwd_compat_ioctl(struct file *file, unsigned int cmd, ...@@ -493,7 +495,7 @@ static long cpwd_compat_ioctl(struct file *file, unsigned int cmd,
return rval; return rval;
} }
static ssize_t cpwd_write(struct file *file, const char __user *buf, static ssize_t cpwd_write(struct file *file, const char __user *buf,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
struct inode *inode = file->f_path.dentry->d_inode; struct inode *inode = file->f_path.dentry->d_inode;
...@@ -508,7 +510,7 @@ static ssize_t cpwd_write(struct file *file, const char __user *buf, ...@@ -508,7 +510,7 @@ static ssize_t cpwd_write(struct file *file, const char __user *buf,
return 0; return 0;
} }
static ssize_t cpwd_read(struct file * file, char __user *buffer, static ssize_t cpwd_read(struct file *file, char __user *buffer,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
return -EINVAL; return -EINVAL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment