apps/system/usbmsc: Back out kludge that is no longer needed with the recent fix to the USB MSC class
This commit is contained in:
parent
2fa8fdd94c
commit
7d9ca9f29b
@ -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).
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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 */
|
||||
|
||||
@ -555,81 +560,6 @@ static int msconn_daemon(int argc, char *argv[])
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* 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
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user