]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - drivers/staging/comedi/comedi_fops.c
Merge tag 'omap-for-v3.11/fixes-for-merge-window' of git://git.kernel.org/pub/scm...
[karo-tx-linux.git] / drivers / staging / comedi / comedi_fops.c
index 924c54c9c31fad595d1cdf9331db17d8c40413f4..8647518259f6dd5ab3379babc218d5ef6cf24831 100644 (file)
     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;
 }