mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-29 23:53:32 +00:00
staging: comedi: comedidev.h: clarify async->event error/cancel detection
Introduce COMEDI_CB_ERROR_MASK and COMEDI_CB_CANCEL_MASK to clarify the async->events that indicate errors and cancel an async command. Use the new defines to tidy up and clarify the code. 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
bb856b6c04
commit
781f933c15
4 changed files with 17 additions and 19 deletions
|
@ -1555,9 +1555,7 @@ static int do_cmd_ioctl(struct comedi_device *dev,
|
|||
|
||||
comedi_buf_reset(s);
|
||||
|
||||
async->cb_mask =
|
||||
COMEDI_CB_EOA | COMEDI_CB_BLOCK | COMEDI_CB_ERROR |
|
||||
COMEDI_CB_OVERFLOW;
|
||||
async->cb_mask = COMEDI_CB_BLOCK | COMEDI_CB_CANCEL_MASK;
|
||||
if (async->cmd.flags & CMDF_WAKE_EOS)
|
||||
async->cb_mask |= COMEDI_CB_EOS;
|
||||
|
||||
|
@ -2390,14 +2388,14 @@ void comedi_event(struct comedi_device *dev, struct comedi_subdevice *s)
|
|||
if (!comedi_is_subdevice_running(s))
|
||||
return;
|
||||
|
||||
if (s->
|
||||
async->events & (COMEDI_CB_EOA | COMEDI_CB_ERROR |
|
||||
COMEDI_CB_OVERFLOW)) {
|
||||
if (s->async->events & COMEDI_CB_CANCEL_MASK)
|
||||
runflags_mask |= SRF_RUNNING;
|
||||
}
|
||||
/* remember if an error event has occurred, so an error
|
||||
* can be returned the next time the user does a read() */
|
||||
if (s->async->events & (COMEDI_CB_ERROR | COMEDI_CB_OVERFLOW)) {
|
||||
|
||||
/*
|
||||
* Remember if an error event has occurred, so an error
|
||||
* can be returned the next time the user does a read().
|
||||
*/
|
||||
if (s->async->events & COMEDI_CB_ERROR_MASK) {
|
||||
runflags_mask |= SRF_ERROR;
|
||||
runflags |= SRF_ERROR;
|
||||
}
|
||||
|
|
|
@ -221,6 +221,9 @@ struct comedi_async {
|
|||
* @COMEDI_CB_EOBUF: DEPRECATED: end of buffer
|
||||
* @COMEDI_CB_ERROR: card error during acquisition
|
||||
* @COMEDI_CB_OVERFLOW: buffer overflow/underflow
|
||||
*
|
||||
* @COMEDI_CB_ERROR_MASK: events that indicate an error has occurred
|
||||
* @COMEDI_CB_CANCEL_MASK: events that will cancel an async command
|
||||
*/
|
||||
#define COMEDI_CB_EOS (1 << 0)
|
||||
#define COMEDI_CB_EOA (1 << 1)
|
||||
|
@ -229,6 +232,9 @@ struct comedi_async {
|
|||
#define COMEDI_CB_ERROR (1 << 4)
|
||||
#define COMEDI_CB_OVERFLOW (1 << 5)
|
||||
|
||||
#define COMEDI_CB_ERROR_MASK (COMEDI_CB_ERROR | COMEDI_CB_OVERFLOW)
|
||||
#define COMEDI_CB_CANCEL_MASK (COMEDI_CB_EOA | COMEDI_CB_ERROR_MASK)
|
||||
|
||||
struct comedi_driver {
|
||||
struct comedi_driver *next;
|
||||
|
||||
|
|
|
@ -375,7 +375,7 @@ unsigned int comedi_handle_events(struct comedi_device *dev,
|
|||
if (events == 0)
|
||||
return events;
|
||||
|
||||
if (events & (COMEDI_CB_EOA | COMEDI_CB_ERROR | COMEDI_CB_OVERFLOW))
|
||||
if (events & COMEDI_CB_CANCEL_MASK)
|
||||
s->cancel(dev, s);
|
||||
|
||||
comedi_event(dev, s);
|
||||
|
|
|
@ -1119,7 +1119,6 @@ static bool pci230_handle_ao_fifo(struct comedi_device *dev,
|
|||
unsigned short dacstat;
|
||||
unsigned int i, n;
|
||||
unsigned int events = 0;
|
||||
bool running;
|
||||
|
||||
/* Get DAC FIFO status. */
|
||||
dacstat = inw(devpriv->daqio + PCI230_DACCON);
|
||||
|
@ -1201,12 +1200,8 @@ static bool pci230_handle_ao_fifo(struct comedi_device *dev,
|
|||
events |= COMEDI_CB_OVERFLOW | COMEDI_CB_ERROR;
|
||||
}
|
||||
}
|
||||
if (events & (COMEDI_CB_EOA | COMEDI_CB_ERROR | COMEDI_CB_OVERFLOW))
|
||||
running = false;
|
||||
else
|
||||
running = true;
|
||||
async->events |= events;
|
||||
return running;
|
||||
return !(async->events & COMEDI_CB_CANCEL_MASK);
|
||||
}
|
||||
|
||||
static int pci230_ao_inttrig_scan_begin(struct comedi_device *dev,
|
||||
|
@ -2128,8 +2123,7 @@ static void pci230_handle_ai(struct comedi_device *dev,
|
|||
events |= COMEDI_CB_BLOCK;
|
||||
}
|
||||
async->events |= events;
|
||||
if (!(async->events & (COMEDI_CB_EOA | COMEDI_CB_ERROR |
|
||||
COMEDI_CB_OVERFLOW))) {
|
||||
if (!(async->events & COMEDI_CB_CANCEL_MASK)) {
|
||||
/* update FIFO interrupt trigger level */
|
||||
pci230_ai_update_fifo_trigger_level(dev, s);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue