mirror of
https://github.com/rd-stuffs/msm-4.14.git
synced 2025-02-20 11:45:48 +08:00
staging: comedi: mite: introduce mite_sync_dma()
The struct mite_channel 'dir' member specifies if the dma is input or output. Wrap the mite_sync_input_dma() and mite_sync_output_dma() functions with a single mite_sync_dma() so that the drivers don't have to worry about the sync direction. The functions that actually sync the input/output dma currently return -1 if an overflow/underrun is detected otherwise they return 0. If an overflow/underrun is detected the async->event COMEDI_CB_OVERFLOW is also set. The callers never check the return value anyway so just make the functions return void. The async->event can be checked if necessary to detect any errors. 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>
This commit is contained in:
parent
33b0b6913d
commit
51d430056c
@ -680,8 +680,8 @@ void mite_dma_disarm(struct mite_channel *mite_chan)
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(mite_dma_disarm);
|
||||
|
||||
int mite_sync_input_dma(struct mite_channel *mite_chan,
|
||||
struct comedi_subdevice *s)
|
||||
static void mite_sync_input_dma(struct mite_channel *mite_chan,
|
||||
struct comedi_subdevice *s)
|
||||
{
|
||||
struct comedi_async *async = s->async;
|
||||
int count;
|
||||
@ -697,7 +697,7 @@ int mite_sync_input_dma(struct mite_channel *mite_chan,
|
||||
dev_warn(s->device->class_dev,
|
||||
"mite: DMA overwrite of free area\n");
|
||||
async->events |= COMEDI_CB_OVERFLOW;
|
||||
return -1;
|
||||
return;
|
||||
}
|
||||
|
||||
count = nbytes - async->buf_write_count;
|
||||
@ -705,18 +705,15 @@ int mite_sync_input_dma(struct mite_channel *mite_chan,
|
||||
* it's possible count will be negative due to conservative value
|
||||
* returned by mite_bytes_written_to_memory_lb
|
||||
*/
|
||||
if (count <= 0)
|
||||
return 0;
|
||||
|
||||
comedi_buf_write_free(s, count);
|
||||
comedi_inc_scan_progress(s, count);
|
||||
async->events |= COMEDI_CB_BLOCK;
|
||||
return 0;
|
||||
if (count > 0) {
|
||||
comedi_buf_write_free(s, count);
|
||||
comedi_inc_scan_progress(s, count);
|
||||
async->events |= COMEDI_CB_BLOCK;
|
||||
}
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(mite_sync_input_dma);
|
||||
|
||||
int mite_sync_output_dma(struct mite_channel *mite_chan,
|
||||
struct comedi_subdevice *s)
|
||||
static void mite_sync_output_dma(struct mite_channel *mite_chan,
|
||||
struct comedi_subdevice *s)
|
||||
{
|
||||
struct comedi_async *async = s->async;
|
||||
struct comedi_cmd *cmd = &async->cmd;
|
||||
@ -739,7 +736,7 @@ int mite_sync_output_dma(struct mite_channel *mite_chan,
|
||||
((int)(nbytes_ub - old_alloc_count) > 0)) {
|
||||
dev_warn(s->device->class_dev, "mite: DMA underrun\n");
|
||||
async->events |= COMEDI_CB_OVERFLOW;
|
||||
return -1;
|
||||
return;
|
||||
}
|
||||
|
||||
if (finite_regen) {
|
||||
@ -749,20 +746,24 @@ int mite_sync_output_dma(struct mite_channel *mite_chan,
|
||||
* hence we expect that old_alloc_count will reach a maximum of
|
||||
* stop_count bytes.
|
||||
*/
|
||||
return 0;
|
||||
return;
|
||||
}
|
||||
|
||||
count = nbytes_lb - async->buf_read_count;
|
||||
if (count <= 0)
|
||||
return 0;
|
||||
|
||||
if (count) {
|
||||
if (count > 0) {
|
||||
comedi_buf_read_free(s, count);
|
||||
async->events |= COMEDI_CB_BLOCK;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(mite_sync_output_dma);
|
||||
|
||||
void mite_sync_dma(struct mite_channel *mite_chan, struct comedi_subdevice *s)
|
||||
{
|
||||
if (mite_chan->dir == COMEDI_INPUT)
|
||||
mite_sync_input_dma(mite_chan, s);
|
||||
else
|
||||
mite_sync_output_dma(mite_chan, s);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(mite_sync_dma);
|
||||
|
||||
static unsigned int mite_get_status(struct mite_channel *mite_chan)
|
||||
{
|
||||
|
@ -90,10 +90,7 @@ void mite_release_channel(struct mite_channel *mite_chan);
|
||||
|
||||
void mite_dma_arm(struct mite_channel *mite_chan);
|
||||
void mite_dma_disarm(struct mite_channel *mite_chan);
|
||||
int mite_sync_input_dma(struct mite_channel *mite_chan,
|
||||
struct comedi_subdevice *s);
|
||||
int mite_sync_output_dma(struct mite_channel *mite_chan,
|
||||
struct comedi_subdevice *s);
|
||||
void mite_sync_dma(struct mite_channel *mite_chan, struct comedi_subdevice *s);
|
||||
u32 mite_bytes_in_transit(struct mite_channel *mite_chan);
|
||||
unsigned int mite_ack_linkc(struct mite_channel *mite_chan);
|
||||
int mite_done(struct mite_channel *mite_chan);
|
||||
|
@ -460,7 +460,7 @@ static int ni_660x_input_poll(struct comedi_device *dev,
|
||||
|
||||
/* lock to avoid race with comedi_poll */
|
||||
spin_lock_irqsave(&devpriv->interrupt_lock, flags);
|
||||
mite_sync_input_dma(counter->mite_chan, s);
|
||||
mite_sync_dma(counter->mite_chan, s);
|
||||
spin_unlock_irqrestore(&devpriv->interrupt_lock, flags);
|
||||
return comedi_buf_read_n_available(s);
|
||||
}
|
||||
|
@ -890,7 +890,7 @@ static void ni_sync_ai_dma(struct comedi_device *dev)
|
||||
|
||||
spin_lock_irqsave(&devpriv->mite_channel_lock, flags);
|
||||
if (devpriv->ai_mite_chan)
|
||||
mite_sync_input_dma(devpriv->ai_mite_chan, s);
|
||||
mite_sync_dma(devpriv->ai_mite_chan, s);
|
||||
spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags);
|
||||
}
|
||||
|
||||
@ -936,7 +936,7 @@ static void mite_handle_b_linkc(struct mite_struct *mite,
|
||||
|
||||
spin_lock_irqsave(&devpriv->mite_channel_lock, flags);
|
||||
if (devpriv->ao_mite_chan)
|
||||
mite_sync_output_dma(devpriv->ao_mite_chan, s);
|
||||
mite_sync_dma(devpriv->ao_mite_chan, s);
|
||||
spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags);
|
||||
}
|
||||
|
||||
@ -3698,7 +3698,7 @@ static void handle_cdio_interrupt(struct comedi_device *dev)
|
||||
spin_lock_irqsave(&devpriv->mite_channel_lock, flags);
|
||||
if (devpriv->cdo_mite_chan) {
|
||||
mite_ack_linkc(devpriv->cdo_mite_chan);
|
||||
mite_sync_output_dma(devpriv->cdo_mite_chan, s);
|
||||
mite_sync_dma(devpriv->cdo_mite_chan, s);
|
||||
}
|
||||
spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags);
|
||||
|
||||
|
@ -368,7 +368,7 @@ static int ni_pcidio_poll(struct comedi_device *dev, struct comedi_subdevice *s)
|
||||
spin_lock_irqsave(&dev->spinlock, irq_flags);
|
||||
spin_lock(&devpriv->mite_channel_lock);
|
||||
if (devpriv->di_mite_chan)
|
||||
mite_sync_input_dma(devpriv->di_mite_chan, s);
|
||||
mite_sync_dma(devpriv->di_mite_chan, s);
|
||||
spin_unlock(&devpriv->mite_channel_lock);
|
||||
count = comedi_buf_n_bytes_ready(s);
|
||||
spin_unlock_irqrestore(&dev->spinlock, irq_flags);
|
||||
@ -403,7 +403,7 @@ static irqreturn_t nidio_interrupt(int irq, void *d)
|
||||
unsigned int m_status = mite_ack_linkc(devpriv->di_mite_chan);
|
||||
|
||||
if (m_status & CHSR_LINKC) {
|
||||
mite_sync_input_dma(devpriv->di_mite_chan, s);
|
||||
mite_sync_dma(devpriv->di_mite_chan, s);
|
||||
/* XXX need to byteswap */
|
||||
}
|
||||
if (m_status & ~(CHSR_INT | CHSR_LINKC | CHSR_DONE | CHSR_DRDY |
|
||||
|
@ -430,7 +430,7 @@ void ni_tio_handle_interrupt(struct ni_gpct *counter,
|
||||
spin_lock_irqsave(&counter->lock, flags);
|
||||
if (counter->mite_chan) {
|
||||
mite_ack_linkc(counter->mite_chan);
|
||||
mite_sync_input_dma(counter->mite_chan, s);
|
||||
mite_sync_dma(counter->mite_chan, s);
|
||||
}
|
||||
spin_unlock_irqrestore(&counter->lock, flags);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user