Detangle use of board_xyzclassobject() and board_xyzuninitialize()

This commit is contained in:
Gregory Nutt 2017-07-14 06:59:45 -06:00
parent 1674cb8c8e
commit 23cbc28b05
6 changed files with 121 additions and 111 deletions

View File

@ -40,12 +40,126 @@
#include <nuttx/config.h>
#include <sys/types.h>
#include <nuttx/usb/usbdev.h>
#include <nuttx/usb/cdcacm.h>
#include <nuttx/usb/usbmsc.h>
#include <nuttx/usb/composite.h>
#include "samv71-xult.h"
#if defined(CONFIG_BOARDCTL_USBDEVCTRL) && defined(CONFIG_USBDEV_COMPOSITE)
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: board_cdcclassobject
*
* Description:
* If the CDC serial class driver is part of composite device, then
* board-specific logic must provide board_cdcclassobject(). In the
* simplest case, board_cdcclassobject() is simply a wrapper around
* cdcacm_classobject() that provides the correct device minor number.
*
* Input Parameters:
* classdev - The location to return the CDC serial class' device
* instance.
*
* Returned Value:
* 0 on success; a negated errno on failure
*
****************************************************************************/
static int board_cdcclassobject(int minor,
FAR struct usbdev_description_s *devdesc,
FAR struct usbdevclass_driver_s **classdev)
{
return cdcacm_classobject(0, devdesc, classdev);
}
/****************************************************************************
* Name: board_cdcuninitialize
*
* Description:
* Un-initialize the USB serial class driver. This is just an application-
* specific wrapper around cdcadm_unitialize() that is called form the
* composite device logic.
*
* Input Parameters:
* classdev - The class driver instance previously given to the composite
* driver by board_cdcclassobject().
*
* Returned Value:
* None
*
****************************************************************************/
static void board_cdcuninitialize(FAR struct usbdevclass_driver_s *classdev)
{
cdcacm_initialize(classdev);
}
/************************************************************************************
* Name: board_mscclassobject
*
* Description:
* If the mass storage class driver is part of composite device, then
* its instantiation and configuration is a multi-step, board-specific,
* process (See comments for usbmsc_configure below). In this case,
* board-specific logic must provide board_mscclassobject().
*
* board_mscclassobject() is called from the composite driver. It must
* encapsulate the instantiation and configuration of the mass storage
* class and the return the mass storage device's class driver instance
* to the composite dirver.
*
* Input Parameters:
* classdev - The location to return the mass storage class' device
* instance.
*
* Returned Value:
* 0 on success; a negated errno on failure
*
************************************************************************************/
static int board_mscclassobject(int minor, FAR struct usbdev_description_s *devdesc,
FAR struct usbdevclass_driver_s **classdev)
{
FAR void *handle;
int ret;
ret = usbmsc_configure(1, &handle);
if (ret >= 0)
{
retr = usbmsc_classobject(handle, devdesc, classdev);
}
return ret;
}
/************************************************************************************
* Name: board_mscuninitialize
*
* Description:
* Un-initialize the USB storage class driver. This is just an application-
* specific wrapper aboutn usbmsc_unitialize() that is called form the composite
* device logic.
*
* Input Parameters:
* classdev - The class driver instrance previously give to the composite
* driver by board_mscclassobject().
*
* Returned Value:
* None
*
************************************************************************************/
void board_mscuninitialize(FAR struct usbdevclass_driver_s *classdev)
{
usbmsc_uninitialize(classdev);
}
/****************************************************************************
* Public Functions
****************************************************************************/

View File

@ -2502,8 +2502,7 @@ int cdcacm_initialize(int minor, FAR void **handle)
* CDC/ACM driver is an internal part of a composite device, or a standalone
* USB driver:
*
* classdev - The class object returned by board_cdcclassobject() or
* cdcacm_classobject()
* classdev - The class object returned by cdcacm_classobject()
* handle - The opaque handle representing the class object returned by
* a previous call to cdcacm_initialize().
*

View File

