Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

staging: comedi: comedidev.h: Document usage of 'detach' handler

Document when the "detach" handler function pointed to by the `detach`
member of a `struct comedi_driver` is called by the comedi core, and how
the "attach" and "auto_attach" handlers can defer clean-up to it when
they return an error to the comedi core. This is already mentioned as
part of the documentation for `comedi_auto_config()`, but is useful to
document it for `struct comedi_driver` as well, since
`comedi_auto_config()` is not usually called directly by low-level
comedi drivers, and it is not called at all for "legacy" comedi devices
that are configured manually.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Ian Abbott and committed by
Greg Kroah-Hartman
3e0f9b2c 3c87f653

+12
+12
drivers/staging/comedi/comedidev.h
··· 426 426 * handler will be called with the COMEDI device structure's board_ptr member 427 427 * pointing to the matched pointer to a board name within the driver's private 428 428 * array of static, read-only board type information. 429 + * 430 + * The @detach handler has two roles. If a COMEDI device was successfully 431 + * configured by the @attach or @auto_attach handler, it is called when the 432 + * device is being deconfigured (by the %COMEDI_DEVCONFIG ioctl, or due to 433 + * unloading of the driver, or due to device removal). It is also called when 434 + * the @attach or @auto_attach handler returns an error. Therefore, the 435 + * @attach or @auto_attach handlers can defer clean-up on error until the 436 + * @detach handler is called. If the @attach or @auto_attach handlers free 437 + * any resources themselves, they must prevent the @detach handler from 438 + * freeing the same resources. The @detach handler must not assume that all 439 + * resources requested by the @attach or @auto_attach handler were 440 + * successfully allocated. 429 441 */ 430 442 struct comedi_driver { 431 443 /* private: */