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

staging: comedi: mf6x4: introduce a macro to select the AI channel

For aesthetics, use a macro to set the bit in the ADCTRL register that
selects an analog input channel.
Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
 drivers/staging/comedi/drivers/mf6x4.c | 9 +++++----
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent ea22ae5e
...@@ -39,8 +39,8 @@ ...@@ -39,8 +39,8 @@
/* BAR1 registers */ /* BAR1 registers */
#define MF6X4_ADDATA_R 0x00 #define MF6X4_ADDATA_R 0x00
#define MF6X4_ADCTRL_R 0x00 #define MF6X4_ADCTRL_REG 0x00
#define MF6X4_ADCTRL_M 0xff #define MF6X4_ADCTRL_CHAN(x) BIT(chan)
#define MF6X4_DIN_R 0x10 #define MF6X4_DIN_R 0x10
#define MF6X4_DIN_M 0xff #define MF6X4_DIN_M 0xff
#define MF6X4_DOUT_R 0x10 #define MF6X4_DOUT_R 0x10
...@@ -133,13 +133,13 @@ static int mf6x4_ai_insn_read(struct comedi_device *dev, ...@@ -133,13 +133,13 @@ static int mf6x4_ai_insn_read(struct comedi_device *dev,
struct comedi_insn *insn, struct comedi_insn *insn,
unsigned int *data) unsigned int *data)
{ {
int chan = CR_CHAN(insn->chanspec); unsigned int chan = CR_CHAN(insn->chanspec);
int ret; int ret;
int i; int i;
int d; int d;
/* Set the ADC channel number in the scan list */ /* Set the ADC channel number in the scan list */
iowrite16((1 << chan) & MF6X4_ADCTRL_M, dev->mmio + MF6X4_ADCTRL_R); iowrite16(MF6X4_ADCTRL_CHAN(chan), dev->mmio + MF6X4_ADCTRL_REG);
for (i = 0; i < insn->n; i++) { for (i = 0; i < insn->n; i++) {
/* Trigger ADC conversion by reading ADSTART */ /* Trigger ADC conversion by reading ADSTART */
...@@ -155,7 +155,7 @@ static int mf6x4_ai_insn_read(struct comedi_device *dev, ...@@ -155,7 +155,7 @@ static int mf6x4_ai_insn_read(struct comedi_device *dev,
data[i] = d; data[i] = d;
} }
iowrite16(0x0, dev->mmio + MF6X4_ADCTRL_R); iowrite16(0x0, dev->mmio + MF6X4_ADCTRL_REG);
return insn->n; return insn->n;
} }
......
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