@ -783,8 +783,7 @@ static void composite_resume(FAR struct usbdevclass_driver_s *driver,
* Description:
* Register USB composite device as configured. This function will call
* board-specific implementations in order to obtain the class objects for
* each of the members of the composite (see board_mscclassobject(),
* board_cdcclassobjec(), ...)
* each of the members of the composite.
*
* Input Parameter:
* None
@ -887,8 +886,7 @@ errout_with_alloc:
* Un-initialize the USB composite driver. The handle is the USB composite
* class' device object as was returned by composite_initialize(). This
* function will call board-specific implementations in order to free the
* class objects for each of the members of the composite (see
* board_mscuninitialize(), board_cdcuninitialize(), ...)
* class objects for each of the members of the composite.
*
* Input Parameters:
* handle - The handle returned by a previous call to composite_initialize().

View File

@ -329,53 +329,6 @@ typedef FAR void (*cdcacm_callback_t)(enum cdcacm_event_e event);
* Public Function Prototypes
****************************************************************************/
/****************************************************************************
* Name: board_cdcclassobject
*
* Description:
* If the CDC serial class driver is part of composite device, then
* board-specific logic must provide board_cdcclassobject(). In the
* simplest case, board_cdcclassobject() is simply a wrapper around
* cdcacm_classobject() that provides the correct device minor number.
*
* Input Parameters:
* classdev - The location to return the CDC serial class' device
* instance.
*
* Returned Value:
* 0 on success; a negated errno on failure
*
****************************************************************************/
#if defined(CONFIG_USBDEV_COMPOSITE) && defined(CONFIG_CDCACM_COMPOSITE)
struct usbdevclass_driver_s;
struct usbdev_description_s;
int board_cdcclassobject(int minor, FAR struct usbdev_description_s *devdesc,
FAR struct usbdevclass_driver_s **classdev);
#endif
/****************************************************************************
* Name: board_cdcuninitialize
*
* Description:
* Un-initialize the USB serial class driver. This is just an application-
* specific wrapper around cdcadm_unitialize() that is called form the
* composite device logic.
*
* Input Parameters:
* classdev - The class driver instance previously give to the composite
* driver by board_cdcclassobject().
*
* Returned Value:
* None
*
****************************************************************************/
#if defined(CONFIG_USBDEV_COMPOSITE) && defined(CONFIG_CDCACM_COMPOSITE)
struct usbdevclass_driver_s;
void board_cdcuninitialize(FAR struct usbdevclass_driver_s *classdev);
#endif
/****************************************************************************
* Name: cdcacm_classobject
*
@ -436,8 +389,7 @@ int cdcacm_initialize(int minor, FAR void **handle);
* CDC/ACM driver is an internal part of a composite device, or a
* standalone USB driver:
*
* classdev - The class object returned by board_cdcclassobject() or
* cdcacm_classobject()
* classdev - The class object returned by cdcacm_classobject()
* handle - The opaque handle representing the class object returned by
* a previous call to cdcacm_initialize().
*

View File

@ -104,8 +104,7 @@ extern "C"
* Description:
* Register USB composite device as configured. This function will call
* board-specific implementations in order to obtain the class objects for
* each of the members of the composite (see board_mscclassobject(),
* board_cdcclassobjec(), ...)
* each of the members of the composite.
*
* Input Parameter:
* None
@ -130,8 +129,7 @@ FAR void *composite_initialize(uint8_t ndevices,
* Un-initialize the USB composite driver. The handle is the USB composite
* class' device object as was returned by composite_initialize(). This
* function will call board-specific implementations in order to free the
* class objects for each of the members of the composite (see
* board_mscuninitialize(), board_cdcuninitialize(), ...)
* class objects for each of the members of the composite.
*
* Input Parameters:
* handle - The handle returned by a previous call to composite_initialize().

View File

@ -88,57 +88,6 @@ extern "C"
* Public Functions
************************************************************************************/
/************************************************************************************
* Name: board_mscclassobject
*
* Description:
* If the mass storage class driver is part of composite device, then
* its instantiation and configuration is a multi-step, board-specific,
* process (See comments for usbmsc_configure below). In this case,
* board-specific logic must provide board_mscclassobject().
*
* board_mscclassobject() is called from the composite driver. It must
* encapsulate the instantiation and configuration of the mass storage
* class and the return the mass storage device's class driver instance
* to the composite dirver.
*
* Input Parameters:
* classdev - The location to return the mass storage class' device
* instance.
*
* Returned Value:
* 0 on success; a negated errno on failure
*
************************************************************************************/
#if defined(CONFIG_USBDEV_COMPOSITE) && defined(CONFIG_USBMSC_COMPOSITE)
struct usbdevclass_driver_s;
int board_mscclassobject(int minor, FAR struct usbdev_description_s *devdesc,
FAR struct usbdevclass_driver_s **classdev);
#endif
/************************************************************************************
* Name: board_mscuninitialize
*
* Description:
* Un-initialize the USB storage class driver. This is just an application-
* specific wrapper aboutn usbmsc_unitialize() that is called form the composite
* device logic.
*
* Input Parameters:
* classdev - The class driver instrance previously give to the composite
* driver by board_mscclassobject().
*
* Returned Value:
* None
*
************************************************************************************/
#if defined(CONFIG_USBDEV_COMPOSITE) && defined(CONFIG_USBMSC_COMPOSITE)
struct usbdevclass_driver_s;
void board_mscuninitialize(FAR struct usbdevclass_driver_s *classdev);
#endif
/************************************************************************************
* Name: usbmsc_configure
*
@ -157,7 +106,7 @@ void board_mscuninitialize(FAR struct usbdevclass_driver_s *classdev);
*
* Returned Value:
* 0 on success; a negated errno on failure. The returned handle value is
* an untyped equivalent to the usbmsc_classobject() or board_mscclassobject().
* an untyped equivalent to the usbmsc_classobject().
*
************************************************************************************/