staging: comedi: das16: use spin-lock when setting timer
authorIan Abbott <abbotti@mev.co.uk>
Wed, 29 Oct 2014 17:35:12 +0000 (17:35 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 30 Oct 2014 20:29:31 +0000 (13:29 -0700)
commit0a43f75ef57fcf20b9637fa49889e6721ceb5ea7
treed88b8a8677bb521ae77ce04bc93d794c0c33aa96
parentab784e5075698ed3b767d5e264a50aab39add209
staging: comedi: das16: use spin-lock when setting timer

"das16" sets a timer running in `das16_cmd_exec()` and sets
`devpriv->timer_running` to indicate that it is running.  The timer
expiration routine `das16_timer_interrupt()` checks
`devpriv->timer_running` to check whether it needs to reschedule the
timer, but this is not synchronized with `das16_cmd_exec()`.  Since
`das16_cancel()` acquires the `dev->spinlock` spin-lock when clearing
`devpriv->timer_running` and removing the timer from the queue, use the
same spin-lock in `das16_cmd_exec()` and `das16_timer_interrupt()`
around the setting and checking of `devpriv->timer_running`.

Since `das16_interrupt()` (called from `das16_timer_interrupt()`) checks
whether DMA is enabled in the device while holding `dev->spinlock`, and
DMA is enabled by `das16_cmd_exec()` around the time it schedules the
timer, enable the DMA in the device while holding the spin-lock.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/drivers/das16.c