Forráskód Böngészése

【完善】fal_rtt.c 文件

guozhanxin 7 éve
szülő
commit
59609178a0
2 módosított fájl, 5 hozzáadás és 20 törlés
  1. 0 2
      inc/fal.h
  2. 5 18
      src/fal_rtt.c

+ 0 - 2
inc/fal.h

@@ -131,7 +131,6 @@ int fal_partition_erase_all(const struct fal_partition *part);
 void fal_show_part_table(void);
 
 /* =============== API provided to RT-Thread =============== */
-#if defined(RT_USING_DFS)
 /**
  * create RT-Thread block device by specified partition
  *
@@ -141,7 +140,6 @@ void fal_show_part_table(void);
  *            NULL: created failed
  */
 struct rt_device *fal_blk_device_create(const char *parition_name);
-#endif /* defined(RT_USING_DFS) */
 
 #if defined(RT_USING_MTD_NOR)
 /**

+ 5 - 18
src/fal_rtt.c

@@ -24,8 +24,6 @@
 
 #include <fal.h>
 
-#if defined(RT_USING_DFS)
-
 #include <rtthread.h>
 #include <rtdevice.h>
 #include <string.h>
@@ -216,8 +214,6 @@ struct rt_device *fal_blk_device_create(const char *parition_name)
     return RT_DEVICE(blk_dev);
 }
 
-#endif /* defined(RT_USING_DFS) */
-
 /* ========================== MTD nor device ======================== */
 #if defined(RT_USING_MTD_NOR)
 
@@ -358,15 +354,6 @@ struct fal_char_device
 };
 
 /* RT-Thread device interface */
-static rt_err_t char_dev_open(rt_device_t dev, rt_uint16_t oflag)
-{
-    struct fal_char_device *part = (struct fal_char_device *) dev;
-
-    /* erase partition when device open */
-    fal_partition_erase_all(part->fal_part);
-
-    return RT_EOK;
-}
 static rt_size_t char_dev_read(rt_device_t dev, rt_off_t pos, void *buffer, rt_size_t size)
 {
     int ret = 0;
@@ -414,7 +401,7 @@ static rt_size_t char_dev_write(rt_device_t dev, rt_off_t pos, const void *buffe
 const static struct rt_device_ops char_dev_ops =
 {
     RT_NULL,
-    char_dev_open,
+    RT_NULL,
     RT_NULL,
     char_dev_read,
     char_dev_write,
@@ -422,7 +409,7 @@ const static struct rt_device_ops char_dev_ops =
 };
 #endif
 
-#ifdef RT_USING_DFS_DEVFS
+#ifdef RT_USING_POSIX
 #include <dfs_posix.h>
 
 /* RT-Thread device filesystem interface */
@@ -501,7 +488,7 @@ const static struct dfs_file_ops char_dev_fops =
     RT_NULL, /* getdents */
     RT_NULL,
 };
-#endif /* defined(RT_USING_DFS_DEVFS) */
+#endif /* defined(RT_USING_POSIX) */
 
 /**
  * create RT-Thread char device by specified partition
@@ -540,7 +527,7 @@ struct rt_device *fal_char_device_create(const char *parition_name)
         char_dev->parent.ops  = &char_dev_ops;
 #else
         char_dev->parent.init = NULL;
-        char_dev->parent.open = char_dev_open;
+        char_dev->parent.open = NULL;
         char_dev->parent.close = NULL;
         char_dev->parent.read = char_dev_read;
         char_dev->parent.write = char_dev_write;
@@ -552,7 +539,7 @@ struct rt_device *fal_char_device_create(const char *parition_name)
         rt_device_register(RT_DEVICE(char_dev), fal_part->name, RT_DEVICE_FLAG_RDWR);
         log_i("The FAL char device (%s) created successfully", fal_part->name);
 
-#if defined(RT_USING_DFS_DEVFS)
+#ifdef RT_USING_POSIX
         /* set fops */
         char_dev->parent.fops = &char_dev_fops;
 #endif