From: Frank Mori Hess Date: Thu, 8 Feb 2001 02:00:36 +0000 (+0000) Subject: made bufconfig ioctl always write back buffer sizes even if they were not changed X-Git-Tag: r0_7_57~31 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=db8d1fb0973971c091c33786771b13ee53bb986b;p=comedi.git made bufconfig ioctl always write back buffer sizes even if they were not changed --- diff --git a/comedi/comedi_fops.c b/comedi/comedi_fops.c index f7ca89f8..082d3ba7 100644 --- a/comedi/comedi_fops.c +++ b/comedi/comedi_fops.c @@ -171,15 +171,18 @@ static int do_bufconfig_ioctl(comedi_device *dev,void *arg) if(copy_from_user(&bc,arg,sizeof(comedi_bufconfig))) return -EFAULT; + if(dev->read_subdev >= 0) + rsd = &dev->subdevices[dev->read_subdev]; + if(dev->write_subdev >= 0) + wsd = &dev->subdevices[dev->write_subdev]; + if(bc.read_size){ - if(dev->read_subdev < 0) + if(rsd == NULL) { DPRINTK("device has no read subdevice, buffer resize failed\n"); return -ENODEV; } - rsd = &dev->subdevices[dev->read_subdev]; - if(rsd->busy) return -EBUSY; @@ -192,14 +195,12 @@ static int do_bufconfig_ioctl(comedi_device *dev,void *arg) return -EINVAL; } if(bc.write_size){ - if(dev->write_subdev < 0) + if(wsd == NULL) { DPRINTK("device has no write subdevice, buffer resize failed\n"); return -ENODEV; } - wsd = &dev->subdevices[dev->write_subdev]; - if(wsd->busy) return -EBUSY; @@ -219,8 +220,7 @@ static int do_bufconfig_ioctl(comedi_device *dev,void *arg) if(ret < 0) return ret; - bc.read_size = rsd->prealloc_bufsz; - DPRINTK("comedi%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, rsd->prealloc_bufsz); } if(bc.write_size){ ret = resize_buf(dev,wsd,bc.write_size); @@ -228,10 +228,17 @@ static int do_bufconfig_ioctl(comedi_device *dev,void *arg) if(ret < 0) return ret; - bc.write_size = wsd->prealloc_bufsz; - DPRINTK("comedi%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, wsd->prealloc_bufsz); } + // write back buffer sizes + if(rsd){ + bc.read_size = rsd->prealloc_bufsz; + } else bc.read_size = 0; + if(wsd){ + bc.write_size = wsd->prealloc_bufsz; + } else bc.write_size = 0; + if(copy_to_user(arg,&bc,sizeof(comedi_bufconfig))) return -EFAULT;