static int board_mscclassobject(int minor, FAR struct usbdev_devinfo_s *devinfo, FAR struct usbdevclass_driver_s **classdev) { int ret; DEBUGASSERT(g_mschandle == NULL); /* Configure the mass storage device */ uinfo("Configuring with NLUNS=1\n"); ret = usbmsc_configure(1, &g_mschandle); if (ret < 0) { uerr("ERROR: usbmsc_configure failed: %d\n", -ret); return ret; } uinfo("MSC handle=%p\n", g_mschandle); /* Bind the LUN(s) */ uinfo("Bind LUN=0 to /dev/mmcsd0\n"); ret = usbmsc_bindlun(g_mschandle, "/dev/mmcsd0", 0, 0, 0, false); if (ret < 0) { uerr("ERROR: usbmsc_bindlun failed for LUN 1 at /dev/mmcsd0: %d\n", ret); usbmsc_uninitialize(g_mschandle); g_mschandle = NULL; return ret; } /* Get the mass storage device's class object */ ret = usbmsc_classobject(g_mschandle, devinfo, classdev); if (ret < 0) { uerr("ERROR: usbmsc_classobject failed: %d\n", -ret); usbmsc_uninitialize(g_mschandle); g_mschandle = NULL; } return ret; }
int board_mscclassobject(FAR struct usbdevclass_driver_s **classdev) { int ret; DEBUGASSERT(g_composite.mschandle == NULL); /* Initialize USB trace output IDs */ usbtrace_enable(TRACE_BITSET); check_test_memory_usage("After usbtrace_enable()"); /* Configure the mass storage device */ printf("board_mscclassobject: Configuring with NLUNS=%d\n", CONFIG_SYSTEM_COMPOSITE_NLUNS); ret = usbmsc_configure(CONFIG_SYSTEM_COMPOSITE_NLUNS, &g_composite.mschandle); if (ret < 0) { printf("board_mscclassobject: usbmsc_configure failed: %d\n", -ret); return ret; } printf("board_mscclassobject: MSC handle=%p\n", g_composite.mschandle); check_test_memory_usage("After usbmsc_configure()"); /* Bind the LUN(s) */ printf("board_mscclassobject: Bind LUN=0 to %s\n", CONFIG_SYSTEM_COMPOSITE_DEVPATH1); ret = usbmsc_bindlun(g_composite.mschandle, CONFIG_SYSTEM_COMPOSITE_DEVPATH1, 0, 0, 0, false); if (ret < 0) { printf("board_mscclassobject: usbmsc_bindlun failed for LUN 1 using %s: %d\n", CONFIG_SYSTEM_COMPOSITE_DEVPATH1, -ret); usbmsc_uninitialize(g_composite.mschandle); return ret; } check_test_memory_usage("After usbmsc_bindlun()"); #if CONFIG_SYSTEM_COMPOSITE_NLUNS > 1 printf("board_mscclassobject: Bind LUN=1 to %s\n", CONFIG_SYSTEM_COMPOSITE_DEVPATH2); ret = usbmsc_bindlun(g_composite.mschandle, CONFIG_SYSTEM_COMPOSITE_DEVPATH2, 1, 0, 0, false); if (ret < 0) { printf("board_mscclassobject: usbmsc_bindlun failed for LUN 2 using %s: %d\n", CONFIG_SYSTEM_COMPOSITE_DEVPATH2, -ret); usbmsc_uninitialize(g_composite.mschandle); return ret; } check_test_memory_usage("After usbmsc_bindlun() #2"); #if CONFIG_SYSTEM_COMPOSITE_NLUNS > 2 printf("board_mscclassobject: Bind LUN=2 to %s\n", CONFIG_SYSTEM_COMPOSITE_DEVPATH3); ret = usbmsc_bindlun(g_composite.mschandle, CONFIG_SYSTEM_COMPOSITE_DEVPATH3, 2, 0, 0, false); if (ret < 0) { printf("board_mscclassobject: usbmsc_bindlun failed for LUN 3 using %s: %d\n", CONFIG_SYSTEM_COMPOSITE_DEVPATH3, -ret); usbmsc_uninitialize(g_composite.mschandle); return ret; } check_test_memory_usage("After usbmsc_bindlun() #3"); #endif #endif /* Get the mass storage device's class object */ ret = usbmsc_classobject(g_composite.mschandle, classdev); if (ret < 0) { printf("board_mscclassobject: usbmsc_classobject failed: %d\n", -ret); usbmsc_uninitialize(g_composite.mschandle); } check_test_memory_usage("After usbmsc_classobject()"); return ret; }