#endif
comedi_device *comedi_devices;
-spinlock_t big_comedi_lock; /* Dynamic initialization */
static int do_devconfig_ioctl(comedi_device * dev, comedi_devconfig * arg);
static int do_bufconfig_ioctl(comedi_device * dev, void *arg);
return -EINVAL;
s = dev->subdevices + arg;
- comedi_spin_lock_irqsave(&big_comedi_lock, flags);
- if (s->busy) {
- comedi_spin_unlock_irqrestore(&big_comedi_lock, flags);
- return -EBUSY;
- }
- if (s->lock) {
+ comedi_spin_lock_irqsave(&s->spin_lock, flags);
+ if (s->busy || s->lock) {
ret = -EBUSY;
} else {
s->lock = file;
}
- comedi_spin_unlock_irqrestore(&big_comedi_lock, flags);
+ comedi_spin_unlock_irqrestore(&s->spin_lock, flags);
if (ret < 0)
return ret;
printk("comedi: version " COMEDI_RELEASE
" - David Schleef <ds@schleef.org>\n");
- spin_lock_init(&big_comedi_lock);
retval = register_chrdev_region(MKDEV(COMEDI_MAJOR, 0),
COMEDI_NUM_MINORS, "comedi");
if (retval)
{
unsigned long flags;
- comedi_spin_lock_irqsave(&s->runflags_lock, flags);
+ comedi_spin_lock_irqsave(&s->spin_lock, flags);
s->runflags &= ~mask;
s->runflags |= (bits & mask);
- comedi_spin_unlock_irqrestore(&s->runflags_lock, flags);
+ comedi_spin_unlock_irqrestore(&s->spin_lock, flags);
}
unsigned comedi_get_subdevice_runflags(comedi_subdevice * s)
unsigned long flags;
unsigned runflags;
- comedi_spin_lock_irqsave(&s->runflags_lock, flags);
+ comedi_spin_lock_irqsave(&s->spin_lock, flags);
runflags = s->runflags;
- comedi_spin_unlock_irqrestore(&s->runflags_lock, flags);
+ comedi_spin_unlock_irqrestore(&s->spin_lock, flags);
return runflags;
}
unsigned long flags;
int ret = 0;
- comedi_spin_lock_irqsave(&big_comedi_lock, flags);
+ comedi_spin_lock_irqsave(&s->spin_lock, flags);
if (s->busy) {
ret = -EBUSY;
}
}
- comedi_spin_unlock_irqrestore(&big_comedi_lock, flags);
+ comedi_spin_unlock_irqrestore(&s->spin_lock, flags);
return ret;
}
comedi_subdevice *s = dev->subdevices + subdevice;
unsigned long flags;
comedi_async *async;
+ int ret;
async = s->async;
- comedi_spin_lock_irqsave(&big_comedi_lock, flags);
+ comedi_spin_lock_irqsave(&s->spin_lock, flags);
if (s->busy) {
- comedi_spin_unlock_irqrestore(&big_comedi_lock, flags);
- return -EBUSY;
- }
-
- if (s->lock && s->lock != (void *)d) {
- comedi_spin_unlock_irqrestore(&big_comedi_lock, flags);
- return -EACCES;
- }
+ ret = -EBUSY;
+ } else if (s->lock && s->lock != (void *)d) {
+ ret = -EACCES;
+ } else {
+ s->lock = NULL;
- s->lock = NULL;
+ if (async) {
+ async->cb_mask = 0;
+ async->cb_func = NULL;
+ async->cb_arg = NULL;
+ }
- if (async) {
- async->cb_mask = 0;
- async->cb_func = NULL;
- async->cb_arg = NULL;
+ ret = 0;
}
- comedi_spin_unlock_irqrestore(&big_comedi_lock, flags);
+ comedi_spin_unlock_irqrestore(&s->spin_lock, flags);
- return 0;
+ return ret;
}
/*
void *lock;
void *busy;
unsigned runflags;
- spinlock_t runflags_lock;
+ spinlock_t spin_lock;
int io_bits;
};
extern comedi_device *comedi_devices;
-extern spinlock_t big_comedi_lock;
#ifdef CONFIG_COMEDI_DEBUG
extern int comedi_debug;
for (i = 0; i < num_subdevices; ++i) {
dev->subdevices[i].device = dev;
dev->subdevices[i].async_dma_dir = DMA_NONE;
- spin_lock_init(&dev->subdevices[i].runflags_lock);
+ spin_lock_init(&dev->subdevices[i].spin_lock);
}
return 0;
}