diff options
author | H Hartley Sweeten <hsweeten@visionengravers.com> | 2013-05-13 17:07:24 -0700 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-05-16 16:03:44 -0700 |
commit | 5e763f7bd9fea0027e246e6c2cee291566a390a9 (patch) | |
tree | c2522483be07750af707feb9385fd17dc6947958 /drivers/staging | |
parent | 867143804929cc6ef18946143116ae6849cb6ae8 (diff) | |
download | op-kernel-dev-5e763f7bd9fea0027e246e6c2cee291566a390a9.zip op-kernel-dev-5e763f7bd9fea0027e246e6c2cee291566a390a9.tar.gz |
staging: comedi: ni_labpc: remove *_ai_gain_bits tables
The bits needed to set the analog input gain can be simply calculated
based on the 'range'.
The LabPC versions of the board do not have the '0x10' gain that the
LabPC+ board supports. By incrementing the range appropriately the
correct gain bits can still be calculated.
This allows removing the two gain tables, as well as the export, along
with the 'ai_range_code' data in the boardinfo.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging')
-rw-r--r-- | drivers/staging/comedi/drivers/ni_labpc.c | 27 | ||||
-rw-r--r-- | drivers/staging/comedi/drivers/ni_labpc.h | 3 | ||||
-rw-r--r-- | drivers/staging/comedi/drivers/ni_labpc_cs.c | 1 | ||||
-rw-r--r-- | drivers/staging/comedi/drivers/ni_labpc_pci.c | 1 |
4 files changed, 11 insertions, 21 deletions
diff --git a/drivers/staging/comedi/drivers/ni_labpc.c b/drivers/staging/comedi/drivers/ni_labpc.c index 7d6bd1b..7320009 100644 --- a/drivers/staging/comedi/drivers/ni_labpc.c +++ b/drivers/staging/comedi/drivers/ni_labpc.c @@ -84,7 +84,7 @@ #define CMD1_REG 0x00 /* W: Command 1 reg */ #define CMD1_MA(x) (((x) & 0x7) << 0) #define CMD1_TWOSCMP (1 << 3) -#define CMD1_GAIN_MASK (7 << 4) +#define CMD1_GAIN(x) (((x) & 0x7) << 4) #define CMD1_SCANEN (1 << 7) #define CMD2_REG 0x01 /* W: Command 2 reg */ #define CMD2_PRETRIG (1 << 0) @@ -149,11 +149,6 @@ enum scan_mode { MODE_MULT_CHAN_DOWN, }; -static const int labpc_plus_ai_gain_bits[] = { - 0x00, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70, - 0x00, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70, -}; - static const struct comedi_lrange range_labpc_plus_ai = { 16, { BIP_RANGE(5), @@ -175,12 +170,6 @@ static const struct comedi_lrange range_labpc_plus_ai = { } }; -const int labpc_1200_ai_gain_bits[] = { - 0x00, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70, - 0x00, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70, -}; -EXPORT_SYMBOL_GPL(labpc_1200_ai_gain_bits); - static const struct comedi_lrange range_labpc_1200_ai = { 14, { BIP_RANGE(5), @@ -233,20 +222,17 @@ static inline void labpc_writeb(unsigned int byte, unsigned long address) static const struct labpc_boardinfo labpc_boards[] = { { .name = "lab-pc-1200", - .ai_range_code = labpc_1200_ai_gain_bits, .ai_speed = 10000, .ai_scan_up = 1, .has_ao = 1, .is_labpc1200 = 1, }, { .name = "lab-pc-1200ai", - .ai_range_code = labpc_1200_ai_gain_bits, .ai_speed = 10000, .ai_scan_up = 1, .is_labpc1200 = 1, }, { .name = "lab-pc+", - .ai_range_code = labpc_plus_ai_gain_bits, .ai_speed = 12000, .has_ao = 1, }, @@ -317,12 +303,21 @@ static void labpc_ai_set_chan_and_gain(struct comedi_device *dev, const struct labpc_boardinfo *board = comedi_board(dev); struct labpc_private *devpriv = dev->private; + if (board->is_labpc1200) { + /* + * The LabPC-1200 boards do not have a gain + * of '0x10'. Skip the range values that would + * result in this gain. + */ + range += (range > 0) + (range > 7); + } + /* munge channel bits for differential/scan disabled mode */ if ((mode == MODE_SINGLE_CHAN || mode == MODE_SINGLE_CHAN_INTERVAL) && aref == AREF_DIFF) chan *= 2; devpriv->cmd1 = CMD1_MA(chan); - devpriv->cmd1 |= board->ai_range_code[range]; + devpriv->cmd1 |= CMD1_GAIN(range); devpriv->write_byte(devpriv->cmd1, dev->iobase + CMD1_REG); } diff --git a/drivers/staging/comedi/drivers/ni_labpc.h b/drivers/staging/comedi/drivers/ni_labpc.h index a96d6ac..2cb407b 100644 --- a/drivers/staging/comedi/drivers/ni_labpc.h +++ b/drivers/staging/comedi/drivers/ni_labpc.h @@ -28,7 +28,6 @@ enum transfer_type { fifo_not_empty_transfer, fifo_half_full_transfer, struct labpc_boardinfo { const char *name; - const int *ai_range_code; int ai_speed; /* maximum input speed in ns */ unsigned ai_scan_up:1; /* can auto scan up in ai channels */ unsigned has_ao:1; /* has analog outputs */ @@ -88,6 +87,4 @@ int labpc_common_attach(struct comedi_device *dev, unsigned int irq, unsigned long isr_flags); void labpc_common_detach(struct comedi_device *dev); -extern const int labpc_1200_ai_gain_bits[]; - #endif /* _NI_LABPC_H */ diff --git a/drivers/staging/comedi/drivers/ni_labpc_cs.c b/drivers/staging/comedi/drivers/ni_labpc_cs.c index 9d88bc0..883581e 100644 --- a/drivers/staging/comedi/drivers/ni_labpc_cs.c +++ b/drivers/staging/comedi/drivers/ni_labpc_cs.c @@ -70,7 +70,6 @@ NI manuals: static const struct labpc_boardinfo labpc_cs_boards[] = { { .name = "daqcard-1200", - .ai_range_code = labpc_1200_ai_gain_bits, .ai_speed = 10000, .has_ao = 1, .is_labpc1200 = 1, diff --git a/drivers/staging/comedi/drivers/ni_labpc_pci.c b/drivers/staging/comedi/drivers/ni_labpc_pci.c index 044f820..1f80711 100644 --- a/drivers/staging/comedi/drivers/ni_labpc_pci.c +++ b/drivers/staging/comedi/drivers/ni_labpc_pci.c @@ -45,7 +45,6 @@ enum labpc_pci_boardid { static const struct labpc_boardinfo labpc_pci_boards[] = { [BOARD_NI_PCI1200] = { .name = "ni_pci-1200", - .ai_range_code = labpc_1200_ai_gain_bits, .ai_speed = 10000, .ai_scan_up = 1, .has_ao = 1, |