Skip to content

Commit

Permalink
staging: comedi: addi_apci_1516: fix i_APCI1516_StartStopWriteWatchdog()
Browse files Browse the repository at this point in the history
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: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
H Hartley Sweeten authored and Greg Kroah-Hartman committed Nov 13, 2012
1 parent 158b649 commit 0ff1fa7
Showing 1 changed file with 17 additions and 21 deletions.
38 changes: 17 additions & 21 deletions drivers/staging/comedi/drivers/addi_apci_1516.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 0ff1fa7

Please sign in to comment.