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

staging: comedi: ni_6527: tidy up ni6527_intr_insn_config()

Handle the instruction (data[0]) with a switch to make it easier
to add additional instructions in the future.

To clarify the code, factor out the code that sets the rising/falling
edge detection.

Rename the CamelCase defines used for the rising/falling edge detection
registers.
Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: default avatarIan Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent c16a4d69
...@@ -68,9 +68,8 @@ Updated: Sat, 25 Jan 2003 13:24:40 -0800 ...@@ -68,9 +68,8 @@ Updated: Sat, 25 Jan 2003 13:24:40 -0800
#define NI6527_CTRL_ENABLE_IRQS (NI6527_CTRL_FALLING | \ #define NI6527_CTRL_ENABLE_IRQS (NI6527_CTRL_FALLING | \
NI6527_CTRL_RISING | \ NI6527_CTRL_RISING | \
NI6527_CTRL_IRQ | NI6527_CTRL_EDGE) NI6527_CTRL_IRQ | NI6527_CTRL_EDGE)
#define NI6527_RISING_EDGE_REG(x) (0x18 + (x))
#define Rising_Edge_Detection_Enable(x) (0x018+(x)) #define NI6527_FALLING_EDGE_REG(x) (0x20 + (x))
#define Falling_Edge_Detection_Enable(x) (0x020+(x))
enum ni6527_boardid { enum ni6527_boardid {
BOARD_PCI6527, BOARD_PCI6527,
...@@ -299,32 +298,41 @@ static int ni6527_intr_insn_bits(struct comedi_device *dev, ...@@ -299,32 +298,41 @@ static int ni6527_intr_insn_bits(struct comedi_device *dev,
return insn->n; return insn->n;
} }
static int ni6527_intr_insn_config(struct comedi_device *dev, static void ni6527_set_edge_detection(struct comedi_device *dev,
struct comedi_subdevice *s, unsigned int rising,
struct comedi_insn *insn, unsigned int *data) unsigned int falling)
{ {
struct ni6527_private *devpriv = dev->private; struct ni6527_private *devpriv = dev->private;
void __iomem *mmio = devpriv->mite->daq_io_addr;
if (insn->n < 1) /* enable rising-edge detection channels */
return -EINVAL; writeb(rising & 0xff, mmio + NI6527_RISING_EDGE_REG(0));
if (data[0] != INSN_CONFIG_CHANGE_NOTIFY) writeb((rising >> 8) & 0xff, mmio + NI6527_RISING_EDGE_REG(1));
return -EINVAL; writeb((rising >> 16) & 0xff, mmio + NI6527_RISING_EDGE_REG(2));
writeb(data[1], /* enable falling-edge detection channels */
devpriv->mite->daq_io_addr + Rising_Edge_Detection_Enable(0)); writeb(falling & 0xff, mmio + NI6527_FALLING_EDGE_REG(0));
writeb(data[1] >> 8, writeb((falling >> 8) & 0xff, mmio + NI6527_FALLING_EDGE_REG(1));
devpriv->mite->daq_io_addr + Rising_Edge_Detection_Enable(1)); writeb((falling >> 16) & 0xff, mmio + NI6527_FALLING_EDGE_REG(2));
writeb(data[1] >> 16, }
devpriv->mite->daq_io_addr + Rising_Edge_Detection_Enable(2));
writeb(data[2], static int ni6527_intr_insn_config(struct comedi_device *dev,
devpriv->mite->daq_io_addr + Falling_Edge_Detection_Enable(0)); struct comedi_subdevice *s,
writeb(data[2] >> 8, struct comedi_insn *insn,
devpriv->mite->daq_io_addr + Falling_Edge_Detection_Enable(1)); unsigned int *data)
writeb(data[2] >> 16, {
devpriv->mite->daq_io_addr + Falling_Edge_Detection_Enable(2)); switch (data[0]) {
case INSN_CONFIG_CHANGE_NOTIFY:
/* check_insn_config_length() does not check this instruction */
if (insn->n != 3)
return -EINVAL;
ni6527_set_edge_detection(dev, data[1], data[2]);
break;
default:
return -EINVAL;
}
return 2; return insn->n;
} }
static int ni6527_auto_attach(struct comedi_device *dev, static int ni6527_auto_attach(struct comedi_device *dev,
......
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