#endif
comedi_device *comedi_devices;
+spinlock_t big_comedi_lock = SPIN_LOCK_UNLOCKED;
static int do_devconfig_ioctl(comedi_device *dev,comedi_devconfig *arg,kdev_t minor);
static int do_bufconfig_ioctl(comedi_device *dev,void *arg);
writes:
none
- non-RT linux always controls rtcomedi_lock_semaphore. If an
- RT-linux process wants the lock, it first checks rtcomedi_lock_semaphore.
- 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;
-
static int do_lock_ioctl(comedi_device *dev,unsigned int arg,void * file)
{
int ret=0;
+ unsigned long flags;
comedi_subdevice *s;
if(arg>=dev->n_subdevices)
if(s->busy)
return -EBUSY;
- rtcomedi_lock_semaphore=1;
+ comedi_spin_lock_irqsave(&big_comedi_lock, flags);
if(s->lock && s->lock!=file){
ret=-EACCES;
s->lock=file;
}
- rtcomedi_lock_semaphore=0;
+ comedi_spin_unlock_irqrestore(&big_comedi_lock, flags);
if(ret<0)
return ret;
/* for kcomedilib */
EXPORT_SYMBOL(comedi_devices);
-EXPORT_SYMBOL(rtcomedi_lock_semaphore);
+EXPORT_SYMBOL(big_comedi_lock);
EXPORT_SYMBOL(check_chanlist);
#endif
MODULE_LICENSE("GPL");
-static spinlock_t lock_spinlock;
-
comedi_t *comedi_open(const char *filename)
{
ret = -EBUSY;
goto error;
}
- s->busy = (void *)&rtcomedi_lock_semaphore;
+ s->busy = d;
switch(insn->insn){
case INSN_READ:
unsigned long flags;
int ret=0;
- comedi_spin_lock_irqsave(&lock_spinlock,flags);
+ comedi_spin_lock_irqsave(&big_comedi_lock,flags);
if(s->busy){
ret = -EBUSY;
ret = -EACCES;
}else{
__MOD_INC_USE_COUNT(dev->driver->module);
- s->lock=(void *)&rtcomedi_lock_semaphore;
+ s->lock = d;
}
}
- comedi_spin_unlock_irqrestore(&lock_spinlock,flags);
+ comedi_spin_unlock_irqrestore(&big_comedi_lock,flags);
return ret;
}
async = s->async;
- comedi_spin_lock_irqsave(&lock_spinlock,flags);
+ comedi_spin_lock_irqsave(&big_comedi_lock,flags);
if(s->busy){
- comedi_spin_unlock_irqrestore(&lock_spinlock,flags);
+ comedi_spin_unlock_irqrestore(&big_comedi_lock,flags);
return -EBUSY;
}
if(s->lock && s->lock!=(void *)d){
- comedi_spin_unlock_irqrestore(&lock_spinlock,flags);
+ comedi_spin_unlock_irqrestore(&big_comedi_lock,flags);
return -EACCES;
}
}
__MOD_DEC_USE_COUNT(dev->driver->module);
- comedi_spin_unlock_irqrestore(&lock_spinlock,flags);
+ comedi_spin_unlock_irqrestore(&big_comedi_lock,flags);
return 0;
}
extern comedi_device *comedi_devices;
+extern spinlock_t big_comedi_lock;
/*
* function prototypes
int do_rangeinfo_ioctl(comedi_device *dev,comedi_rangeinfo *arg);
int check_chanlist(comedi_subdevice *s,int n,unsigned int *chanlist);
-extern volatile int rtcomedi_lock_semaphore;
-
/* range stuff */