]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
staging: comedi: drivers: introduce comedi_alloc_devpriv()
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Mon, 24 Jun 2013 23:55:14 +0000 (16:55 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 23 Jul 2013 21:04:59 +0000 (14:04 -0700)
Introduce a helper function to allocate memory and set the
comedi_device private data pointer.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/comedidev.h
drivers/staging/comedi/drivers.c

index b75915f30f48492c99060bb23a805cc6721fe0b3..bfbe4160edf0766ec7a86dac0da0ec9f7f250598 100644 (file)
@@ -357,6 +357,7 @@ void comedi_buf_memcpy_from(struct comedi_async *async, unsigned int offset,
 
 /* drivers.c - general comedi driver functions */
 
+void *comedi_alloc_devpriv(struct comedi_device *, size_t);
 int comedi_alloc_subdevices(struct comedi_device *, int);
 
 int comedi_load_firmware(struct comedi_device *, struct device *,
index e25eba5713c153a9fd2e829561eb481b26a8dc47..87df7960c96fde443fbad96735c7f9d2494200ca 100644 (file)
@@ -57,6 +57,18 @@ static void comedi_clear_hw_dev(struct comedi_device *dev)
        dev->hw_dev = NULL;
 }
 
+/**
+ * comedi_alloc_devpriv() - Allocate memory for the device private data.
+ * @dev: comedi_device struct
+ * @size: size of the memory to allocate
+ */
+void *comedi_alloc_devpriv(struct comedi_device *dev, size_t size)
+{
+       dev->private = kzalloc(size, GFP_KERNEL);
+       return dev->private;
+}
+EXPORT_SYMBOL_GPL(comedi_alloc_devpriv);
+
 int comedi_alloc_subdevices(struct comedi_device *dev, int num_subdevices)
 {
        struct comedi_subdevice *s;