Skip to content

Commit

Permalink
staging: comedi: adv_pci1710: change boardinfo 'fifo_half_size' to 'h…
Browse files Browse the repository at this point in the history
…as_large_fifo'

The boards supported by this driver have a 4K or 1K FIFO that is used when reading
analog input samples when running an async command. The maximum number of samples
in the FIFO is half the FIFO size due to the 2 bytes/sample (12-bit resolution).

For aesthetics, change the 'fifo_half_size' member to a bit-field flag 'has_large_fifo'
and add a new member to the private data to hold the 'max_samples' available in the
FIFO. Refactor the board attach and pci1710_handle_fifo() accordingly.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
H Hartley Sweeten authored and Greg Kroah-Hartman committed Jan 25, 2015
1 parent abd2839 commit 7bd428c
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions drivers/staging/comedi/drivers/adv_pci1710.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ struct boardtype {
const struct comedi_lrange *rangelist_ai; /* rangelist for A/D */
const char *rangecode_ai; /* range codes for programming */
const struct comedi_lrange *rangelist_ao; /* rangelist for D/A */
unsigned int fifo_half_size; /* size of FIFO/2 */
unsigned int has_irq:1;
unsigned int has_large_fifo:1; /* 4K or 1K FIFO */
unsigned int has_diff_ai:1;
unsigned int has_di_do:1;
unsigned int has_counter:1;
Expand All @@ -213,8 +213,8 @@ static const struct boardtype boardtypes[] = {
.rangelist_ai = &range_pci1710_3,
.rangecode_ai = range_codes_pci1710_3,
.rangelist_ao = &range_pci171x_da,
.fifo_half_size = 2048,
.has_irq = 1,
.has_large_fifo = 1,
.has_diff_ai = 1,
.has_di_do = 1,
.has_counter = 1,
Expand All @@ -227,8 +227,8 @@ static const struct boardtype boardtypes[] = {
.rangelist_ai = &range_pci1710hg,
.rangecode_ai = range_codes_pci1710hg,
.rangelist_ao = &range_pci171x_da,
.fifo_half_size = 2048,
.has_irq = 1,
.has_large_fifo = 1,
.has_diff_ai = 1,
.has_di_do = 1,
.has_counter = 1,
Expand All @@ -241,7 +241,6 @@ static const struct boardtype boardtypes[] = {
.rangelist_ai = &range_pci17x1,
.rangecode_ai = range_codes_pci17x1,
.rangelist_ao = &range_pci171x_da,
.fifo_half_size = 512,
.has_irq = 1,
.has_di_do = 1,
.has_counter = 1,
Expand All @@ -252,8 +251,8 @@ static const struct boardtype boardtypes[] = {
.n_aichan = 32,
.rangelist_ai = &range_pci1710_3,
.rangecode_ai = range_codes_pci1710_3,
.fifo_half_size = 2048,
.has_irq = 1,
.has_large_fifo = 1,
.has_diff_ai = 1,
},
[BOARD_PCI1720] = {
Expand All @@ -268,13 +267,13 @@ static const struct boardtype boardtypes[] = {
.n_aichan = 16,
.rangelist_ai = &range_pci17x1,
.rangecode_ai = range_codes_pci17x1,
.fifo_half_size = 512,
.has_irq = 1,
.has_di_do = 1,
},
};

struct pci1710_private {
unsigned int max_samples;
unsigned int CntrlReg; /* Control register */
unsigned char ai_et;
unsigned int ai_et_CntrlReg;
Expand Down Expand Up @@ -786,7 +785,7 @@ static int move_block_from_fifo(struct comedi_device *dev,
static void pci1710_handle_fifo(struct comedi_device *dev,
struct comedi_subdevice *s)
{
const struct boardtype *this_board = dev->board_ptr;
struct pci1710_private *devpriv = dev->private;
struct comedi_cmd *cmd = &s->async->cmd;
unsigned int nsamples;
unsigned int m;
Expand All @@ -806,7 +805,7 @@ static void pci1710_handle_fifo(struct comedi_device *dev,
return;
}

nsamples = this_board->fifo_half_size;
nsamples = devpriv->max_samples;
if (comedi_samples_to_bytes(s, nsamples) >= s->async->prealloc_bufsz) {
m = comedi_bytes_to_samples(s, s->async->prealloc_bufsz);
if (move_block_from_fifo(dev, s, m, 0))
Expand Down Expand Up @@ -1188,6 +1187,9 @@ static int pci1710_auto_attach(struct comedi_device *dev,
subdev++;
}

/* max_samples is half the FIFO size (2 bytes/sample) */
devpriv->max_samples = (this_board->has_large_fifo) ? 2048 : 512;

return 0;
}

Expand Down

0 comments on commit 7bd428c

Please sign in to comment.