Commit 0ff1fa77 authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

staging: comedi: addi_apci_1516: fix i_APCI1516_StartStopWriteWatchdog()

This function is used by the watchdog subdevice to "ping" the watchdog.
Rename the CamelCase function to apci1516_wdog_insn_write.

Currently this function does not follow the comed API. INSN_WRITE functions
are supposed to write insn->n values. Also, starting and stopping the
watchdog is handled by the INSN_CONFIG function.

Fix this function so it works like the comedi core expects. Also, since
the watchdog needs to be enabled in order to "ping" it, make sure it is
enabled before writing to it.
Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 158b6497
......@@ -52,7 +52,7 @@
#define APCI1516_WDOG_RELOAD_REG 0x04
#define APCI1516_WDOG_CTRL_REG 0x0c
#define APCI1516_WDOG_CTRL_ENABLE (1 << 0)
#define APCI1516_WDOG_CTRL_SOFT_TRIG (1 << 9)
#define APCI1516_WDOG_CTRL_SW_TRIG (1 << 9)
#define APCI1516_WDOG_STATUS_REG 0x10
struct apci1516_boardinfo {
......@@ -158,29 +158,25 @@ static int apci1516_wdog_insn_config(struct comedi_device *dev,
return insn->n;
}
static int i_APCI1516_StartStopWriteWatchdog(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data)
static int apci1516_wdog_insn_write(struct comedi_device *dev,
struct comedi_subdevice *s,
struct comedi_insn *insn,
unsigned int *data)
{
struct apci1516_private *devpriv = dev->private;
int i;
switch (data[0]) {
case 0: /* stop the watchdog */
outw(0x0, devpriv->wdog_iobase + APCI1516_WDOG_CTRL_REG);
break;
case 1: /* start the watchdog */
outw(APCI1516_WDOG_CTRL_ENABLE,
devpriv->wdog_iobase + APCI1516_WDOG_CTRL_REG);
break;
case 2: /* Software trigger */
outw(APCI1516_WDOG_CTRL_ENABLE | APCI1516_WDOG_CTRL_SOFT_TRIG,
devpriv->wdog_iobase + APCI1516_WDOG_CTRL_REG);
break;
default:
printk("\nSpecified functionality does not exist\n");
if (devpriv->ctrl == 0) {
dev_warn(dev->class_dev, "watchdog is disabled\n");
return -EINVAL;
} /* switch(data[0]) */
}
/* "ping" the watchdog */
for (i = 0; i < insn->n; i++) {
outw(devpriv->ctrl | APCI1516_WDOG_CTRL_SW_TRIG,
devpriv->wdog_iobase + APCI1516_WDOG_CTRL_REG);
}
return insn->n;
}
......@@ -290,7 +286,7 @@ static int __devinit apci1516_auto_attach(struct comedi_device *dev,
s->subdev_flags = SDF_WRITEABLE;
s->n_chan = 1;
s->maxdata = 0xff;
s->insn_write = i_APCI1516_StartStopWriteWatchdog;
s->insn_write = apci1516_wdog_insn_write;
s->insn_read = apci1516_wdog_insn_read;
s->insn_config = apci1516_wdog_insn_config;
} else {
......
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