[PATCH] staging: comedi: introduce, and use, comedi_spriv_free()

Ian Abbott abbotti at mev.co.uk
Tue Apr 16 10:41:38 UTC 2013


On 2013-04-16 00:41, H Hartley Sweeten wrote:
> The comedi_subdevice 'private' variable is a void * that is available
> for the subdevice to use in manner. It's common in comedi drivers for
> the driver to allocate memory for a subdevice and store the pointer
> to that memory in the 'private' variable. It's then the responsibility
> of the driver to free that memory when the device is detached.
>
> Due to how the attach/detach works in comedi, the drivers need to do
> some sanity checking before they can free the allocated memory during
> the detach.
>
> Introduce a helper function, comedi_spriv_free(), to handle freeing
> the private data allocated for a subdevice. This allows moving all the
> sanity checks into the helper function and makes it safe to call
> with any context. It also allows removing some of the boilerplate
> code in the (*detach) functions.
>
> Remove the subdev_8255_cleanup() export in the 8255 subdevice driver
> as well as the addi_watchdog_cleanup() export in the addi_watchdog
> driver and use the new helper instead.
>
> The amplc_dio200_common driver uses a number of local helper functions
> to free the private data for it's subdevices. Remove those as well and
> use the new helper.
>
> Signed-off-by: H Hartley Sweeten <hsweeten at visionengravers.com>
> Cc: Ian Abbott <abbotti at mev.co.uk>
> Cc: Greg Kroah-Hartman <gregkh at linuxfoundation.org>

Reviewed-by: Ian Abbott <abbotti at mev.co.uk>

-- 
-=( Ian Abbott @ MEV Ltd.    E-mail: <abbotti at mev.co.uk>        )=-
-=( Tel: +44 (0)161 477 1898   FAX: +44 (0)161 718 3587         )=-



More information about the devel mailing list