static int do_cancel_ioctl(comedi_device *dev,unsigned int arg,void *file);
static int do_cmdtest_ioctl(comedi_device *dev,void *arg,void *file);
static int do_insnlist_ioctl(comedi_device *dev,void *arg,void *file);
+static int do_poll_ioctl(comedi_device *dev,unsigned int subd,void *file);
static void do_become_nonbusy(comedi_device *dev,comedi_subdevice *s);
int resize_buf(comedi_device *dev,comedi_async *s, unsigned int size);
static int comedi_fasync (int fd, struct file *file, int on);
-static int comedi_ioctl(struct inode * inode,struct file * file,unsigned int cmd,unsigned long arg)
+static int comedi_ioctl(struct inode * inode,struct file * file,
+ unsigned int cmd,unsigned long arg)
{
kdev_t minor=MINOR(inode->i_rdev);
comedi_device *dev=comedi_get_device_by_minor(minor);
+ /* Device config is special, because it must work on
+ * an unconfigured device. */
+ if(cmd==COMEDI_DEVCONFIG){
+ return do_devconfig_ioctl(dev,(void *)arg,minor);
+ }
+
+ if(!dev->attached){
+ DPRINTK("no driver configured on /dev/comedi%i\n", dev->minor);
+ return -ENODEV;
+ }
+
switch(cmd)
{
- case COMEDI_DEVCONFIG:
- return do_devconfig_ioctl(dev,(void *)arg,minor);
case COMEDI_BUFCONFIG:
return do_bufconfig_ioctl(dev,(void*)arg);
case COMEDI_DEVINFO:
return do_cmdtest_ioctl(dev,(void *)arg,file);
case COMEDI_INSNLIST:
return do_insnlist_ioctl(dev,(void *)arg,file);
+ case COMEDI_POLL:
+ return do_poll_ioctl(dev,arg,file);
default:
return -EIO;
}
comedi_subdevice *s;
int ret = 0;
- // perform sanity checks
- if(!dev->attached)
- {
- DPRINTK("no driver configured on comedi%i\n", dev->minor);
- return -ENODEV;
- }
-
if(copy_from_user(&bc,arg,sizeof(comedi_bufconfig)))
return -EFAULT;
unsigned long irq_flags;
int m;
- // perform sanity checks
- if(!dev->attached)
- {
- DPRINTK("no driver configured on comedi%i\n", dev->minor);
- return -ENODEV;
- }
-
if(copy_from_user(&bi,arg, sizeof(comedi_bufinfo)))
return -EFAULT;
async->buf_user_count += bi.bytes_read;
// check for buffer overrun
- if(m > async->data_len){ /* XXX MODE */
+ if(m > async->data_len){
async->buf_user_count = async->buf_int_count;
async->buf_user_ptr = async->buf_int_ptr;
do_cancel(dev, dev->read_subdev);
comedi_trig user_trig;
comedi_subdevice *s;
- if(!dev->attached)
- {
- DPRINTK("no driver configured on comedi%i\n", dev->minor);
- return -ENODEV;
- }
-
#if 0
DPRINTK("entering do_trig_ioctl()\n");
#endif
int i;
int ret=0;
- if(!dev->attached)
- {
- DPRINTK("no driver configured on comedi%i\n", dev->minor);
- return -ENODEV;
- }
-
if(copy_from_user(&insnlist,arg,sizeof(comedi_insnlist)))
return -EFAULT;
int ret=0;
unsigned int *chanlist_saver=NULL;
- if(!dev->attached)
- {
- DPRINTK("no driver configured on comedi%i\n", dev->minor);
- return -ENODEV;
- }
-
if(copy_from_user(&user_cmd,arg,sizeof(comedi_cmd))){
DPRINTK("bad cmd address\n");
return -EFAULT;
goto cleanup;
}
+#if 0
/* XXX this needs to be removed when the drivers are ready */
+ /* They should be ready now. */
async->cmd.data = async->prealloc_buf;
async->cmd.data_len=async->prealloc_bufsz;
+#endif
async->data = async->prealloc_buf;
async->data_len=async->prealloc_bufsz;
unsigned int *chanlist=NULL;
unsigned int *chanlist_saver=NULL;
- if(!dev->attached)
- {
- DPRINTK("no driver configured on comedi%i\n", dev->minor);
- return -ENODEV;
- }
-
if(copy_from_user(&user_cmd,arg,sizeof(comedi_cmd))){
DPRINTK("bad cmd address\n");
return -EFAULT;
int ret=0;
comedi_subdevice *s;
- if(!dev->attached)
- {
- DPRINTK("no driver configured on comedi%i\n", dev->minor);
- return -ENODEV;
- }
-
if(arg>=dev->n_subdevices)
return -EINVAL;
s=dev->subdevices+arg;
{
comedi_subdevice *s;
- if(!dev->attached)
- {
- DPRINTK("no driver configured on comedi%i\n", dev->minor);
- return -ENODEV;
- }
-
if(arg>=dev->n_subdevices)
return -EINVAL;
s=dev->subdevices+arg;
{
comedi_subdevice *s;
- if(!dev->attached)
- {
- DPRINTK("no driver configured on comedi%i\n", dev->minor);
- return -ENODEV;
- }
-
if(arg>=dev->n_subdevices)
return -EINVAL;
s=dev->subdevices+arg;
return do_cancel(dev,s);
}
+/*
+ COMEDI_POLL ioctl
+ instructs driver to synchronize buffers
+
+ arg:
+ subdevice number
+
+ reads:
+ nothing
+
+ writes:
+ nothing
+
+*/
+static int do_poll_ioctl(comedi_device *dev,unsigned int arg,void *file)
+{
+ comedi_subdevice *s;
+
+ if(arg>=dev->n_subdevices)
+ return -EINVAL;
+ s=dev->subdevices+arg;
+
+ if(s->lock && s->lock!=file)
+ return -EACCES;
+
+ if(!s->busy)
+ return 0;
+
+ if(s->busy!=file)
+ return -EBUSY;
+
+ if(s->poll)return s->poll(dev,s);
+
+ return -EINVAL;
+}
+
static int do_cancel(comedi_device *dev,comedi_subdevice *s)
{
int ret=0;
if(!s->busy){
/* XXX this is going to change soon -- write cmds
- * will require start_src=TRIG_READY */
+ * will require start_src=TRIG_FOLLOW */
buf_ptr=async->prealloc_buf;
buf_len=async->prealloc_bufsz;
}else{