comedi_open and comedi_close, removed conflict with comedi.
return file->f_pos=new_offset;
}
-static int comedi_open(struct inode *inode,struct file *file)
+static int comedi_fop_open(struct inode *inode,struct file *file)
{
kdev_t minor=MINOR(inode->i_rdev);
comedi_device *dev;
}
#define comedi_ioctl_v20 comedi_ioctl
-#define comedi_open_v20 comedi_open
+#define comedi_open_v20 comedi_fop_open
static struct file_operations comedi_fops={
lseek : comedi_lseek_v20,
#ifdef LINUX_V22
#define comedi_ioctl_v22 comedi_ioctl
-#define comedi_open_v22 comedi_open
+#define comedi_open_v22 comedi_fop_open
static struct file_operations comedi_fops={
llseek : comedi_lseek_v22,
}
+int comedi_open(unsigned int minor)
+{
+ comedi_device *dev;
+
+ if(minor>=COMEDI_NDEVICES)
+ return -ENODEV;
+
+ dev=comedi_get_device_by_minor(minor);
+
+ if(!dev->attached)
+ return -ENODEV;
+
+ return minor;
+}
+
+void comedi_close(unsigned int minor)
+{
+}
+
/*
These functions are #if 0'd because they aren't appropriate
inside RTLinux, at least, not in this form. Interface needs
this function is too complicated
*/
+static int comedi_trig_ioctl_mode0(comedi_device *dev,comedi_subdevice *s,comedi_trig *it);
+static int comedi_trig_ioctl_modeN(comedi_device *dev,comedi_subdevice *s,comedi_trig *it);
int comedi_trig_ioctl(unsigned int minor,unsigned int subdev,comedi_trig *it)
{
comedi_device *dev;
comedi_subdevice *s;
- int ret=0;
+ int ret;
if((ret=minor_to_dev(minor,&dev))<0)
return ret;
if(s->type==COMEDI_SUBD_UNUSED)
return -EIO;
+ if(it->mode==0)
+ return comedi_trig_ioctl_mode0(dev,s,it);
+
+ return comedi_trig_ioctl_modeN(dev,s,it);
+}
+
+static int comedi_trig_ioctl_mode0(comedi_device *dev,comedi_subdevice *s,comedi_trig *it)
+{
+ int ret=0;
+
+ /* are we locked? (ioctl lock) */
+ if(s->lock && s->lock!=&rtcomedi_lock_semaphore)
+ return -EACCES;
+
+ /* are we busy? */
+ if(s->busy)
+ return -EBUSY;
+ s->busy=(void *)&rtcomedi_lock_semaphore;
+
+ /* make sure channel/gain list isn't too long */
+ if(it->n_chan > s->len_chanlist){
+ ret = -EINVAL;
+ goto cleanup;
+ }
+
+ /* make sure each element in channel/gain list is valid */
+ if((ret=check_chanlist(s,it->n_chan,it->chanlist))<0)
+ goto cleanup;
+
+ if(it->data==NULL){
+ ret=-EINVAL;
+ goto cleanup;
+ }
+
+ if(!it->data_len){
+#if 0
+ ret=-EINVAL;
+ goto cleanup;
+#else
+ it->data_len=it->n_chan*it->n;
+ rt_printk("comedi: warning: trig->data_len not set\n");
+#endif
+ }
+
+ s->cur_trig=*it;
+
+ ret=s->trig[0](dev,s,it);
+
+ if(ret>it->n*it->n_chan){
+ rt_printk("comedi: (bug) trig returned too many samples\n");
+ }
+
+cleanup:
+ s->busy=NULL;
+
+ return ret;
+}
+
+static int comedi_trig_ioctl_modeN(comedi_device *dev,comedi_subdevice *s,comedi_trig *it)
+{
+ int ret=0;
+
/* is subdevice RT capable? (important!) */
if(!(s->subdev_flags&SDF_RT)){
ret=-EINVAL;
ret=s->trig[it->mode](dev,s,it);
if(ret==0)return 0;
- if(ret<0)goto cleanup;
-
- if(ret>it->n*it->n_chan){
- rt_printk("comedi: (bug) trig returned too many samples\n");
- }
cleanup:
s->busy=NULL;
/* exported functions */
-int comedi_trig_ioctl(unsigned int minor,unsigned int subdev,comedi_trig *it);
-int __comedi_trig_ioctl(unsigned int minor,unsigned int subdev,comedi_trig *it);
+/* these functions may not be called at real-time priority */
+
+int comedi_open(unsigned int minor);
+void comedi_close(unsigned int minor);
+
+/* these functions may be called at any priority, but may fail at
+ real-time priority */
+
int comedi_lock_ioctl(unsigned int minor,unsigned int subdev);
int comedi_unlock_ioctl(unsigned int minor,unsigned int subdev);
+
+/* these functions may be called at any priority, but you must hold
+ the lock for the subdevice */
+
int comedi_cancel_ioctl(unsigned int minor,unsigned int subdev);
int comedi_register_callback(unsigned int minor,unsigned int subdev,
unsigned int mask,int (*cb)(unsigned int,void *),void *arg);
+int comedi_trig_ioctl(unsigned int minor,unsigned int subdev,comedi_trig *it);
+int __comedi_trig_ioctl(unsigned int minor,unsigned int subdev,comedi_trig *it);
+int comedi_data_write(unsigned int dev,unsigned int subdev,unsigned int chan,
+ unsigned int range,unsigned int aref,lsampl_t data);
+int comedi_data_read(unsigned int dev,unsigned int subdev,unsigned int chan,
+ unsigned int range,unsigned int aref,lsampl_t *data);
+int comedi_dio_config(unsigned int dev,unsigned int subdev,unsigned int chan,
+ unsigned int io);
+int comedi_dio_read(unsigned int dev,unsigned int subdev,unsigned int chan,
+ unsigned int *val);
+int comedi_dio_write(unsigned int dev,unsigned int subdev,unsigned int chan,
+ unsigned int val);
+int comedi_dio_bitfield(unsigned int dev,unsigned int subdev,unsigned int mask,
+ unsigned int *bits);
+
+
#endif