Replace all calls to the OS internal usbdev_serialinitialize with proper calls to boardctl()
This commit is contained in:
parent
843d2b90e6
commit
6951366eca
@ -197,10 +197,8 @@ int main(int argc, FAR char *argv[])
|
||||
int usbserial_main(int argc, char *argv[])
|
||||
#endif
|
||||
{
|
||||
#ifdef CONFIG_CDCACM
|
||||
struct boardioc_usbdev_ctrl_s ctrl;
|
||||
FAR void *handle;
|
||||
#endif
|
||||
#ifndef CONFIG_EXAMPLES_USBSERIAL_INONLY
|
||||
int infd;
|
||||
#endif
|
||||
@ -227,15 +225,16 @@ int usbserial_main(int argc, char *argv[])
|
||||
ctrl.instance = 0;
|
||||
ctrl.handle = &handle;
|
||||
|
||||
ret = boardctl(BOARDIOC_USBDEV_CONTROL, (uintptr_t)&ctrl);
|
||||
|
||||
#else
|
||||
# warning REVISIT: This violates the OS/application interface
|
||||
|
||||
ret = usbdev_serialinitialize(0);
|
||||
ctrl.usbdev = BOARDIOC_USBDEV_PL2303;
|
||||
ctrl.action = BOARDIOC_USBDEV_CONNECT;
|
||||
ctrl.instance = 0;
|
||||
ctrl.handle = &handle;
|
||||
|
||||
#endif
|
||||
|
||||
ret = boardctl(BOARDIOC_USBDEV_CONTROL, (uintptr_t)&ctrl);
|
||||
if (ret < 0)
|
||||
{
|
||||
printf("usbserial_main: ERROR: Failed to create the USB serial device: %d\n",
|
||||
|
@ -183,10 +183,8 @@ int main(int argc, FAR char *argv[])
|
||||
int usbterm_main(int argc, char *argv[])
|
||||
#endif
|
||||
{
|
||||
#ifdef CONFIG_CDCACM
|
||||
struct boardioc_usbdev_ctrl_s ctrl;
|
||||
FAR void *handle;
|
||||
#endif
|
||||
pthread_attr_t attr;
|
||||
int ret;
|
||||
|
||||
@ -219,20 +217,22 @@ int usbterm_main(int argc, char *argv[])
|
||||
ctrl.instance = 0;
|
||||
ctrl.handle = &handle;
|
||||
|
||||
ret = boardctl(BOARDIOC_USBDEV_CONTROL, (uintptr_t)&ctrl);
|
||||
|
||||
#else
|
||||
# warning REVISIT: This violates the OS/application interface
|
||||
|
||||
ret = usbdev_serialinitialize(0);
|
||||
ctrl.usbdev = BOARDIOC_USBDEV_PL2303;
|
||||
ctrl.action = BOARDIOC_USBDEV_CONNECT;
|
||||
ctrl.instance = 0;
|
||||
ctrl.handle = &handle;
|
||||
|
||||
#endif
|
||||
|
||||
ret = boardctl(BOARDIOC_USBDEV_CONTROL, (uintptr_t)&ctrl);
|
||||
if (ret < 0)
|
||||
{
|
||||
printf("usbterm_main: ERROR: Failed to create the USB serial device: %d\n", -ret);
|
||||
goto errout_with_devinit;
|
||||
}
|
||||
|
||||
printf("usbterm_main: Successfully registered the serial driver\n");
|
||||
|
||||
#if defined(CONFIG_USBDEV_TRACE) && CONFIG_USBDEV_TRACE_INITIALIDSET != 0
|
||||
|
@ -269,10 +269,8 @@ restart:
|
||||
int nsh_consolemain(int argc, char *argv[])
|
||||
{
|
||||
FAR struct console_stdio_s *pstate = nsh_newconsole();
|
||||
#ifdef CONFIG_CDCACM
|
||||
struct boardioc_usbdev_ctrl_s ctrl;
|
||||
FAR void *handle;
|
||||
#endif
|
||||
int ret;
|
||||
|
||||
DEBUGASSERT(pstate);
|
||||
@ -290,18 +288,19 @@ int nsh_consolemain(int argc, char *argv[])
|
||||
|
||||
ctrl.usbdev = BOARDIOC_USBDEV_CDCACM;
|
||||
ctrl.action = BOARDIOC_USBDEV_CONNECT;
|
||||
ctrl.instance = 0;
|
||||
ctrl.instance = CONFIG_NSH_USBDEV_MINOR;
|
||||
ctrl.handle = &handle;
|
||||
|
||||
ret = boardctl(BOARDIOC_USBDEV_CONTROL, (uintptr_t)&ctrl);
|
||||
|
||||
#else
|
||||
# warning REVISIT: This violates the OS/application interface
|
||||
|
||||
ret = usbdev_serialinitialize(CONFIG_NSH_USBDEV_MINOR);
|
||||
ctrl.usbdev = BOARDIOC_USBDEV_PL2303;
|
||||
ctrl.action = BOARDIOC_USBDEV_CONNECT;
|
||||
ctrl.instance = CONFIG_NSH_USBDEV_MINOR;
|
||||
ctrl.handle = &handle;
|
||||
|
||||
#endif
|
||||
|
||||
ret = boardctl(BOARDIOC_USBDEV_CONTROL, (uintptr_t)&ctrl);
|
||||
UNUSED(ret); /* Eliminate warning if not used */
|
||||
DEBUGASSERT(ret == OK);
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user