From c2bf42611c9fbbb3f811fab0d8083fdd4dafccd1 Mon Sep 17 00:00:00 2001 From: Frank Mori Hess Date: Thu, 20 Feb 2003 19:00:20 +0000 Subject: [PATCH] added comedi_get_buffer_size() to kcomedilib --- comedi/kcomedilib/get.c | 19 ++++++++++++++++--- include/linux/comedilib.h | 1 + 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/comedi/kcomedilib/get.c b/comedi/kcomedilib/get.c index c4cb7d4e..0efa7f60 100644 --- a/comedi/kcomedilib/get.c +++ b/comedi/kcomedilib/get.c @@ -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; +} diff --git a/include/linux/comedilib.h b/include/linux/comedilib.h index a4a9ec5e..c1754b30 100644 --- a/include/linux/comedilib.h +++ b/include/linux/comedilib.h @@ -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); -- 2.26.2