don't generate events when there are none
authorFrank Mori Hess <fmhess@speakeasy.net>
Thu, 3 Oct 2002 02:27:35 +0000 (02:27 +0000)
committerFrank Mori Hess <fmhess@speakeasy.net>
Thu, 3 Oct 2002 02:27:35 +0000 (02:27 +0000)
comedi/drivers/comedi_fc.c

index 72b8647f0cc56cc8899d0219bef03df1a122abc6..4790378eca1b1e98bfff3d535bc7045d6445393c 100644 (file)
@@ -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 );