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

staging: comedi: ni_at_a2150: use sample manipulation helpers

Use the recently added sample manipulation helpers to remove the hardcoded
assumption of the sample size.
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 14f7b680
...@@ -168,7 +168,6 @@ static irqreturn_t a2150_interrupt(int irq, void *d) ...@@ -168,7 +168,6 @@ static irqreturn_t a2150_interrupt(int irq, void *d)
struct comedi_cmd *cmd; struct comedi_cmd *cmd;
unsigned int max_points, num_points, residue, leftover; unsigned int max_points, num_points, residue, leftover;
unsigned short dpnt; unsigned short dpnt;
static const int sample_size = sizeof(devpriv->dma_buffer[0]);
if (!dev->attached) { if (!dev->attached) {
dev_err(dev->class_dev, "premature interrupt\n"); dev_err(dev->class_dev, "premature interrupt\n");
...@@ -206,12 +205,12 @@ static irqreturn_t a2150_interrupt(int irq, void *d) ...@@ -206,12 +205,12 @@ static irqreturn_t a2150_interrupt(int irq, void *d)
clear_dma_ff(devpriv->dma); clear_dma_ff(devpriv->dma);
/* figure out how many points to read */ /* figure out how many points to read */
max_points = devpriv->dma_transfer_size / sample_size; max_points = comedi_bytes_to_samples(s, devpriv->dma_transfer_size);
/* residue is the number of points left to be done on the dma /* residue is the number of points left to be done on the dma
* transfer. It should always be zero at this point unless * transfer. It should always be zero at this point unless
* the stop_src is set to external triggering. * the stop_src is set to external triggering.
*/ */
residue = get_dma_residue(devpriv->dma) / sample_size; residue = comedi_bytes_to_samples(s, get_dma_residue(devpriv->dma));
num_points = max_points - residue; num_points = max_points - residue;
if (devpriv->count < num_points && cmd->stop_src == TRIG_COUNT) if (devpriv->count < num_points && cmd->stop_src == TRIG_COUNT)
num_points = devpriv->count; num_points = devpriv->count;
...@@ -219,7 +218,8 @@ static irqreturn_t a2150_interrupt(int irq, void *d) ...@@ -219,7 +218,8 @@ static irqreturn_t a2150_interrupt(int irq, void *d)
/* figure out how many points will be stored next time */ /* figure out how many points will be stored next time */
leftover = 0; leftover = 0;
if (cmd->stop_src == TRIG_NONE) { if (cmd->stop_src == TRIG_NONE) {
leftover = devpriv->dma_transfer_size / sample_size; leftover = comedi_bytes_to_samples(s,
devpriv->dma_transfer_size);
} else if (devpriv->count > max_points) { } else if (devpriv->count > max_points) {
leftover = devpriv->count - max_points; leftover = devpriv->count - max_points;
if (leftover > max_points) if (leftover > max_points)
...@@ -248,7 +248,8 @@ static irqreturn_t a2150_interrupt(int irq, void *d) ...@@ -248,7 +248,8 @@ static irqreturn_t a2150_interrupt(int irq, void *d)
/* re-enable dma */ /* re-enable dma */
if (leftover) { if (leftover) {
set_dma_addr(devpriv->dma, virt_to_bus(devpriv->dma_buffer)); set_dma_addr(devpriv->dma, virt_to_bus(devpriv->dma_buffer));
set_dma_count(devpriv->dma, leftover * sample_size); set_dma_count(devpriv->dma,
comedi_samples_to_bytes(s, leftover));
enable_dma(devpriv->dma); enable_dma(devpriv->dma);
} }
release_dma_lock(flags); release_dma_lock(flags);
......
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