summaryrefslogtreecommitdiff
path: root/drivers/staging/comedi/drivers.c
diff options
context:
space:
mode:
authorH Hartley Sweeten <hsweeten@visionengravers.com>2013-06-11 18:32:29 (GMT)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-06-17 21:31:10 (GMT)
commit588ba6dc5fb4bdca47a3da38c2718fbb82d3eee1 (patch)
tree510ced4246ec45af6c448d51531865dd61a805b5 /drivers/staging/comedi/drivers.c
parentcadf87a090194dcf607ce6b6de8cc3b84f5898f0 (diff)
downloadlinux-fsl-qoriq-588ba6dc5fb4bdca47a3da38c2718fbb82d3eee1.tar.xz
staging: comedi: drivers: let core handle freeing s->private
Introduce a new subdevice runflags, SRF_FREE_SPRIV, and a new helper function, comedi_set_spriv(), that the drivers can use to set the comedi_subdevice private data pointer. The helper function will also set SRF_FREE_SPRIV to allow the comedi core to automatically free the subdevice private data during the cleanup_device() stage of the detach. Currently s->private is only allocated by the 8255, addi_watchdog, amplc_dio200_common, and ni_65xx drivers. All users of those drivers can then have the comedi_spriv_free() calls removed and in many cases the (*detach) can then simply be the appropriate comedi core provided function. The ni_65xx driver uses a helper function, ni_65xx_alloc_subdevice_private(), to allocate the private data. Refactor the function to return an errno or call comedi_set_spriv() instead of returning a pointer to the private data and requiring the caller to handle it. 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>
Diffstat (limited to 'drivers/staging/comedi/drivers.c')
-rw-r--r--drivers/staging/comedi/drivers.c14
1 files changed, 2 insertions, 12 deletions
diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c
index f3e57fd..e25eba5 100644
--- a/drivers/staging/comedi/drivers.c
+++ b/drivers/staging/comedi/drivers.c
@@ -83,18 +83,6 @@ int comedi_alloc_subdevices(struct comedi_device *dev, int num_subdevices)
}
EXPORT_SYMBOL_GPL(comedi_alloc_subdevices);
-void comedi_spriv_free(struct comedi_device *dev, int subdev_num)
-{
- struct comedi_subdevice *s;
-
- if (dev->subdevices && subdev_num < dev->n_subdevices) {
- s = &dev->subdevices[subdev_num];
- kfree(s->private);
- s->private = NULL;
- }
-}
-EXPORT_SYMBOL_GPL(comedi_spriv_free);
-
static void cleanup_device(struct comedi_device *dev)
{
int i;
@@ -103,6 +91,8 @@ static void cleanup_device(struct comedi_device *dev)
if (dev->subdevices) {
for (i = 0; i < dev->n_subdevices; i++) {
s = &dev->subdevices[i];
+ if (s->runflags & SRF_FREE_SPRIV)
+ kfree(s->private);
comedi_free_subdevice_minor(s);
if (s->async) {
comedi_buf_alloc(dev, s, 0);