From 23cbc28b053f1a237a47766cd5f5a282da80dda5 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 14 Jul 2017 06:59:45 -0600 Subject: [PATCH] Detangle use of board_xyzclassobject() and board_xyzuninitialize() --- configs/samv71-xult/src/sam_composite.c | 114 ++++++++++++++++++++++++ drivers/usbdev/cdcacm.c | 3 +- drivers/usbdev/composite.c | 6 +- include/nuttx/usb/cdcacm.h | 50 +---------- include/nuttx/usb/composite.h | 6 +- include/nuttx/usb/usbmsc.h | 53 +---------- 6 files changed, 121 insertions(+), 111 deletions(-) diff --git a/configs/samv71-xult/src/sam_composite.c b/configs/samv71-xult/src/sam_composite.c index 986a18f3bb..7ed02e7efc 100644 --- a/configs/samv71-xult/src/sam_composite.c +++ b/configs/samv71-xult/src/sam_composite.c @@ -40,12 +40,126 @@ #include #include +#include +#include +#include #include #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 ****************************************************************************/ diff --git a/drivers/usbdev/cdcacm.c b/drivers/usbdev/cdcacm.c index 3d8a5dc10d..a5e85a347b 100644 --- a/drivers/usbdev/cdcacm.c +++ b/drivers/usbdev/cdcacm.c @@ -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(). * diff --git a/drivers/usbdev/composite.c b/drivers/usbdev/composite.c index 6448d31d93..ba926697fc 100644 --- a/drivers/usbdev/composite.c +++ b/drivers/usbdev/composite.c @@ -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(). diff --git a/include/nuttx/usb/cdcacm.h b/include/nuttx/usb/cdcacm.h index f734d654b2..13d4917950 100644 --- a/include/nuttx/usb/cdcacm.h +++ b/include/nuttx/usb/cdcacm.h @@ -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(). * diff --git a/include/nuttx/usb/composite.h b/include/nuttx/usb/composite.h index fa273e50bd..be728423cb 100644 --- a/include/nuttx/usb/composite.h +++ b/include/nuttx/usb/composite.h @@ -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(). diff --git a/include/nuttx/usb/usbmsc.h b/include/nuttx/usb/usbmsc.h index bf248e9538..c06c55a6b9 100644 --- a/include/nuttx/usb/usbmsc.h +++ b/include/nuttx/usb/usbmsc.h @@ -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(). * ************************************************************************************/