diff options
author | H Hartley Sweeten <hsweeten@visionengravers.com> | 2013-06-24 16:23:20 -0700 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-06-24 16:43:40 -0700 |
commit | fbd88336660ef7e85905af17a72e1112d924d41c (patch) | |
tree | e25fb525c16066cbaf3d2b57f899d1c99ececf94 | |
parent | 7f5ac6f4f595b4b17b15ff6701f07377bea8ffd3 (diff) | |
download | linux-fbd88336660ef7e85905af17a72e1112d924d41c.tar.gz linux-fbd88336660ef7e85905af17a72e1112d924d41c.tar.bz2 linux-fbd88336660ef7e85905af17a72e1112d924d41c.zip |
staging: comedi: unioxx5: use comedi_alloc_spriv()
Use the helper function to allocate the memory and set the subdevice
private pointer. This allows the core to automatically free the
memory during the detach so the driver doesn't need to deal with it.
Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/staging/comedi/drivers/unioxx5.c | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/drivers/staging/comedi/drivers/unioxx5.c b/drivers/staging/comedi/drivers/unioxx5.c index fc88b66f408d..c9201d821fbc 100644 --- a/drivers/staging/comedi/drivers/unioxx5.c +++ b/drivers/staging/comedi/drivers/unioxx5.c @@ -371,15 +371,13 @@ static int __unioxx5_subdev_init(struct comedi_device *dev, int i, to, ndef_flag = 0; int ret; - usp = kzalloc(sizeof(*usp), GFP_KERNEL); - if (usp == NULL) + usp = comedi_alloc_spriv(s, sizeof(*usp)); + if (!usp) return -ENOMEM; ret = __comedi_request_region(dev, iobase, UNIOXX5_SIZE); - if (ret) { - kfree(usp); + if (ret) return ret; - } usp->usp_iobase = iobase; /* defining modules types */ @@ -413,7 +411,6 @@ static int __unioxx5_subdev_init(struct comedi_device *dev, /* initial subdevice for digital or analog i/o */ s->type = COMEDI_SUBD_DIO; - s->private = usp; s->subdev_flags = SDF_READABLE | SDF_WRITABLE; s->n_chan = UNIOXX5_NUM_OF_CHANS; s->maxdata = 0xFFF; @@ -483,7 +480,6 @@ static void unioxx5_detach(struct comedi_device *dev) spriv = s->private; if (spriv && spriv->usp_iobase) release_region(spriv->usp_iobase, UNIOXX5_SIZE); - kfree(spriv); } } |