// perform sanity checks
if(!dev->attached)
- return -EINVAL;
+ {
+ DPRINTK("no driver configured on comedi%i\n", dev->minor);
+ return -ENODEV;
+ }
if(copy_from_user(&bc,arg,sizeof(comedi_bufconfig)))
return -EFAULT;
if(bc.read_size){
if(dev->read_subdev < 0)
- return -EINVAL;
+ {
+ DPRINTK("device has no read subdevice, buffer resize failed\n");
+ return -ENODEV;
+ }
rsd = &dev->subdevices[dev->read_subdev];
}
if(bc.write_size){
if(dev->write_subdev < 0)
- return -EINVAL;
+ {
+ DPRINTK("device has no write subdevice, buffer resize failed\n");
+ return -ENODEV;
+ }
wsd = &dev->subdevices[dev->write_subdev];
return ret;
bc.read_size = rsd->prealloc_bufsz;
- DPRINTK("dev %i read buffer resized to %i bytes\n", dev->minor, bc.read_size);
+ DPRINTK("comedi%i read buffer resized to %i bytes\n", dev->minor, bc.read_size);
}
if(bc.write_size){
ret = resize_buf(dev,wsd,bc.write_size);
return ret;
bc.write_size = wsd->prealloc_bufsz;
- DPRINTK("dev %i write buffer resized to %i bytes\n", dev->minor, bc.write_size);
+ DPRINTK("comedi%i write buffer resized to %i bytes\n", dev->minor, bc.write_size);
}
if(copy_to_user(arg,&bc,sizeof(comedi_bufconfig)))
{
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
DPRINTK("bad trig address\n");
return -EFAULT;
}
-
+
#if 0
/* this appears to be the only way to check if we are allowed
to write to an area. */
if(copy_to_user(arg,&user_trig,sizeof(comedi_trig)))
return -EFAULT;
#endif
-
+
if(user_trig.subdev>=dev->n_subdevices){
DPRINTK("%d no such subdevice\n",user_trig.subdev);
return -ENODEV;
DPRINTK("%d not useable subdevice\n",user_trig.subdev);
return -EIO;
}
-
+
/* are we locked? (ioctl lock) */
if(s->lock && s->lock!=file){
DPRINTK("device locked\n");
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;
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;
If it is 1, it knows it is pre-empting this function, and fails.
Obviously, if RT-linux fails to get a lock, it *must* allow
linux to run, since that is the only way to free the lock.
-
+
This function is not SMP compatible.
necessary locking:
- ioctl/rt lock (this type)
- lock while subdevice busy
- lock while subdevice being programmed
-
+
*/
volatile int rtcomedi_lock_semaphore=0;
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;
-
+
if(s->busy)
return -EBUSY;
rtcomedi_lock_semaphore=1;
-
+
if(s->lock && s->lock!=file){
ret=-EACCES;
}else{
s->lock=file;
}
-
+
rtcomedi_lock_semaphore=0;
if(ret<0)
arg:
subdevice number
-
+
reads:
none
{
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;
-
+
if(s->busy)
return -EBUSY;
if(s->lock && s->lock!=file)
return -EACCES;
-
+
if(s->lock==file){
#if 0
if(s->unlock)
{
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;
int subdev;
struct comedi_file_private *cfp;
+ if(!dev->attached)
+ {
+ DPRINTK("no driver configured on comedi%i\n", dev->minor);
+ return -ENODEV;
+ }
+
if(vma->vm_flags & VM_WRITE){
subdev=dev->write_subdev;
}else{
dev=comedi_get_device_by_minor(MINOR(RDEV_OF_FILE(file)));
+ if(!dev->attached)
+ {
+ DPRINTK("no driver configured on comedi%i\n", dev->minor);
+ return -ENODEV;
+ }
+
poll_wait(file, &dev->read_wait, wait);
poll_wait(file, &dev->write_wait, wait);
mask = 0;
unsigned int buf_len;
dev=comedi_get_device_by_minor(MINOR(RDEV_OF_FILE(file)));
+
+ if(!dev->attached)
+ {
+ DPRINTK("no driver configured on comedi%i\n", dev->minor);
+ return -ENODEV;
+ }
+
if(dev->write_subdev<0)return -EIO;
s=dev->subdevices+dev->write_subdev;
int sample_size;
dev=comedi_get_device_by_minor(MINOR(RDEV_OF_FILE(file)));
+
+ if(!dev->attached)
+ {
+ DPRINTK("no driver configured on comedi%i\n", dev->minor);
+ return -ENODEV;
+ }
+
if(dev->read_subdev<0)return -EIO;
s=dev->subdevices+dev->read_subdev;
{
comedi_device *dev;
loff_t new_offset;
-
+
dev=comedi_get_device_by_minor(MINOR(RDEV_OF_FILE(file)));
switch(origin){