diff --git a/system/composite/Kconfig b/system/composite/Kconfig index 5da58a488..a4f0b6b4c 100644 --- a/system/composite/Kconfig +++ b/system/composite/Kconfig @@ -15,6 +15,15 @@ menuconfig SYSTEM_COMPOSITE disconn: Disconnect the mass storage device to the host if SYSTEM_COMPOSITE + +config SYSTEM_COMPOSITE_DEFCONFIG + int "Default composite configuration" + default 0 + ---help--- + Boards may support multiple composite configurations. If so, then + this is the default configuration that the conn command will use if + no configuration ID is provided on the command line. + if CDCACM_COMPOSITE config SYSTEM_COMPOSITE_SERDEV diff --git a/system/composite/composite_main.c b/system/composite/composite_main.c index a3a55ef2f..e2e97794e 100644 --- a/system/composite/composite_main.c +++ b/system/composite/composite_main.c @@ -518,7 +518,7 @@ int conn_main(int argc, char *argv[]) #endif { struct boardioc_usbdev_ctrl_s ctrl; - int instance = 0; + int config = CONFIG_SYSTEM_COMPOSITE_DEFCONFIG; int ret; /* If this program is implemented as the NSH 'conn' command, then we need to @@ -537,11 +537,11 @@ int conn_main(int argc, char *argv[]) } #endif - /* There is one optional argument.. the interface instance number */ + /* There is one optional argument.. the interface configuration ID */ if (argc == 2) { - instance = atoi(argv[1]); + config = atoi(argv[1]); } else if (argc > 2) { @@ -569,8 +569,8 @@ int conn_main(int argc, char *argv[]) ctrl.usbdev = BOARDIOC_USBDEV_COMPOSITE; ctrl.action = BOARDIOC_USBDEV_INITIALIZE; - ctrl.instance = instance; - ctrl.config = 0; + ctrl.instance = 0; + ctrl.config = config; ctrl.handle = NULL; ret = boardctl(BOARDIOC_USBDEV_CONTROL, (uintptr_t)&ctrl); @@ -586,8 +586,8 @@ int conn_main(int argc, char *argv[]) ctrl.usbdev = BOARDIOC_USBDEV_COMPOSITE; ctrl.action = BOARDIOC_USBDEV_CONNECT; - ctrl.instance = instance; - ctrl.config = 0; + ctrl.instance = 0; + ctrl.config = config; ctrl.handle = &g_composite.cmphandle; ret = boardctl(BOARDIOC_USBDEV_CONTROL, (uintptr_t)&ctrl); @@ -691,8 +691,8 @@ errout: ctrl.usbdev = BOARDIOC_USBDEV_COMPOSITE; ctrl.action = BOARDIOC_USBDEV_DISCONNECT; - ctrl.instance = instance; - ctrl.config = 0; + ctrl.instance = 0; + ctrl.config = config; ctrl.handle = &g_composite.cmphandle; (void)boardctl(BOARDIOC_USBDEV_CONTROL, (uintptr_t)&ctrl); @@ -719,7 +719,7 @@ int disconn_main(int argc, char *argv[]) #endif { struct boardioc_usbdev_ctrl_s ctrl; - int instance = instance; + int config = CONFIG_SYSTEM_COMPOSITE_DEFCONFIG; /* First check if the USB mass storage device is already connected */ @@ -731,11 +731,11 @@ int disconn_main(int argc, char *argv[]) check_test_memory_usage("Since MS connection"); - /* There is one optional argument.. the interface instance number */ + /* There is one optional argument.. the interface configuration ID */ if (argc == 2) { - instance = atoi(argv[1]); + config = atoi(argv[1]); } else if (argc > 2) { @@ -747,8 +747,8 @@ int disconn_main(int argc, char *argv[]) ctrl.usbdev = BOARDIOC_USBDEV_COMPOSITE; ctrl.action = BOARDIOC_USBDEV_DISCONNECT; - ctrl.instance = instance; - ctrl.config = 0; + ctrl.instance = 0; + ctrl.config = config; ctrl.handle = &g_composite.cmphandle; (void)boardctl(BOARDIOC_USBDEV_CONTROL, (uintptr_t)&ctrl);