Commit 620ec185 authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

staging: comedi: das1800: remove hard coded 'sample_size'

Use the comedi_bytes_per_sample() helper to remove the hard coded sample_size
in suggest_transfer_size().

The helper function needs to comedi_subdevice pointer. Change the parameters
passed to suggest_transfer_size() and setup_dma() so that this pointer is
available. Rename these functions so they have namespace associated with the
driver.
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 0afa6153
...@@ -966,11 +966,12 @@ static void das1800_setup_counters(struct comedi_device *dev, ...@@ -966,11 +966,12 @@ static void das1800_setup_counters(struct comedi_device *dev,
} }
} }
/* utility function that suggests a dma transfer size based on the conversion period 'ns' */ static unsigned int das1800_ai_transfer_size(struct comedi_device *dev,
static unsigned int suggest_transfer_size(const struct comedi_cmd *cmd) struct comedi_subdevice *s)
{ {
struct comedi_cmd *cmd = &s->async->cmd;
unsigned int size = DMA_BUF_SIZE; unsigned int size = DMA_BUF_SIZE;
static const int sample_size = 2; /* size in bytes of one sample from board */ unsigned int sample_size = comedi_bytes_per_sample(s);
unsigned int fill_time = 300000000; /* target time in nanoseconds for filling dma buffer */ unsigned int fill_time = 300000000; /* target time in nanoseconds for filling dma buffer */
unsigned int max_size; /* maximum size we will allow for a transfer */ unsigned int max_size; /* maximum size we will allow for a transfer */
...@@ -1004,8 +1005,8 @@ static unsigned int suggest_transfer_size(const struct comedi_cmd *cmd) ...@@ -1004,8 +1005,8 @@ static unsigned int suggest_transfer_size(const struct comedi_cmd *cmd)
return size; return size;
} }
/* sets up dma */ static void das1800_ai_setup_dma(struct comedi_device *dev,
static void setup_dma(struct comedi_device *dev, const struct comedi_cmd *cmd) struct comedi_subdevice *s)
{ {
struct das1800_private *devpriv = dev->private; struct das1800_private *devpriv = dev->private;
struct das1800_dma_desc *dma = &devpriv->dma_desc[0]; struct das1800_dma_desc *dma = &devpriv->dma_desc[0];
...@@ -1017,7 +1018,7 @@ static void setup_dma(struct comedi_device *dev, const struct comedi_cmd *cmd) ...@@ -1017,7 +1018,7 @@ static void setup_dma(struct comedi_device *dev, const struct comedi_cmd *cmd)
devpriv->cur_dma = 0; devpriv->cur_dma = 0;
/* determine a reasonable dma transfer size */ /* determine a reasonable dma transfer size */
bytes = suggest_transfer_size(cmd); bytes = das1800_ai_transfer_size(dev, s);
dma->size = bytes; dma->size = bytes;
das1800_isadma_program(dma); das1800_isadma_program(dma);
...@@ -1089,7 +1090,7 @@ static int das1800_ai_do_cmd(struct comedi_device *dev, ...@@ -1089,7 +1090,7 @@ static int das1800_ai_do_cmd(struct comedi_device *dev,
/* setup card and start */ /* setup card and start */
program_chanlist(dev, cmd); program_chanlist(dev, cmd);
das1800_setup_counters(dev, cmd); das1800_setup_counters(dev, cmd);
setup_dma(dev, cmd); das1800_ai_setup_dma(dev, s);
outb(control_c, dev->iobase + DAS1800_CONTROL_C); outb(control_c, dev->iobase + DAS1800_CONTROL_C);
/* set conversion rate and length for burst mode */ /* set conversion rate and length for burst mode */
if (control_c & BMDE) { if (control_c & BMDE) {
......
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