Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932241AbcLHNxa (ORCPT ); Thu, 8 Dec 2016 08:53:30 -0500 Received: from smtp65.iad3a.emailsrvr.com ([173.203.187.65]:33197 "EHLO smtp65.iad3a.emailsrvr.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751550AbcLHNx3 (ORCPT ); Thu, 8 Dec 2016 08:53:29 -0500 X-Auth-ID: abbotti@mev.co.uk X-Sender-Id: abbotti@mev.co.uk From: Ian Abbott To: devel@driverdev.osuosl.org Cc: Greg Kroah-Hartman , Ian Abbott , H Hartley Sweeten , linux-kernel@vger.kernel.org Subject: [PATCH] staging: comedi: comedidev.h: Document usage of 'detach' handler Date: Thu, 8 Dec 2016 13:53:10 +0000 Message-Id: <20161208135310.16295-1-abbotti@mev.co.uk> X-Mailer: git-send-email 2.10.2 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- drivers/staging/comedi/comedidev.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h index dcb6376..0c7c37a 100644 --- a/drivers/staging/comedi/comedidev.h +++ b/drivers/staging/comedi/comedidev.h @@ -426,6 +426,18 @@ enum comedi_cb { * handler will be called with the COMEDI device structure's board_ptr member * pointing to the matched pointer to a board name within the driver's private * array of static, read-only board type information. + * + * The @detach handler has two roles. If a COMEDI device was successfully + * configured by the @attach or @auto_attach handler, it is called when the + * device is being deconfigured (by the %COMEDI_DEVCONFIG ioctl, or due to + * unloading of the driver, or due to device removal). It is also called when + * the @attach or @auto_attach handler returns an error. Therefore, the + * @attach or @auto_attach handlers can defer clean-up on error until the + * @detach handler is called. If the @attach or @auto_attach handlers free + * any resources themselves, they must prevent the @detach handler from + * freeing the same resources. The @detach handler must not assume that all + * resources requested by the @attach or @auto_attach handler were + * successfully allocated. */ struct comedi_driver { /* private: */ -- 2.10.2