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

staging: comedi: adl_pci9118: tidy up pci9118_set_chanlist()

Define some macros to set the 'chan' and 'range' bits in the chanlist
register. Use them to tidy up this function.
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 b7a078e9
...@@ -120,6 +120,8 @@ ...@@ -120,6 +120,8 @@
#define PCI9118_DIO_REG 0x1c #define PCI9118_DIO_REG 0x1c
#define PCI9118_SOFTTRG_REG 0x20 #define PCI9118_SOFTTRG_REG 0x20
#define PCI9118_AI_CHANLIST_REG 0x24 #define PCI9118_AI_CHANLIST_REG 0x24
#define PCI9118_AI_CHANLIST_RANGE(x) (((x) & 0x3) << 8)
#define PCI9118_AI_CHANLIST_CHAN(x) ((x) << 0)
#define PCI9118_AI_BURST_NUM_REG 0x28 #define PCI9118_AI_BURST_NUM_REG 0x28
#define PCI9118_AI_AUTOSCAN_MODE_REG 0x2c #define PCI9118_AI_AUTOSCAN_MODE_REG 0x2c
#define PCI9118_AI_CFG_REG 0x30 #define PCI9118_AI_CFG_REG 0x30
...@@ -375,9 +377,11 @@ static void pci9118_set_chanlist(struct comedi_device *dev, ...@@ -375,9 +377,11 @@ static void pci9118_set_chanlist(struct comedi_device *dev,
int frontadd, int backadd) int frontadd, int backadd)
{ {
struct pci9118_private *devpriv = dev->private; struct pci9118_private *devpriv = dev->private;
unsigned int chan0 = CR_CHAN(chanlist[0]);
unsigned int range0 = CR_RANGE(chanlist[0]); unsigned int range0 = CR_RANGE(chanlist[0]);
unsigned int aref0 = CR_AREF(chanlist[0]); unsigned int aref0 = CR_AREF(chanlist[0]);
unsigned int scanquad, gain, ssh = 0x00; unsigned int ssh = 0x00;
unsigned int val;
int i; int i;
/* /*
...@@ -397,37 +401,33 @@ static void pci9118_set_chanlist(struct comedi_device *dev, ...@@ -397,37 +401,33 @@ static void pci9118_set_chanlist(struct comedi_device *dev,
outl(0, dev->iobase + PCI9118_AI_AUTOSCAN_MODE_REG); outl(0, dev->iobase + PCI9118_AI_AUTOSCAN_MODE_REG);
outl(1, dev->iobase + PCI9118_AI_AUTOSCAN_MODE_REG); outl(1, dev->iobase + PCI9118_AI_AUTOSCAN_MODE_REG);
if (frontadd) { /* insert channels for S&H */ /* insert channels for S&H */
if (frontadd) {
val = PCI9118_AI_CHANLIST_CHAN(chan0) |
PCI9118_AI_CHANLIST_RANGE(range0);
ssh = devpriv->softsshsample; ssh = devpriv->softsshsample;
for (i = 0; i < frontadd; i++) { for (i = 0; i < frontadd; i++) {
/* store range list to card */ outl(val | ssh, dev->iobase + PCI9118_AI_CHANLIST_REG);
scanquad = CR_CHAN(chanlist[0]);
/* get channel number; */
gain = CR_RANGE(chanlist[0]);
/* get gain number */
scanquad |= ((gain & 0x03) << 8);
outl(scanquad | ssh,
dev->iobase + PCI9118_AI_CHANLIST_REG);
ssh = devpriv->softsshhold; ssh = devpriv->softsshhold;
} }
} }
for (i = 0; i < n_chan; i++) { /* store range list to card */ /* store chanlist */
scanquad = CR_CHAN(chanlist[i]); /* get channel number */ for (i = 0; i < n_chan; i++) {
gain = CR_RANGE(chanlist[i]); /* get gain number */ unsigned int chan = CR_CHAN(chanlist[i]);
scanquad |= ((gain & 0x03) << 8); unsigned int range = CR_RANGE(chanlist[i]);
outl(scanquad | ssh, dev->iobase + PCI9118_AI_CHANLIST_REG);
}
if (backadd) { /* insert channels for fit onto 32bit DMA */ val = PCI9118_AI_CHANLIST_CHAN(chan) |
for (i = 0; i < backadd; i++) { /* store range list to card */ PCI9118_AI_CHANLIST_RANGE(range);
scanquad = CR_CHAN(chanlist[0]); outl(val | ssh, dev->iobase + PCI9118_AI_CHANLIST_REG);
/* get channel number */
gain = CR_RANGE(chanlist[0]); /* get gain number */
scanquad |= ((gain & 0x03) << 8);
outl(scanquad | ssh,
dev->iobase + PCI9118_AI_CHANLIST_REG);
} }
/* insert channels to fit onto 32bit DMA */
if (backadd) {
val = PCI9118_AI_CHANLIST_CHAN(chan0) |
PCI9118_AI_CHANLIST_RANGE(range0);
for (i = 0; i < backadd; i++)
outl(val | ssh, dev->iobase + PCI9118_AI_CHANLIST_REG);
} }
/* close scan queue */ /* close scan queue */
outl(0, dev->iobase + PCI9118_AI_AUTOSCAN_MODE_REG); outl(0, dev->iobase + PCI9118_AI_AUTOSCAN_MODE_REG);
......
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