From 54db996e6dab51571718e8e97c26fdc695e254ac Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 24 Jun 2013 16:55:14 -0700 Subject: [PATCH] staging: comedi: drivers: introduce comedi_alloc_devpriv() Introduce a helper function to allocate memory and set the comedi_device private data pointer. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedidev.h | 1 + drivers/staging/comedi/drivers.c | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h index b75915f30f48..bfbe4160edf0 100644 --- a/drivers/staging/comedi/comedidev.h +++ b/drivers/staging/comedi/comedidev.h @@ -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 *, diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c index e25eba5713c1..87df7960c96f 100644 --- a/drivers/staging/comedi/drivers.c +++ b/drivers/staging/comedi/drivers.c @@ -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; -- 2.20.1