Skip to content

Commit 92c65e5

Browse files
bigguinessgregkh
authored andcommitted
staging: comedi: adv_pci1710: define the mux control register bits
For aesthetics, define some macros to set the bits in the mux control register. Also, rename the 'mux_ext' member of the private data. Signed-off-by: H Hartley Sweeten <[email protected]> Reviewed-by: Ian Abbott <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 7603900 commit 92c65e5

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

drivers/staging/comedi/drivers/adv_pci1710.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@
4545
#define PCI171X_RANGE_UNI BIT(4)
4646
#define PCI171X_RANGE_GAIN(x) (((x) & 0x7) << 0)
4747
#define PCI171X_MUX_REG 0x04 /* W: A/D multiplexor control */
48+
#define PCI171X_MUX_CHANH(x) (((x) & 0xf) << 8)
49+
#define PCI171X_MUX_CHANL(x) (((x) & 0xf) << 0)
50+
#define PCI171X_MUX_CHAN(x) (PCI171X_MUX_CHANH(x) | PCI171X_MUX_CHANL(x))
4851
#define PCI171X_STATUS_REG 0x06 /* R: status register */
4952
#define PCI171X_STATUS_IRQ BIT(11) /* 1=IRQ occurred */
5053
#define PCI171X_STATUS_FF BIT(10) /* 1=FIFO is full, fatal error */
@@ -179,7 +182,7 @@ struct pci1710_private {
179182
unsigned int max_samples;
180183
unsigned int ctrl; /* control register value */
181184
unsigned int ctrl_ext; /* used to switch from TRIG_EXT to TRIG_xxx */
182-
unsigned int mux_ext; /* used to set the channel interval to scan */
185+
unsigned int mux_scan; /* used to set the channel interval to scan */
183186
unsigned char ai_et;
184187
unsigned int act_chanlist[32]; /* list of scanned channel */
185188
unsigned char saved_seglen; /* len of the non-repeating chanlist */
@@ -279,7 +282,7 @@ static void pci171x_ai_setup_chanlist(struct comedi_device *dev,
279282
rangeval |= PCI171X_RANGE_GAIN(range);
280283

281284
/* select channel and set range */
282-
outw(chan | (chan << 8), dev->iobase + PCI171X_MUX_REG);
285+
outw(PCI171X_MUX_CHAN(chan), dev->iobase + PCI171X_MUX_REG);
283286
outw(rangeval, dev->iobase + PCI171X_RANGE_REG);
284287

285288
devpriv->act_chanlist[i] = chan;
@@ -288,8 +291,9 @@ static void pci171x_ai_setup_chanlist(struct comedi_device *dev,
288291
devpriv->act_chanlist[i] = CR_CHAN(chanlist[i]);
289292

290293
/* select channel interval to scan */
291-
devpriv->mux_ext = first_chan | (last_chan << 8);
292-
outw(devpriv->mux_ext, dev->iobase + PCI171X_MUX_REG);
294+
devpriv->mux_scan = PCI171X_MUX_CHANL(first_chan) |
295+
PCI171X_MUX_CHANH(last_chan);
296+
outw(devpriv->mux_scan, dev->iobase + PCI171X_MUX_REG);
293297
}
294298

295299
static int pci171x_ai_eoc(struct comedi_device *dev,
@@ -551,7 +555,7 @@ static irqreturn_t interrupt_service_pci1710(int irq, void *d)
551555
outb(0, dev->iobase + PCI171X_CLRFIFO_REG);
552556
outb(0, dev->iobase + PCI171X_CLRINT_REG);
553557
/* no sample on this interrupt; reset the channel interval */
554-
outw(devpriv->mux_ext, dev->iobase + PCI171X_MUX_REG);
558+
outw(devpriv->mux_scan, dev->iobase + PCI171X_MUX_REG);
555559
outw(devpriv->ctrl, dev->iobase + PCI171X_CTRL_REG);
556560
comedi_8254_pacer_enable(dev->pacer, 1, 2, true);
557561
return IRQ_HANDLED;

0 commit comments

Comments
 (0)