X-Git-Url: https://git.karo-electronics.de/?a=blobdiff_plain;f=drivers%2Fstaging%2Fcomedi%2Fcomedi_fops.c;h=8647518259f6dd5ab3379babc218d5ef6cf24831;hb=f4b96f5e4ff8d86699c851c10245e102809b0331;hp=924c54c9c31fad595d1cdf9331db17d8c40413f4;hpb=78750f1908869c3bfcbf2a1f1f00f078f2948271;p=karo-tx-linux.git diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index 924c54c9c31f..8647518259f6 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -14,11 +14,6 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ #undef DEBUG @@ -536,6 +531,23 @@ static bool comedi_is_subdevice_idle(struct comedi_subdevice *s) return (runflags & (SRF_ERROR | SRF_RUNNING)) ? false : true; } +/** + * comedi_alloc_spriv() - Allocate memory for the subdevice private data. + * @s: comedi_subdevice struct + * @size: size of the memory to allocate + * + * This also sets the subdevice runflags to allow the core to automatically + * free the private data during the detach. + */ +void *comedi_alloc_spriv(struct comedi_subdevice *s, size_t size) +{ + s->private = kzalloc(size, GFP_KERNEL); + if (s->private) + comedi_set_subdevice_runflags(s, ~0, SRF_FREE_SPRIV); + return s->private; +} +EXPORT_SYMBOL_GPL(comedi_alloc_spriv); + /* This function restores a subdevice to an idle state. */ @@ -665,7 +677,7 @@ static int do_bufconfig_ioctl(struct comedi_device *dev, if (copy_from_user(&bc, arg, sizeof(bc))) return -EFAULT; - if (bc.subdevice >= dev->n_subdevices || bc.subdevice < 0) + if (bc.subdevice >= dev->n_subdevices) return -EINVAL; s = &dev->subdevices[bc.subdevice]; @@ -918,7 +930,7 @@ static int do_bufinfo_ioctl(struct comedi_device *dev, if (copy_from_user(&bi, arg, sizeof(bi))) return -EFAULT; - if (bi.subdevice >= dev->n_subdevices || bi.subdevice < 0) + if (bi.subdevice >= dev->n_subdevices) return -EINVAL; s = &dev->subdevices[bi.subdevice]; @@ -2317,9 +2329,6 @@ static int comedi_close(struct inode *inode, struct file *file) mutex_unlock(&dev->mutex); - if (file->f_flags & FASYNC) - comedi_fasync(-1, file, 0); - return 0; }