diff options
author | Gregory Nutt <gnutt@nuttx.org> | 2014-03-25 12:42:01 -0600 |
---|---|---|
committer | Gregory Nutt <gnutt@nuttx.org> | 2014-03-25 12:42:01 -0600 |
commit | 4a5c2a0d7b62efab98f8b0f477e9f76bb30d7bdf (patch) | |
tree | f0387173868f1f644766767d1a034f42edc1d5e8 | |
parent | 3ff3472d485e8c0e69845269e8b49151aa0abb4b (diff) | |
download | px4-nuttx-4a5c2a0d7b62efab98f8b0f477e9f76bb30d7bdf.tar.gz px4-nuttx-4a5c2a0d7b62efab98f8b0f477e9f76bb30d7bdf.tar.bz2 px4-nuttx-4a5c2a0d7b62efab98f8b0f477e9f76bb30d7bdf.zip |
apps/system/usbmsc: Back out kludge that is no longer needed with the recent fix to the USB MSC class
-rw-r--r-- | apps/ChangeLog.txt | 2 | ||||
-rw-r--r-- | apps/system/usbmsc/Kconfig | 18 | ||||
-rw-r--r-- | apps/system/usbmsc/usbmsc.h | 6 | ||||
-rw-r--r-- | apps/system/usbmsc/usbmsc_main.c | 126 | ||||
-rw-r--r-- | nuttx/configs/pic32mx7mmb/nsh/defconfig | 2 | ||||
-rw-r--r-- | nuttx/configs/sama5d3x-ek/demo/defconfig | 2 | ||||
-rw-r--r-- | nuttx/configs/stm3210e-eval/nsh2/defconfig | 2 |
7 files changed, 30 insertions, 128 deletions
diff --git a/apps/ChangeLog.txt b/apps/ChangeLog.txt index 328919363..dbc2e79aa 100644 --- a/apps/ChangeLog.txt +++ b/apps/ChangeLog.txt @@ -866,3 +866,5 @@ * apps/examples/igmp: Fill out Kconfig file; update makefile so that the IGMP example can be used as an NSH built-in application. From Manuel Stühn (2014-3-24). + * apps/system/usbmsc: Back out the USBMSC daemon... it is no longer + needed with the recent fix to the USBMSC class driver (2014-3-25). diff --git a/apps/system/usbmsc/Kconfig b/apps/system/usbmsc/Kconfig index 7be540e33..75dcda981 100644 --- a/apps/system/usbmsc/Kconfig +++ b/apps/system/usbmsc/Kconfig @@ -148,24 +148,6 @@ config SYSTEM_USBMSC_CMD_PRIORITY ---help--- Priority of the small 'msconn' and 'msdis' command applications. -config SYSTEM_USBMSC_DAEMON_STACKSIZE - int "Stacksize of msconn daemon" - default 2048 - ---help--- - To avoid threading entanglements, the USB MSC class is initialized - on a daemon thread. This permits the msconn application to return - to the NSH command line immediately. This is the stack used for - that short-lived USB MSC initialization daemon. - -config SYSTEM_USBMSC_DAEMON_PRIORITY - int "Priority of the msconn daemon" - default 100 - ---help--- - To avoid threading entanglements, the USB MSC class is initialized - on a daemon thread. This permits the msconn application to return - to the NSH command line immediately. This is the priority used for - that short-lived USB MSC initialization daemon. - endif # NSH_BUILTIN_APPS endif # SYSTEM_USBMSC diff --git a/apps/system/usbmsc/usbmsc.h b/apps/system/usbmsc/usbmsc.h index 1a0afb9a2..c54803ee2 100644 --- a/apps/system/usbmsc/usbmsc.h +++ b/apps/system/usbmsc/usbmsc.h @@ -89,12 +89,6 @@ # undef CONFIG_SYSTEM_USBMSC_DEVPATH3 #endif -#if defined(CONFIG_NSH_BUILTIN_APPS) && defined(CONFIG_SCHED_WAITPID) -# ifndef CONFIG_SYSTEM_USBMSC_DAEMON_STACKSIZE -# define CONFIG_SYSTEM_USBMSC_DAEMON_STACKSIZE 2048 -# endif -#endif - /* Debug ********************************************************************/ #ifdef CONFIG_CPP_HAVE_VARARGS diff --git a/apps/system/usbmsc/usbmsc_main.c b/apps/system/usbmsc/usbmsc_main.c index 2ffcdac43..9dd0fb5ad 100644 --- a/apps/system/usbmsc/usbmsc_main.c +++ b/apps/system/usbmsc/usbmsc_main.c @@ -375,7 +375,11 @@ static int usbmsc_enumerate(struct usbtrace_s *trace, void *arg) #endif /**************************************************************************** - * msconn_daemon + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * msconn_main * * Description: * This is the main program that configures the USB mass storage device @@ -385,13 +389,14 @@ static int usbmsc_enumerate(struct usbtrace_s *trace, void *arg) * ****************************************************************************/ -static int msconn_daemon(int argc, char *argv[]) +int msconn_main(int argc, char *argv[]) { FAR void *handle; int ret; - /* If this program is implemented as the NSH 'msconn' command, then we need to - * do a little error checking to assure that we are not being called re-entrantly. + /* If this program is implemented as the NSH 'msconn' command, then we + * need to do a little error checking to assure that we are not being + * called re-entrantly. */ #ifdef CONFIG_NSH_BUILTIN_APPS @@ -401,7 +406,7 @@ static int msconn_daemon(int argc, char *argv[]) if (g_usbmsc.mshandle) { - message("msconn_daemon: ERROR: Already connected\n"); + message("mcsonn_main: ERROR: Already connected\n"); return EXIT_FAILURE; } #endif @@ -425,11 +430,11 @@ static int msconn_daemon(int argc, char *argv[]) /* Register block drivers (architecture-specific) */ - message("msconn_daemon: Creating block drivers\n"); + message("mcsonn_main: Creating block drivers\n"); ret = usbmsc_archinitialize(); if (ret < 0) { - message("msconn_daemon: usbmsc_archinitialize failed: %d\n", -ret); + message("mcsonn_main: usbmsc_archinitialize failed: %d\n", -ret); return EXIT_FAILURE; } @@ -437,23 +442,23 @@ static int msconn_daemon(int argc, char *argv[]) /* Then exports the LUN(s) */ - message("msconn_daemon: Configuring with NLUNS=%d\n", CONFIG_SYSTEM_USBMSC_NLUNS); + message("mcsonn_main: Configuring with NLUNS=%d\n", CONFIG_SYSTEM_USBMSC_NLUNS); ret = usbmsc_configure(CONFIG_SYSTEM_USBMSC_NLUNS, &handle); if (ret < 0) { - message("msconn_daemon: usbmsc_configure failed: %d\n", -ret); + message("mcsonn_main: usbmsc_configure failed: %d\n", -ret); usbmsc_uninitialize(handle); return EXIT_FAILURE; } - message("msconn_daemon: handle=%p\n", handle); + message("mcsonn_main: handle=%p\n", handle); check_test_memory_usage("After usbmsc_configure()"); - message("msconn_daemon: Bind LUN=0 to %s\n", CONFIG_SYSTEM_USBMSC_DEVPATH1); + message("mcsonn_main: Bind LUN=0 to %s\n", CONFIG_SYSTEM_USBMSC_DEVPATH1); ret = usbmsc_bindlun(handle, CONFIG_SYSTEM_USBMSC_DEVPATH1, 0, 0, 0, false); if (ret < 0) { - message("msconn_daemon: usbmsc_bindlun failed for LUN 1 using %s: %d\n", + message("mcsonn_main: usbmsc_bindlun failed for LUN 1 using %s: %d\n", CONFIG_SYSTEM_USBMSC_DEVPATH1, -ret); usbmsc_uninitialize(handle); return EXIT_FAILURE; @@ -463,11 +468,11 @@ static int msconn_daemon(int argc, char *argv[]) #if CONFIG_SYSTEM_USBMSC_NLUNS > 1 - message("msconn_daemon: Bind LUN=1 to %s\n", CONFIG_SYSTEM_USBMSC_DEVPATH2); + message("mcsonn_main: Bind LUN=1 to %s\n", CONFIG_SYSTEM_USBMSC_DEVPATH2); ret = usbmsc_bindlun(handle, CONFIG_SYSTEM_USBMSC_DEVPATH2, 1, 0, 0, false); if (ret < 0) { - message("msconn_daemon: usbmsc_bindlun failed for LUN 2 using %s: %d\n", + message("mcsonn_main: usbmsc_bindlun failed for LUN 2 using %s: %d\n", CONFIG_SYSTEM_USBMSC_DEVPATH2, -ret); usbmsc_uninitialize(handle); return EXIT_FAILURE; @@ -477,11 +482,11 @@ static int msconn_daemon(int argc, char *argv[]) #if CONFIG_SYSTEM_USBMSC_NLUNS > 2 - message("msconn_daemon: Bind LUN=2 to %s\n", CONFIG_SYSTEM_USBMSC_DEVPATH3); + message("mcsonn_main: Bind LUN=2 to %s\n", CONFIG_SYSTEM_USBMSC_DEVPATH3); ret = usbmsc_bindlun(handle, CONFIG_SYSTEM_USBMSC_DEVPATH3, 2, 0, 0, false); if (ret < 0) { - message("msconn_daemon: usbmsc_bindlun failed for LUN 3 using %s: %d\n", + message("mcsonn_main: usbmsc_bindlun failed for LUN 3 using %s: %d\n", CONFIG_SYSTEM_USBMSC_DEVPATH3, -ret); usbmsc_uninitialize(handle); return EXIT_FAILURE; @@ -495,14 +500,14 @@ static int msconn_daemon(int argc, char *argv[]) ret = usbmsc_exportluns(handle); if (ret < 0) { - message("msconn_daemon: usbmsc_exportluns failed: %d\n", -ret); + message("mcsonn_main: usbmsc_exportluns failed: %d\n", -ret); usbmsc_uninitialize(handle); return EXIT_FAILURE; } check_test_memory_usage("After usbmsc_exportluns()"); - /* It this program was configued as an NSH command, then just exit now. + /* It this program was configured as an NSH command, then just exit now. * Also, if signals are not enabled (and, hence, sleep() is not supported. * then we have not real option but to exit now. */ @@ -517,18 +522,18 @@ static int msconn_daemon(int argc, char *argv[]) sleep(5); # ifdef CONFIG_SYSTEM_USBMSC_TRACE - message("\nmsconn_daemon: USB TRACE DATA:\n"); + message("\nmcsonn_main: USB TRACE DATA:\n"); ret = usbtrace_enumerate(usbmsc_enumerate, NULL); if (ret < 0) { - message("msconn_daemon: usbtrace_enumerate failed: %d\n", -ret); + message("mcsonn_main: usbtrace_enumerate failed: %d\n", -ret); usbmsc_uninitialize(handle); return EXIT_FAILURE; } check_test_memory_usage("After usbtrace_enumerate()"); # else - message("msconn_daemon: Still alive\n"); + message("mcsonn_main: Still alive\n"); # endif } #elif defined(CONFIG_NSH_BUILTIN_APPS) @@ -537,7 +542,7 @@ static int msconn_daemon(int argc, char *argv[]) * command. */ - message("msconn_daemon: Connected\n"); + message("mcsonn_main: Connected\n"); g_usbmsc.mshandle = handle; check_test_memory_usage("After MS connection"); @@ -545,7 +550,7 @@ static int msconn_daemon(int argc, char *argv[]) /* Just exit */ - message("msconn_daemon: Exiting\n"); + message("mcsonn_main: Exiting\n"); /* Dump debug memory usage */ @@ -556,81 +561,6 @@ static int msconn_daemon(int argc, char *argv[]) } /**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * msconn_main - * - * Description: - * This is the main program that configures the USB mass storage device - * and exports the LUN(s). If CONFIG_NSH_BUILTIN_APPS is defined - * in the NuttX configuration, then this program can be executed by - * entering the "msconn" command at the NSH console. - * - ****************************************************************************/ - -int msconn_main(int argc, char *argv[]) -{ - /* If this function is started as a built-in application from the NSH - * command line, then daemonize. Why? Because NSH is probably waiting - * on waitpid() for msconn to complete. But the USB MSC initialization - * logic creates a dedicated worker thread using pthread_create(). As - * consequences, there will be two members of the task group and waitpid() - * will not wake up when msconn returns. It will not wake-up until both - * msconn and the USB MSC work thread terminate. - */ - -#if defined(CONFIG_NSH_BUILTIN_APPS) && defined(CONFIG_SCHED_WAITPID) - char *newargv[1] = { NULL }; - struct sched_param param; - int ret; - - /* Check if there is a non-NULL USB mass storage device handle (meaning - * that the USB mass storage device is already configured). There is - * no handshaking so there is a race condition: We will check again - * when the daemon is started. - * - * REVISIT: This might a good application for vfork(); - */ - - if (g_usbmsc.mshandle) - { - message("msconn_main: ERROR: Already connected\n"); - return 1; - } - -#ifndef CONFIG_SYSTEM_USBMSC_DAEMON_PRIORITY - /* Set the daemon to the same priority as this task */ - - ret = sched_getparam(0, ¶m); - if (ret < 0) - { - message("msconn_main: ERROR: Already connected\n"); - return EXIT_FAILURE; - } -#else - param.sched_priority = CONFIG_SYSTEM_USBMSC_DAEMON_PRIORITY; -#endif - - ret = TASK_CREATE("msconn daemon", param.sched_priority, - CONFIG_SYSTEM_USBMSC_DAEMON_STACKSIZE, - msconn_daemon, newargv); - if (ret < 0) - { - message("msconn_main: ERROR: TASK_CREATE failed: %d\n", ret); - return EXIT_FAILURE; - } - - return EXIT_SUCCESS; -#else - /* Otherwise, there is no need to daemonize */ - - return msconn_daemon(argc, argv); -#endif -} - -/**************************************************************************** * msdis_main * * Description: diff --git a/nuttx/configs/pic32mx7mmb/nsh/defconfig b/nuttx/configs/pic32mx7mmb/nsh/defconfig index b0ad11727..4ccd190d5 100644 --- a/nuttx/configs/pic32mx7mmb/nsh/defconfig +++ b/nuttx/configs/pic32mx7mmb/nsh/defconfig @@ -1051,8 +1051,6 @@ CONFIG_SYSTEM_USBMSC_DEVPATH3="/dev/mmcsd2" # CONFIG_SYSTEM_USBMSC_DEBUGMM is not set CONFIG_SYSTEM_USBMSC_CMD_STACKSIZE=768 CONFIG_SYSTEM_USBMSC_CMD_PRIORITY=100 -CONFIG_SYSTEM_USBMSC_DAEMON_STACKSIZE=2048 -CONFIG_SYSTEM_USBMSC_DAEMON_PRIORITY=100 # # Zmodem Commands diff --git a/nuttx/configs/sama5d3x-ek/demo/defconfig b/nuttx/configs/sama5d3x-ek/demo/defconfig index 8d5bd4223..f7ec7cc44 100644 --- a/nuttx/configs/sama5d3x-ek/demo/defconfig +++ b/nuttx/configs/sama5d3x-ek/demo/defconfig @@ -902,8 +902,6 @@ CONFIG_SYSTEM_USBMSC_DEVPATH3="/dev/mmcsd2" # CONFIG_SYSTEM_USBMSC_DEBUGMM is not set CONFIG_SYSTEM_USBMSC_CMD_STACKSIZE=768 CONFIG_SYSTEM_USBMSC_CMD_PRIORITY=100 -CONFIG_SYSTEM_USBMSC_DAEMON_STACKSIZE=2048 -CONFIG_SYSTEM_USBMSC_DAEMON_PRIORITY=100 # # Zmodem Commands diff --git a/nuttx/configs/stm3210e-eval/nsh2/defconfig b/nuttx/configs/stm3210e-eval/nsh2/defconfig index ddf893abf..6171b78b8 100644 --- a/nuttx/configs/stm3210e-eval/nsh2/defconfig +++ b/nuttx/configs/stm3210e-eval/nsh2/defconfig @@ -1158,8 +1158,6 @@ CONFIG_SYSTEM_USBMSC_DEVPATH3="/dev/mmcsd2" # CONFIG_SYSTEM_USBMSC_DEBUGMM is not set CONFIG_SYSTEM_USBMSC_CMD_STACKSIZE=768 CONFIG_SYSTEM_USBMSC_CMD_PRIORITY=100 -CONFIG_SYSTEM_USBMSC_DAEMON_STACKSIZE=2048 -CONFIG_SYSTEM_USBMSC_DAEMON_PRIORITY=100 # # Zmodem Commands |