diff options
| author | sakumisu <[email protected]> | 2025-01-26 19:56:39 +0800 |
|---|---|---|
| committer | sakumisu <[email protected]> | 2025-01-26 19:56:39 +0800 |
| commit | 609c85db6875b0c85cc4bf2edeb72663fcfcff8d (patch) | |
| tree | 6c5328d1f7ad67a6f87d4035f3c4467814729d84 | |
| parent | d3aafb2174d6d84aacd8d14a2ed5bee4946ce80e (diff) | |
update(platform/rtthread/usbh_dfs): move mount into another thread
Signed-off-by: sakumisu <[email protected]>
| -rw-r--r-- | platform/rtthread/usbh_dfs.c | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/platform/rtthread/usbh_dfs.c b/platform/rtthread/usbh_dfs.c index 9fba3915..eee64a0b 100644 --- a/platform/rtthread/usbh_dfs.c +++ b/platform/rtthread/usbh_dfs.c @@ -45,7 +45,6 @@ static rt_err_t rt_udisk_init(rt_device_t dev) struct usbh_msc *msc_class = (struct usbh_msc *)dev->user_data; if (usbh_msc_scsi_init(msc_class) < 0) { - rt_kprintf("scsi_init error,ret:%d\r\n", ret); return -RT_ERROR; } @@ -164,19 +163,35 @@ const static struct rt_device_ops udisk_device_ops = { }; #endif -int udisk_init(struct usbh_msc *msc_class) +static void usbh_msc_thread(CONFIG_USB_OSAL_THREAD_SET_ARGV) { - rt_err_t ret = 0; - rt_uint8_t i; - struct rt_device *dev; + struct usbh_msc *msc_class = (struct usbh_msc *)CONFIG_USB_OSAL_THREAD_GET_ARGV; char name[CONFIG_USBHOST_DEV_NAMELEN]; char mount_point[CONFIG_USBHOST_DEV_NAMELEN]; + int ret; + + snprintf(name, CONFIG_USBHOST_DEV_NAMELEN, DEV_FORMAT, msc_class->sdchar); + snprintf(mount_point, CONFIG_USBHOST_DEV_NAMELEN, CONFIG_USB_DFS_MOUNT_POINT, msc_class->sdchar); + + ret = dfs_mount(name, mount_point, "elm", 0, 0); + if (ret == 0) { + rt_kprintf("udisk: %s mount successfully\n", name); + } else { + rt_kprintf("udisk: %s mount failed, ret = %d\n", name, ret); + } + + usb_osal_thread_delete(NULL); +} + +void usbh_msc_run(struct usbh_msc *msc_class) +{ + struct rt_device *dev; + char name[CONFIG_USBHOST_DEV_NAMELEN]; dev = rt_malloc(sizeof(struct rt_device)); memset(dev, 0, sizeof(struct rt_device)); snprintf(name, CONFIG_USBHOST_DEV_NAMELEN, DEV_FORMAT, msc_class->sdchar); - snprintf(mount_point, CONFIG_USBHOST_DEV_NAMELEN, CONFIG_USB_DFS_MOUNT_POINT, msc_class->sdchar); dev->type = RT_Device_Class_Block; #ifdef RT_USING_DEVICE_OPS @@ -191,19 +206,7 @@ int udisk_init(struct usbh_msc *msc_class) rt_device_register(dev, name, RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_REMOVABLE | RT_DEVICE_FLAG_STANDALONE); - ret = dfs_mount(name, mount_point, "elm", 0, 0); - if (ret == 0) { - rt_kprintf("udisk: %s mount successfully\n", name); - } else { - rt_kprintf("udisk: %s mount failed, ret = %d\n", name, ret); - } - - return ret; -} - -void usbh_msc_run(struct usbh_msc *msc_class) -{ - udisk_init(msc_class); + usb_osal_thread_create("usbh_msc", 2048, CONFIG_USBHOST_PSC_PRIO + 1, usbh_msc_thread, msc_class); } void usbh_msc_stop(struct usbh_msc *msc_class) |
