added comedi_get_buffer_size() to kcomedilib
authorFrank Mori Hess <fmhess@speakeasy.net>
Thu, 20 Feb 2003 19:00:20 +0000 (19:00 +0000)
committerFrank Mori Hess <fmhess@speakeasy.net>
Thu, 20 Feb 2003 19:00:20 +0000 (19:00 +0000)
comedi/kcomedilib/get.c
include/linux/comedilib.h

index c4cb7d4e97d63c73b5b4ed8055359209f6b432f2..0efa7f60a2282da890143503caf8ebdae3bb165a 100644 (file)
@@ -106,7 +106,7 @@ lsampl_t comedi_get_maxdata(comedi_t *d,unsigned int subdevice,unsigned int chan
 
        if (s->maxdata_list)
                return s->maxdata_list[chan];
-               
+
        return s->maxdata;
 }
 
@@ -122,7 +122,7 @@ int comedi_get_rangetype(comedi_t *d,unsigned int subdevice,unsigned int chan)
        } else {
                ret=s->range_table->length;
        }
-       
+
        ret=ret|(dev->minor<<28)|(subdevice<<24)|(chan<<16);
 
        return ret;
@@ -140,7 +140,7 @@ int comedi_get_n_ranges(comedi_t *d,unsigned int subdevice,unsigned int chan)
        } else {
                ret=s->range_table->length;
        }
-       
+
        return ret;
 }
 
@@ -192,6 +192,7 @@ int comedi_set_user_int_count(comedi_t *d,unsigned int subdevice,unsigned int bu
        unsigned int num_bytes;
 
        async = s->async;
+       if( async == NULL ) return -1;
 
        num_bytes =  buf_user_count - async->buf_read_count;
        comedi_buf_read_free( async, num_bytes );
@@ -200,4 +201,16 @@ int comedi_set_user_int_count(comedi_t *d,unsigned int subdevice,unsigned int bu
        return 0;
 }
 
+int comedi_get_buffer_size(comedi_t *d,unsigned int subdev)
+{
+       comedi_device *dev = (comedi_device *)d;
+       comedi_subdevice *s = dev->subdevices + subdev;
+       comedi_async *async;
+
+       if( subdev >= dev->n_subdevices ) return -1;
+       async = s->async;
+       if(async == NULL) return 0;
+
+       return async->prealloc_bufsz;
+}
 
index a4a9ec5e3e4bbb2aa05ec059ba58f6d4bb55e5bf..c1754b301c4e8cabe3c61df19fe49e7ad58e66b9 100644 (file)
@@ -110,6 +110,7 @@ int comedi_set_user_int_count(comedi_t *dev,unsigned int subdevice,
        unsigned int buf_user_count);
 int comedi_map(comedi_t *dev, unsigned int subdev, void *ptr);
 int comedi_unmap(comedi_t *dev, unsigned int subdev);
+int comedi_get_buffer_size(comedi_t *it,unsigned int subdev);