From 85233be248abd1164ab8e4527c6ce480dc809544 Mon Sep 17 00:00:00 2001 From: David Schleef Date: Thu, 16 May 2002 06:30:54 +0000 Subject: [PATCH] Added new ioctl() wrapper. --- lib/buffer.c | 10 +++++----- lib/comedi.c | 22 +++++++++++----------- lib/data.c | 4 ++-- lib/filler.c | 12 ++++++------ lib/ioctl.c | 12 ++++++++++++ lib/libinternal.h | 3 +++ lib/sv.c | 4 ++-- 7 files changed, 41 insertions(+), 26 deletions(-) diff --git a/lib/buffer.c b/lib/buffer.c index f7e952c..9970a41 100644 --- a/lib/buffer.c +++ b/lib/buffer.c @@ -33,7 +33,7 @@ int comedi_set_buffer_size(comedi_t *it, unsigned int subdev, unsigned int size) memset(&bc, 0, sizeof(bc)); bc.subdevice = subdev; bc.size = size; - ret = ioctl(it->fd, COMEDI_BUFCONFIG, &bc); + ret = comedi_ioctl(it->fd, COMEDI_BUFCONFIG, (unsigned long)&bc); __comedi_errno = errno; if(ret < 0) return ret; @@ -48,7 +48,7 @@ int comedi_set_max_buffer_size(comedi_t *it, unsigned int subdev, unsigned int m memset(&bc, 0, sizeof(bc)); bc.subdevice = subdev; bc.maximum_size = max_size; - ret = ioctl(it->fd, COMEDI_BUFCONFIG, &bc); + ret = comedi_ioctl(it->fd, COMEDI_BUFCONFIG, (unsigned long)&bc); __comedi_errno = errno; if(ret < 0) return ret; @@ -77,7 +77,7 @@ int comedi_mark_buffer_read(comedi_t *it, unsigned int subdev, unsigned int byte memset(&bi, 0, sizeof(bi)); bi.bytes_read = bytes; - ret = ioctl(it->fd, COMEDI_BUFINFO, &bi); + ret = comedi_ioctl(it->fd, COMEDI_BUFINFO, (unsigned long)&bi); __comedi_errno = errno; if(__comedi_errno == EINVAL)__comedi_errno = EBUF_OVR; return bi.buf_int_count - bi.buf_user_count; @@ -89,7 +89,7 @@ int comedi_get_buffer_offset(comedi_t *it, unsigned int subdev) comedi_bufinfo bi; memset(&bi, 0, sizeof(bi)); - ret = ioctl(it->fd, COMEDI_BUFINFO, &bi); + ret = comedi_ioctl(it->fd, COMEDI_BUFINFO, (unsigned long)&bi); if(ret < 0) return ret; return bi.buf_user_ptr; } @@ -100,7 +100,7 @@ int comedi_get_front_count(comedi_t *it, unsigned int subdev) comedi_bufinfo bi; memset(&bi, 0, sizeof(bi)); - ret = ioctl(it->fd, COMEDI_BUFINFO, &bi); + ret = comedi_ioctl(it->fd, COMEDI_BUFINFO, (unsigned long)&bi); if(ret < 0) return ret; return bi.buf_int_count; } diff --git a/lib/comedi.c b/lib/comedi.c index 628ee9a..8e20fe5 100644 --- a/lib/comedi.c +++ b/lib/comedi.c @@ -65,7 +65,7 @@ comedi_t *comedi_open(const char *fn) goto cleanup; } - if(ioctl(it->fd, COMEDI_DEVINFO, &it->devinfo)<0) + if(comedi_ioctl(it->fd, COMEDI_DEVINFO, (unsigned long)&it->devinfo)<0) goto cleanup; it->n_subdevices=it->devinfo.n_subdevs; @@ -124,12 +124,12 @@ int comedi_close(comedi_t *it) int comedi_cancel(comedi_t *it,unsigned int subdevice) { - return ioctl(it->fd,COMEDI_CANCEL,subdevice); + return comedi_ioctl(it->fd,COMEDI_CANCEL,subdevice); } int comedi_poll(comedi_t *it,unsigned int subdevice) { - return ioctl(it->fd,COMEDI_POLL,subdevice); + return comedi_ioctl(it->fd,COMEDI_POLL,subdevice); } int comedi_fileno(comedi_t *it) @@ -145,13 +145,13 @@ int comedi_trigger(comedi_t *it,comedi_trig *t) if(!it || !t) return -1; - return ioctl(it->fd, COMEDI_TRIG, t); + return comedi_ioctl(it->fd, COMEDI_TRIG, (unsigned long)t); } int comedi_command(comedi_t *it,comedi_cmd *t) { int ret; - ret = ioctl(it->fd,COMEDI_CMD,t); + ret = comedi_ioctl(it->fd, COMEDI_CMD, (unsigned long)t); __comedi_errno = errno; switch(__comedi_errno){ case EIO: @@ -164,7 +164,7 @@ int comedi_command(comedi_t *it,comedi_cmd *t) int comedi_command_test(comedi_t *it,comedi_cmd *t) { int ret; - ret = ioctl(it->fd,COMEDI_CMDTEST,t); + ret = comedi_ioctl(it->fd, COMEDI_CMDTEST, (unsigned long)t); __comedi_errno = errno; switch(__comedi_errno){ case EIO: @@ -177,7 +177,7 @@ int comedi_command_test(comedi_t *it,comedi_cmd *t) int comedi_do_insnlist(comedi_t *it,comedi_insnlist *il) { int ret; - ret = ioctl(it->fd,COMEDI_INSNLIST,il); + ret = comedi_ioctl(it->fd, COMEDI_INSNLIST, (unsigned long)il); __comedi_errno = errno; return ret; } @@ -185,7 +185,7 @@ int comedi_do_insnlist(comedi_t *it,comedi_insnlist *il) int comedi_do_insn(comedi_t *it,comedi_insn *insn) { if(it->has_insn_ioctl){ - return ioctl(it->fd,COMEDI_INSN,insn); + return comedi_ioctl(it->fd, COMEDI_INSN, (unsigned long)insn); }else{ comedi_insnlist il; int ret; @@ -193,7 +193,7 @@ int comedi_do_insn(comedi_t *it,comedi_insn *insn) il.n_insns = 1; il.insns = insn; - ret = ioctl(it->fd,COMEDI_INSNLIST,&il); + ret = comedi_ioctl(it->fd, COMEDI_INSNLIST, (unsigned long)&il); if(ret<0)return ret; return insn->n; @@ -202,11 +202,11 @@ int comedi_do_insn(comedi_t *it,comedi_insn *insn) int comedi_lock(comedi_t *it,unsigned int subdevice) { - return ioctl(it->fd,COMEDI_LOCK,subdevice); + return comedi_ioctl(it->fd, COMEDI_LOCK, subdevice); } int comedi_unlock(comedi_t *it,unsigned int subdevice) { - return ioctl(it->fd,COMEDI_UNLOCK,subdevice); + return comedi_ioctl(it->fd, COMEDI_UNLOCK, subdevice); } diff --git a/lib/data.c b/lib/data.c index abae977..9f2f3c7 100644 --- a/lib/data.c +++ b/lib/data.c @@ -81,7 +81,7 @@ int comedi_data_write(comedi_t *it,unsigned int subdev,unsigned int chan,unsigne } cmd.chanlist=&chan; - return ioctl(it->fd, COMEDI_TRIG, &cmd); + return comedi_ioctl(it->fd, COMEDI_TRIG, (unsigned long)&cmd); } } @@ -134,7 +134,7 @@ static inline int comedi_internal_data_read_n(comedi_t *it, unsigned int subdev, cmd.data=sdata; } - ret = ioctl(it->fd, COMEDI_TRIG, &cmd); + ret = comedi_ioctl(it->fd, COMEDI_TRIG, (unsigned long)&cmd); if(ret<0) return ret; diff --git a/lib/filler.c b/lib/filler.c index 3738245..498682e 100644 --- a/lib/filler.c +++ b/lib/filler.c @@ -55,7 +55,7 @@ int get_subdevices(comedi_t *it) s=malloc(sizeof(comedi_subdinfo)*it->n_subdevices); debug_ptr(s); - ret = ioctl(it->fd, COMEDI_SUBDINFO, s); + ret = comedi_ioctl(it->fd, COMEDI_SUBDINFO, (unsigned long)s); debug_int(ret); r=it->subdevices=realloc(it->subdevices, @@ -92,7 +92,7 @@ int get_subdevices(comedi_t *it) ci.flaglist = r[i].flags_list; ci.rangelist = r[i].range_type_list; ci.maxdata_list = r[i].maxdata_list; - ret = ioctl(it->fd, COMEDI_CHANINFO, &ci); + ret = comedi_ioctl(it->fd, COMEDI_CHANINFO, (unsigned long)&ci); debug_int(ret); if(r[i].subd_flags&SDF_RANGETYPE){ @@ -131,7 +131,7 @@ comedi_range *get_rangeinfo(int fd,unsigned int range_type) ri.range_type = range_type; ri.range_ptr = kr; - ret = ioctl(fd, COMEDI_RANGEINFO, &ri); + ret = comedi_ioctl(fd, COMEDI_RANGEINFO, (unsigned long)&ri); if(ret<0){ fprintf(stderr,"ioctl(%d,COMEDI_RANGEINFO,0x%08x,%p)\n",fd,range_type,kr); } @@ -169,7 +169,7 @@ static int do_test_for_cmd(comedi_t *dev,unsigned int subdevice) it.scan_end_src = TRIG_ANY; it.stop_src = TRIG_ANY; - ret = ioctl(dev->fd,COMEDI_CMDTEST,&it); + ret = comedi_ioctl(dev->fd, COMEDI_CMDTEST, (unsigned long)&it); if(ret<0 && errno==EIO){ return 0; @@ -198,7 +198,7 @@ static int do_test_for_insnlist(comedi_t *dev) insn.n = 2; insn.data = data; - ret = ioctl(dev->fd,COMEDI_INSNLIST,&il); + ret = comedi_ioctl(dev->fd, COMEDI_INSNLIST, (unsigned long)&il); if(ret<0){ if(errno!=EIO){ @@ -226,7 +226,7 @@ static int do_test_for_insn(comedi_t *dev) insn.n = 2; insn.data = data; - ret = ioctl(dev->fd,COMEDI_INSN,&insn); + ret = comedi_ioctl(dev->fd, COMEDI_INSN, (unsigned long)&insn); if(ret<0){ if(errno!=EIO){ diff --git a/lib/ioctl.c b/lib/ioctl.c index 6e8f0d0..3ea1a1c 100644 --- a/lib/ioctl.c +++ b/lib/ioctl.c @@ -39,3 +39,15 @@ /* ioctl wrappers */ +int comedi_ioctl_debug(int fd, int request, unsigned long arg) +{ + int ret; + + fprintf(stderr,"ioctl(%d,0x%08x,0x%08lx) = ",fd,request,arg); + ret = ioctl(fd,request,arg); + fprintf(stderr,"%d\n",ret); + + return ret; +} + + diff --git a/lib/libinternal.h b/lib/libinternal.h index 6b033cd..2820437 100644 --- a/lib/libinternal.h +++ b/lib/libinternal.h @@ -120,6 +120,9 @@ struct subdevice_struct{ }; +#define comedi_ioctl comedi_ioctl_debug + +int comedi_ioctl_debug(int,int,unsigned long); /* filler routines */ diff --git a/lib/sv.c b/lib/sv.c index 5ed252f..6bdb7c4 100644 --- a/lib/sv.c +++ b/lib/sv.c @@ -107,7 +107,7 @@ int sv_measure_l(comedi_sv_t *it,double *data) for(n=0;nn;){ t.data=(void *)(val+n); t.n=it->n-n; - i = ioctl(it->dev->fd, COMEDI_TRIG, &t); + i = comedi_ioctl(it->dev->fd, COMEDI_TRIG, (unsigned long)&t); if(i<=0){ ret=i; goto out; @@ -160,7 +160,7 @@ int sv_measure_s(comedi_sv_t *it,double *data) for(n=0;nn;){ t.data=val+n; t.n=it->n-n; - i = ioctl(it->dev->fd, COMEDI_TRIG, &t); + i = comedi_ioctl(it->dev->fd, COMEDI_TRIG, (unsigned long)&t); if(i<=0){ ret=i; goto out; -- 2.26.2