static int do_subdinfo_ioctl(comedi_device * dev, comedi_subdinfo * arg,
void *file);
static int do_chaninfo_ioctl(comedi_device * dev, comedi_chaninfo * arg);
-static int do_bufinfo_ioctl(comedi_device * dev, void *arg);
+static int do_bufinfo_ioctl(comedi_device * dev, void *arg, void *file);
static int do_cmd_ioctl(comedi_device * dev, void *arg, void *file);
static int do_lock_ioctl(comedi_device * dev, unsigned int arg, void *file);
static int do_unlock_ioctl(comedi_device * dev, unsigned int arg, void *file);
rc = do_rangeinfo_ioctl(dev, (void *)arg);
break;
case COMEDI_BUFINFO:
- rc = do_bufinfo_ioctl(dev, (void *)arg);
+ rc = do_bufinfo_ioctl(dev, (void *)arg, file);
break;
case COMEDI_LOCK:
rc = do_lock_ioctl(dev, arg, file);
modified bufinfo at arg
*/
-static int do_bufinfo_ioctl(comedi_device * dev, void *arg)
+static int do_bufinfo_ioctl(comedi_device * dev, void *arg, void *file)
{
comedi_bufinfo bi;
comedi_subdevice *s;
return -EINVAL;
s = dev->subdevices + bi.subdevice;
- async = s->async;
+ if (s->lock && s->lock != file)
+ return -EACCES;
+
+ async = s->async;
if (!async) {
DPRINTK("subdevice does not have async capability\n");
bi.buf_write_ptr = 0;
bi.bytes_written = 0;
goto copyback;
}
+ if (!s->busy) {
+ bi.bytes_read = 0;
+ bi.bytes_written = 0;
+ goto copyback;
+ }
+ if (s->busy != file)
+ return -EACCES;
if (bi.bytes_read && (s->subdev_flags & SDF_CMD_READ)) {
bi.bytes_read = comedi_buf_read_alloc(async, bi.bytes_read);