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

staging: comedi: ni_labpc: cleanup true/false flags in boardinfo

The 'register_layout' in the boardinfo can be represented as
a true/false flag instead of an enum. Rename the variable to
'is_labpc1200' and change it to an unsigned 1-bit bit-field.

The 'has_ao' variable is also a true/false flag. Change it to
an unsigned 1-bit bit-field.

Reorder the boardinfo data so that the bit-field data is grouped
together.

For aesthetic reasons, and move the 'const' variables then
reorder the boardinfo declarations to match the definition.
Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 9548b735
...@@ -238,26 +238,25 @@ static inline void labpc_writeb(unsigned int byte, unsigned long address) ...@@ -238,26 +238,25 @@ static inline void labpc_writeb(unsigned int byte, unsigned long address)
static const struct labpc_boardinfo labpc_boards[] = { static const struct labpc_boardinfo labpc_boards[] = {
{ {
.name = "lab-pc-1200", .name = "lab-pc-1200",
.ai_speed = 10000,
.register_layout = labpc_1200_layout,
.has_ao = 1,
.ai_range_table = &range_labpc_1200_ai, .ai_range_table = &range_labpc_1200_ai,
.ai_range_code = labpc_1200_ai_gain_bits, .ai_range_code = labpc_1200_ai_gain_bits,
.ai_speed = 10000,
.ai_scan_up = 1, .ai_scan_up = 1,
.has_ao = 1,
.is_labpc1200 = 1,
}, { }, {
.name = "lab-pc-1200ai", .name = "lab-pc-1200ai",
.ai_speed = 10000,
.register_layout = labpc_1200_layout,
.ai_range_table = &range_labpc_1200_ai, .ai_range_table = &range_labpc_1200_ai,
.ai_range_code = labpc_1200_ai_gain_bits, .ai_range_code = labpc_1200_ai_gain_bits,
.ai_speed = 10000,
.ai_scan_up = 1, .ai_scan_up = 1,
.is_labpc1200 = 1,
}, { }, {
.name = "lab-pc+", .name = "lab-pc+",
.ai_speed = 12000,
.register_layout = labpc_plus_layout,
.has_ao = 1,
.ai_range_table = &range_labpc_plus_ai, .ai_range_table = &range_labpc_plus_ai,
.ai_range_code = labpc_plus_ai_gain_bits, .ai_range_code = labpc_plus_ai_gain_bits,
.ai_speed = 12000,
.has_ao = 1,
}, },
}; };
#endif #endif
...@@ -347,7 +346,7 @@ static void labpc_setup_cmd6_reg(struct comedi_device *dev, ...@@ -347,7 +346,7 @@ static void labpc_setup_cmd6_reg(struct comedi_device *dev,
const struct labpc_boardinfo *board = comedi_board(dev); const struct labpc_boardinfo *board = comedi_board(dev);
struct labpc_private *devpriv = dev->private; struct labpc_private *devpriv = dev->private;
if (board->register_layout != labpc_1200_layout) if (!board->is_labpc1200)
return; return;
/* reference inputs to ground or common? */ /* reference inputs to ground or common? */
...@@ -759,7 +758,7 @@ static int labpc_ai_cmdtest(struct comedi_device *dev, ...@@ -759,7 +758,7 @@ static int labpc_ai_cmdtest(struct comedi_device *dev,
err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT); err |= cfc_check_trigger_src(&cmd->scan_end_src, TRIG_COUNT);
stop_mask = TRIG_COUNT | TRIG_NONE; stop_mask = TRIG_COUNT | TRIG_NONE;
if (board->register_layout == labpc_1200_layout) if (board->is_labpc1200)
stop_mask |= TRIG_EXT; stop_mask |= TRIG_EXT;
err |= cfc_check_trigger_src(&cmd->stop_src, stop_mask); err |= cfc_check_trigger_src(&cmd->stop_src, stop_mask);
...@@ -895,7 +894,7 @@ static int labpc_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) ...@@ -895,7 +894,7 @@ static int labpc_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
/* pc-plus has no fifo-half full interrupt */ /* pc-plus has no fifo-half full interrupt */
} else } else
#endif #endif
if (board->register_layout == labpc_1200_layout && if (board->is_labpc1200 &&
/* wake-end-of-scan should interrupt on fifo not empty */ /* wake-end-of-scan should interrupt on fifo not empty */
(cmd->flags & TRIG_WAKE_EOS) == 0 && (cmd->flags & TRIG_WAKE_EOS) == 0 &&
/* make sure we are taking more than just a few points */ /* make sure we are taking more than just a few points */
...@@ -1176,7 +1175,7 @@ static irqreturn_t labpc_interrupt(int irq, void *d) ...@@ -1176,7 +1175,7 @@ static irqreturn_t labpc_interrupt(int irq, void *d)
/* read board status */ /* read board status */
devpriv->stat1 = devpriv->read_byte(dev->iobase + STAT1_REG); devpriv->stat1 = devpriv->read_byte(dev->iobase + STAT1_REG);
if (board->register_layout == labpc_1200_layout) if (board->is_labpc1200)
devpriv->stat2 = devpriv->read_byte(dev->iobase + STAT2_REG); devpriv->stat2 = devpriv->read_byte(dev->iobase + STAT2_REG);
if ((devpriv->stat1 & (STAT1_GATA0 | STAT1_CNTINT | STAT1_OVERFLOW | if ((devpriv->stat1 & (STAT1_GATA0 | STAT1_CNTINT | STAT1_OVERFLOW |
...@@ -1202,8 +1201,7 @@ static irqreturn_t labpc_interrupt(int irq, void *d) ...@@ -1202,8 +1201,7 @@ static irqreturn_t labpc_interrupt(int irq, void *d)
* has occurred * has occurred
*/ */
if (devpriv->stat1 & STAT1_GATA0 || if (devpriv->stat1 & STAT1_GATA0 ||
(board->register_layout == labpc_1200_layout (board->is_labpc1200 && devpriv->stat2 & STAT2_OUTA1)) {
&& devpriv->stat2 & STAT2_OUTA1)) {
handle_isa_dma(dev); handle_isa_dma(dev);
} }
} else } else
...@@ -1267,7 +1265,7 @@ static int labpc_ao_insn_write(struct comedi_device *dev, ...@@ -1267,7 +1265,7 @@ static int labpc_ao_insn_write(struct comedi_device *dev,
spin_unlock_irqrestore(&dev->spinlock, flags); spin_unlock_irqrestore(&dev->spinlock, flags);
/* set range */ /* set range */
if (board->register_layout == labpc_1200_layout) { if (board->is_labpc1200) {
range = CR_RANGE(insn->chanspec); range = CR_RANGE(insn->chanspec);
if (labpc_range_is_unipolar(s, range)) if (labpc_range_is_unipolar(s, range))
devpriv->cmd6 |= CMD6_DACUNI(channel); devpriv->cmd6 |= CMD6_DACUNI(channel);
...@@ -1604,7 +1602,7 @@ int labpc_common_attach(struct comedi_device *dev, ...@@ -1604,7 +1602,7 @@ int labpc_common_attach(struct comedi_device *dev,
devpriv->write_byte(devpriv->cmd2, dev->iobase + CMD2_REG); devpriv->write_byte(devpriv->cmd2, dev->iobase + CMD2_REG);
devpriv->write_byte(devpriv->cmd3, dev->iobase + CMD3_REG); devpriv->write_byte(devpriv->cmd3, dev->iobase + CMD3_REG);
devpriv->write_byte(devpriv->cmd4, dev->iobase + CMD4_REG); devpriv->write_byte(devpriv->cmd4, dev->iobase + CMD4_REG);
if (board->register_layout == labpc_1200_layout) { if (board->is_labpc1200) {
devpriv->write_byte(devpriv->cmd5, dev->iobase + CMD5_REG); devpriv->write_byte(devpriv->cmd5, dev->iobase + CMD5_REG);
devpriv->write_byte(devpriv->cmd6, dev->iobase + CMD6_REG); devpriv->write_byte(devpriv->cmd6, dev->iobase + CMD6_REG);
} }
...@@ -1672,7 +1670,7 @@ int labpc_common_attach(struct comedi_device *dev, ...@@ -1672,7 +1670,7 @@ int labpc_common_attach(struct comedi_device *dev,
/* calibration subdevices for boards that have one */ /* calibration subdevices for boards that have one */
s = &dev->subdevices[3]; s = &dev->subdevices[3];
if (board->register_layout == labpc_1200_layout) { if (board->is_labpc1200) {
s->type = COMEDI_SUBD_CALIB; s->type = COMEDI_SUBD_CALIB;
s->subdev_flags = SDF_READABLE | SDF_WRITABLE | SDF_INTERNAL; s->subdev_flags = SDF_READABLE | SDF_WRITABLE | SDF_INTERNAL;
s->n_chan = 16; s->n_chan = 16;
...@@ -1687,7 +1685,7 @@ int labpc_common_attach(struct comedi_device *dev, ...@@ -1687,7 +1685,7 @@ int labpc_common_attach(struct comedi_device *dev,
/* EEPROM */ /* EEPROM */
s = &dev->subdevices[4]; s = &dev->subdevices[4];
if (board->register_layout == labpc_1200_layout) { if (board->is_labpc1200) {
s->type = COMEDI_SUBD_MEMORY; s->type = COMEDI_SUBD_MEMORY;
s->subdev_flags = SDF_READABLE | SDF_WRITABLE | SDF_INTERNAL; s->subdev_flags = SDF_READABLE | SDF_WRITABLE | SDF_INTERNAL;
s->n_chan = EEPROM_SIZE; s->n_chan = EEPROM_SIZE;
......
...@@ -27,26 +27,19 @@ ...@@ -27,26 +27,19 @@
#define EEPROM_SIZE 256 /* 256 byte eeprom */ #define EEPROM_SIZE 256 /* 256 byte eeprom */
#define NUM_AO_CHAN 2 /* boards have two analog output channels */ #define NUM_AO_CHAN 2 /* boards have two analog output channels */
enum labpc_register_layout { labpc_plus_layout, labpc_1200_layout };
enum transfer_type { fifo_not_empty_transfer, fifo_half_full_transfer, enum transfer_type { fifo_not_empty_transfer, fifo_half_full_transfer,
isa_dma_transfer isa_dma_transfer
}; };
struct labpc_boardinfo { struct labpc_boardinfo {
const char *name; const char *name;
int ai_speed; /* maximum input speed in nanoseconds */
/* 1200 has extra registers compared to pc+ */
enum labpc_register_layout register_layout;
int has_ao; /* has analog output true/false */
const struct comedi_lrange *ai_range_table; const struct comedi_lrange *ai_range_table;
const int *ai_range_code; const int *ai_range_code;
int ai_speed; /* maximum input speed in ns */
/* board can auto scan up in ai channels, not just down */ unsigned ai_scan_up:1; /* can auto scan up in ai channels */
unsigned ai_scan_up:1; unsigned has_ao:1; /* has analog outputs */
unsigned is_labpc1200:1; /* has extra regs compared to pc+ */
/* uses memory mapped io instead of ioports */ unsigned has_mmio:1; /* uses memory mapped io */
unsigned has_mmio:1;
}; };
struct labpc_private { struct labpc_private {
......
...@@ -76,11 +76,11 @@ NI manuals: ...@@ -76,11 +76,11 @@ NI manuals:
static const struct labpc_boardinfo labpc_cs_boards[] = { static const struct labpc_boardinfo labpc_cs_boards[] = {
{ {
.name = "daqcard-1200", .name = "daqcard-1200",
.ai_speed = 10000,
.register_layout = labpc_1200_layout,
.has_ao = 1,
.ai_range_table = &range_labpc_1200_ai, .ai_range_table = &range_labpc_1200_ai,
.ai_range_code = labpc_1200_ai_gain_bits, .ai_range_code = labpc_1200_ai_gain_bits,
.ai_speed = 10000,
.has_ao = 1,
.is_labpc1200 = 1,
}, },
}; };
......
...@@ -49,12 +49,12 @@ enum labpc_pci_boardid { ...@@ -49,12 +49,12 @@ enum labpc_pci_boardid {
static const struct labpc_boardinfo labpc_pci_boards[] = { static const struct labpc_boardinfo labpc_pci_boards[] = {
[BOARD_NI_PCI1200] = { [BOARD_NI_PCI1200] = {
.name = "ni_pci-1200", .name = "ni_pci-1200",
.ai_speed = 10000,
.register_layout = labpc_1200_layout,
.has_ao = 1,
.ai_range_table = &range_labpc_1200_ai, .ai_range_table = &range_labpc_1200_ai,
.ai_range_code = labpc_1200_ai_gain_bits, .ai_range_code = labpc_1200_ai_gain_bits,
.ai_speed = 10000,
.ai_scan_up = 1, .ai_scan_up = 1,
.has_ao = 1,
.is_labpc1200 = 1,
.has_mmio = 1, .has_mmio = 1,
}, },
}; };
......
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