From 8f6700143c5b021a5a1bd3e21a8c20f177e8e9f2 Mon Sep 17 00:00:00 2001 From: patacongo Date: Thu, 26 Jan 2012 23:14:27 +0000 Subject: Add a text for the new composite USB device git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4341 42af7a65-404d-4744-a932-0658087f49c3 --- nuttx/drivers/usbdev/usbmsc.c | 48 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) (limited to 'nuttx/drivers/usbdev/usbmsc.c') diff --git a/nuttx/drivers/usbdev/usbmsc.c b/nuttx/drivers/usbdev/usbmsc.c index a264ab232..0c444c156 100644 --- a/nuttx/drivers/usbdev/usbmsc.c +++ b/nuttx/drivers/usbdev/usbmsc.c @@ -83,7 +83,7 @@ #include "usbmsc.h" #ifdef CONFIG_USBMSC_COMPOSITE -# include +# include # include "composite.h" #endif @@ -139,6 +139,9 @@ static void usbmsc_disconnect(FAR struct usbdevclass_driver_s *driver, /* Initialization/Uninitialization ******************************************/ static void usbmsc_lununinitialize(struct usbmsc_lun_s *lun); +#ifndef CONFIG_USBMSC_COMPOSITE +static int usbmsc_exportluns(FAR void *handle); +#endif /**************************************************************************** * Private Data @@ -1571,6 +1574,9 @@ int usbmsc_unbindlun(FAR void *handle, unsigned int lunno) * ****************************************************************************/ +#ifndef CONFIG_USBMSC_COMPOSITE +static +#endif int usbmsc_exportluns(FAR void *handle) { FAR struct usbmsc_alloc_s *alloc = (FAR struct usbmsc_alloc_s *)handle; @@ -1634,6 +1640,46 @@ errout_with_mutex: return ret; } +/**************************************************************************** + * Name: usbmsc_classobject + * + * Description: + * Register USB mass storage device and return the class object. + * + * Input Parameters: + * classdev - The location to return the CDC serial class' device + * instance. + * + * Returned Value: + * 0 on success; a negated errno on failure + + * + ****************************************************************************/ + +#ifdef CONFIG_USBMSC_COMPOSITE +int usbmsc_classobject(FAR void *handle, + FAR struct usbdevclass_driver_s **classdev) +{ + int ret; + + DEBUGASSERT(handle && classdev); + + /* Export the LUNs as with the "standalone" USB mass storage driver, but + * don't register the class instance with the USB device infrastructure. + */ + + ret = usbmsc_exportluns(handle); + if (ret == OK) + { + /* On sucess, return an (typed) instance of the class instance */ + + *classdev = (FAR struct usbdevclass_driver_s *) + &((FAR struct usbmsc_alloc_s *)handle)->dev; + } + return ret; +} +#endif + /**************************************************************************** * Name: usbmsc_uninitialize * -- cgit v1.2.3