|
@@ -19,14 +19,12 @@
|
|
|
#include <drv_pdma.h>
|
|
|
#include <string.h>
|
|
|
|
|
|
-#if defined(RT_USING_DFS)
|
|
|
- #include <dfs_fs.h>
|
|
|
- #include <dfs_file.h>
|
|
|
- #include <unistd.h>
|
|
|
- #include <stdio.h>
|
|
|
- #include <sys/stat.h>
|
|
|
- #include <sys/statfs.h>
|
|
|
-#endif
|
|
|
+#include <dfs_fs.h>
|
|
|
+#include <dfs_file.h>
|
|
|
+#include <unistd.h>
|
|
|
+#include <stdio.h>
|
|
|
+#include <sys/stat.h>
|
|
|
+#include <sys/statfs.h>
|
|
|
|
|
|
/* Private define ---------------------------------------------------------------*/
|
|
|
|
|
@@ -236,11 +234,13 @@ static rt_size_t nu_sdh_read(rt_device_t dev, rt_off_t pos, void *buffer, rt_siz
|
|
|
{
|
|
|
rt_uint32_t ret = 0;
|
|
|
nu_sdh_t sdh = (nu_sdh_t)dev;
|
|
|
+ rt_err_t result;
|
|
|
|
|
|
RT_ASSERT(dev != RT_NULL);
|
|
|
RT_ASSERT(buffer != RT_NULL);
|
|
|
|
|
|
- rt_sem_take(&sdh->lock, RT_WAITING_FOREVER);
|
|
|
+ result = rt_sem_take(&sdh->lock, RT_WAITING_FOREVER);
|
|
|
+ RT_ASSERT(result == RT_EOK);
|
|
|
|
|
|
/* Check alignment. */
|
|
|
if (((uint32_t)buffer & 0x03) != 0)
|
|
@@ -281,7 +281,8 @@ exit_nu_sdh_read:
|
|
|
sdh->pbuf = RT_NULL;
|
|
|
}
|
|
|
|
|
|
- rt_sem_release(&sdh->lock);
|
|
|
+ result = rt_sem_release(&sdh->lock);
|
|
|
+ RT_ASSERT(result == RT_EOK);
|
|
|
|
|
|
if (ret == Successful)
|
|
|
return blk_nb;
|
|
@@ -295,11 +296,13 @@ static rt_size_t nu_sdh_write(rt_device_t dev, rt_off_t pos, const void *buffer,
|
|
|
{
|
|
|
rt_uint32_t ret = 0;
|
|
|
nu_sdh_t sdh = (nu_sdh_t)dev;
|
|
|
+ rt_err_t result;
|
|
|
|
|
|
RT_ASSERT(dev != RT_NULL);
|
|
|
RT_ASSERT(buffer != RT_NULL);
|
|
|
|
|
|
- rt_sem_take(&sdh->lock, RT_WAITING_FOREVER);
|
|
|
+ result = rt_sem_take(&sdh->lock, RT_WAITING_FOREVER);
|
|
|
+ RT_ASSERT(result == RT_EOK);
|
|
|
|
|
|
/* Check alignment. */
|
|
|
if (((uint32_t)buffer & 0x03) != 0)
|
|
@@ -338,7 +341,8 @@ exit_nu_sdh_write:
|
|
|
sdh->pbuf = RT_NULL;
|
|
|
}
|
|
|
|
|
|
- rt_sem_release(&sdh->lock);
|
|
|
+ result = rt_sem_release(&sdh->lock);
|
|
|
+ RT_ASSERT(result == RT_EOK);
|
|
|
|
|
|
if (ret == Successful) return blk_nb;
|
|
|
|
|
@@ -393,7 +397,8 @@ static int rt_hw_sdh_init(void)
|
|
|
/* Private */
|
|
|
nu_sdh_arr[i].dev.user_data = (void *)&nu_sdh_arr[i];
|
|
|
|
|
|
- rt_sem_init(&nu_sdh_arr[i].lock, "sdhlock", 1, RT_IPC_FLAG_FIFO);
|
|
|
+ ret = rt_sem_init(&nu_sdh_arr[i].lock, "sdhlock", 1, RT_IPC_FLAG_FIFO);
|
|
|
+ RT_ASSERT(ret == RT_EOK);
|
|
|
|
|
|
SDH_Open(nu_sdh_arr[i].base, CardDetect_From_GPIO);
|
|
|
|
|
@@ -402,6 +407,7 @@ static int rt_hw_sdh_init(void)
|
|
|
NVIC_EnableIRQ(SDH0_IRQn);
|
|
|
|
|
|
nu_sdh_arr[i].pbuf = RT_NULL;
|
|
|
+
|
|
|
ret = rt_device_register(&nu_sdh_arr[i].dev, nu_sdh_arr[i].name, flags);
|
|
|
RT_ASSERT(ret == RT_EOK);
|
|
|
}
|
|
@@ -415,8 +421,6 @@ static rt_bool_t nu_sdh_hotplug_is_mounted(const char *mounting_path)
|
|
|
{
|
|
|
rt_bool_t ret = RT_FALSE;
|
|
|
|
|
|
-#if defined(RT_USING_DFS)
|
|
|
-
|
|
|
struct dfs_filesystem *psFS = dfs_filesystem_lookup(mounting_path);
|
|
|
if (psFS == RT_NULL)
|
|
|
{
|
|
@@ -431,8 +435,6 @@ static rt_bool_t nu_sdh_hotplug_is_mounted(const char *mounting_path)
|
|
|
ret = RT_FALSE;
|
|
|
}
|
|
|
|
|
|
-#endif
|
|
|
-
|
|
|
exit_nu_sdh_hotplug_is_mounted:
|
|
|
|
|
|
return ret;
|
|
@@ -442,8 +444,6 @@ static rt_err_t nu_sdh_hotplug_mount(nu_sdh_t sdh)
|
|
|
rt_err_t ret = RT_ERROR;
|
|
|
DIR *t;
|
|
|
|
|
|
-#if defined(RT_USING_DFS)
|
|
|
-
|
|
|
if (nu_sdh_hotplug_is_mounted(sdh->mounted_point) == RT_TRUE)
|
|
|
{
|
|
|
ret = RT_EOK;
|
|
@@ -491,7 +491,6 @@ static rt_err_t nu_sdh_hotplug_mount(nu_sdh_t sdh)
|
|
|
|
|
|
exit_nu_sdh_hotplug_mount:
|
|
|
|
|
|
-#endif
|
|
|
return -(ret);
|
|
|
}
|
|
|
|
|
@@ -499,7 +498,6 @@ static rt_err_t nu_sdh_hotplug_unmount(nu_sdh_t sdh)
|
|
|
{
|
|
|
rt_err_t ret = RT_ERROR;
|
|
|
|
|
|
-#if defined(RT_USING_DFS)
|
|
|
if (nu_sdh_hotplug_is_mounted(sdh->mounted_point) == RT_FALSE)
|
|
|
{
|
|
|
ret = RT_EOK;
|
|
@@ -516,7 +514,6 @@ static rt_err_t nu_sdh_hotplug_unmount(nu_sdh_t sdh)
|
|
|
rt_kprintf("Succeed to unmount %s.\n", sdh->mounted_point);
|
|
|
ret = RT_EOK;
|
|
|
}
|
|
|
-#endif
|
|
|
|
|
|
exit_nu_sdh_hotplug_unmount:
|
|
|
|
|
@@ -585,7 +582,11 @@ static void sdh_hotplugger(void *param)
|
|
|
|
|
|
int mnt_init_sdcard_hotplug(void)
|
|
|
{
|
|
|
- rt_thread_init(&sdh_tid, "hotplug", sdh_hotplugger, NULL, sdh_stack, sizeof(sdh_stack), RT_THREAD_PRIORITY_MAX - 2, 10);
|
|
|
+ rt_err_t result;
|
|
|
+
|
|
|
+ result = rt_thread_init(&sdh_tid, "hotplug", sdh_hotplugger, NULL, sdh_stack, sizeof(sdh_stack), RT_THREAD_PRIORITY_MAX - 2, 10);
|
|
|
+ RT_ASSERT(result == RT_EOK);
|
|
|
+
|
|
|
rt_thread_startup(&sdh_tid);
|
|
|
|
|
|
return 0;
|