From 13e1b8908666adf0a29794709ecce966d3be36a8 Mon Sep 17 00:00:00 2001 From: Frank Mori Hess Date: Thu, 3 Oct 2002 02:27:35 +0000 Subject: [PATCH] don't generate events when there are none --- comedi/drivers/comedi_fc.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/comedi/drivers/comedi_fc.c b/comedi/drivers/comedi_fc.c index 72b8647f..4790378e 100644 --- a/comedi/drivers/comedi_fc.c +++ b/comedi/drivers/comedi_fc.c @@ -61,6 +61,8 @@ unsigned int cfc_write_array_to_buffer( comedi_subdevice *subd, void *data, comedi_async *async = subd->async; unsigned int retval; + if( num_bytes == 0 ) return 0; + retval = comedi_buf_write_alloc( async, num_bytes ); if( retval != num_bytes ) { @@ -69,12 +71,9 @@ unsigned int cfc_write_array_to_buffer( comedi_subdevice *subd, void *data, } comedi_buf_memcpy_to( async, 0, data, num_bytes); - comedi_buf_write_free( async, num_bytes ); - increment_scan_progress( subd, num_bytes ); - - if( num_bytes ) async->events |= COMEDI_CB_BLOCK; + async->events |= COMEDI_CB_BLOCK; return num_bytes; } @@ -85,6 +84,8 @@ unsigned int cfc_read_array_from_buffer( comedi_subdevice *subd, void *data, comedi_async *async = subd->async; unsigned int bytes_available; + if( num_bytes == 0 ) return 0; + bytes_available = comedi_buf_read_n_available( async ); if( bytes_available < num_bytes ) { @@ -92,12 +93,9 @@ unsigned int cfc_read_array_from_buffer( comedi_subdevice *subd, void *data, } comedi_buf_memcpy_from( async, 0, data, num_bytes); - comedi_buf_read_free( async, num_bytes ); - increment_scan_progress( subd, num_bytes ); - - if( num_bytes ) async->events |= COMEDI_CB_BLOCK; + async->events |= COMEDI_CB_BLOCK; return num_bytes; } @@ -106,6 +104,8 @@ unsigned int cfc_handle_events( comedi_device *dev, comedi_subdevice *subd ) { unsigned int events = subd->async->events; + if( events == 0 ) return events; + if( events & ( COMEDI_CB_EOA | COMEDI_CB_ERROR | COMEDI_CB_OVERFLOW ) ) subd->cancel( dev, subd ); -- 2.26.2