From: Frank Mori Hess Date: Sun, 13 Mar 2005 15:17:52 +0000 (+0000) Subject: move check of s->busy after aquisition of big_comedi_lock in X-Git-Tag: r0_7_70~17 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=806efd3a306a148e6148560ec34fa6623119a2d5;p=comedi.git move check of s->busy after aquisition of big_comedi_lock in do_lock_ioctl. Make locking return a less confusing error code on failure. Make locking fail if process already has lock (alternative would be to make locking recursive, but I don't see a reason to bother). --- diff --git a/comedi/comedi_fops.c b/comedi/comedi_fops.c index a2e189df..df3a778e 100644 --- a/comedi/comedi_fops.c +++ b/comedi/comedi_fops.c @@ -1084,17 +1084,17 @@ static int do_lock_ioctl(comedi_device *dev,unsigned int arg,void * file) 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; - - comedi_spin_lock_irqsave(&big_comedi_lock, flags); - - if(s->lock && s->lock!=file){ - ret=-EACCES; + } + if(s->lock){ + ret=-EBUSY; }else{ s->lock=file; } - comedi_spin_unlock_irqrestore(&big_comedi_lock, flags); if(ret<0) diff --git a/comedi/kcomedilib/kcomedilib_main.c b/comedi/kcomedilib/kcomedilib_main.c index 39e3ee2a..78cab126 100644 --- a/comedi/kcomedilib/kcomedilib_main.c +++ b/comedi/kcomedilib/kcomedilib_main.c @@ -335,8 +335,8 @@ int comedi_lock(comedi_t *d,unsigned int subdevice) if(s->busy){ ret = -EBUSY; }else{ - if(s->lock && s->lock!=d){ - ret = -EACCES; + if(s->lock){ + ret = -EBUSY; }else{ s->lock = d; }