diff options
author | H Hartley Sweeten <hsweeten@visionengravers.com> | 2013-06-11 11:32:29 -0700 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-06-17 14:31:10 -0700 |
commit | 588ba6dc5fb4bdca47a3da38c2718fbb82d3eee1 (patch) | |
tree | 510ced4246ec45af6c448d51531865dd61a805b5 /drivers/staging/comedi/comedidev.h | |
parent | cadf87a090194dcf607ce6b6de8cc3b84f5898f0 (diff) |
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/comedidev.h')
-rw-r--r-- | drivers/staging/comedi/comedidev.h | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h index 57deabf77418..e8dc7af8f5a1 100644 --- a/drivers/staging/comedi/comedidev.h +++ b/drivers/staging/comedi/comedidev.h @@ -265,10 +265,12 @@ enum subdevice_runflags { /* indicates an COMEDI_CB_ERROR event has occurred since the last * command was started */ SRF_ERROR = 0x00000004, - SRF_RUNNING = 0x08000000 + SRF_RUNNING = 0x08000000, + SRF_FREE_SPRIV = 0x80000000, /* free s->private on detach */ }; bool comedi_is_subdevice_running(struct comedi_subdevice *s); +void comedi_set_spriv(struct comedi_subdevice *s, void *data); int comedi_check_chanlist(struct comedi_subdevice *s, int n, @@ -356,8 +358,6 @@ void comedi_buf_memcpy_from(struct comedi_async *async, unsigned int offset, int comedi_alloc_subdevices(struct comedi_device *, int); -void comedi_spriv_free(struct comedi_device *, int subdev_num); - int comedi_load_firmware(struct comedi_device *, struct device *, const char *name, int (*cb)(struct comedi_device *, |