Change structure braces policy
[lwext4.git] / lwext4 / ext4_bcache.h
index c64841b6cae60711ee5057edf22436f8758c8f29..692bd86559330820724312653f69177a0e5320b5 100644 (file)
 #include <stdint.h>\r
 #include <stdbool.h>\r
 \r
-/**@brief      Single block descriptor.*/\r
-struct ext4_block {\r
-    /**@brief  Dirty flag.*/\r
-    bool               dirty;\r
+/**@brief   Single block descriptor.*/\r
+struct ext4_block {\r
+    /**@brief   Dirty flag.*/\r
+    bool dirty;\r
 \r
-    /**@brief  Logical block ID*/\r
-    uint64_t   lb_id;\r
+    /**@brief   Logical block ID*/\r
+    uint64_t lb_id;\r
 \r
     /**@brief   Cache id*/\r
-    uint32_t    cache_id;\r
+    uint32_t cache_id;\r
 \r
-    /**@brief  Data buffer.*/\r
-    uint8_t            *data;\r
+    /**@brief   Data buffer.*/\r
+    uint8_t *data;\r
 };\r
 \r
+/**@brief   Block cache descriptor.*/\r
+struct ext4_bcache {\r
 \r
-/**@brief      Block cache descriptor.*/\r
-struct ext4_bcache {\r
+    /**@brief   Item count in block cache*/\r
+    uint32_t cnt;\r
 \r
-    /**@brief  Item count in block cache*/\r
-    uint32_t   cnt;\r
+    /**@brief   Item size in block cache*/\r
+    uint32_t itemsize;\r
 \r
-    /**@brief  Item size in block cache*/\r
-    uint32_t   itemsize;\r
+    /**@brief   Last recently used counter.*/\r
+    uint32_t lru_ctr;\r
 \r
-    /**@brief  Last recently used counter.*/\r
-    uint32_t   lru_ctr;\r
+    /**@brief   Reference count table (cnt).*/\r
+    uint32_t refctr[CONFIG_BLOCK_DEV_CACHE_SIZE];\r
 \r
-    /**@brief  Reference count table (cnt).*/\r
-    uint32_t   *refctr;\r
+    /**@brief   Last recently used ID table (cnt)*/\r
+    uint32_t lru_id[CONFIG_BLOCK_DEV_CACHE_SIZE];\r
 \r
-    /**@brief  Last recently used ID table (cnt)*/\r
-    uint32_t   *lru_id;\r
+    /**@brief   Writeback free delay mode table (cnt)*/\r
+    uint8_t free_delay[CONFIG_BLOCK_DEV_CACHE_SIZE];\r
 \r
-    /**@brief  Free delay mode table (cnt)*/\r
-    uint8_t    *free_delay;\r
+    /**@brief   Logical block table (cnt).*/\r
+    uint64_t lba[CONFIG_BLOCK_DEV_CACHE_SIZE];\r
 \r
-    /**@brief  Logical block table (cnt).*/\r
-    uint64_t   *lba;\r
+    /**@brief   Dirty mark (cnt).*/\r
+    bool dirty[CONFIG_BLOCK_DEV_CACHE_SIZE];\r
 \r
-    /**@brief  Cache data buffers (cnt * itemsize)*/\r
-    uint8_t            *data;\r
+    /**@brief   Cache data buffers (cnt * itemsize)*/\r
+    uint8_t *data;\r
 \r
-    /**@brief  Currently referenced datablocks*/\r
-    uint32_t   ref_blocks;\r
-\r
-    /**@brief  Maximum referenced datablocks*/\r
-    uint32_t   max_ref_blocks;\r
+    /**@brief   Currently referenced datablocks*/\r
+    uint32_t ref_blocks;\r
 \r
+    /**@brief   Maximum referenced datablocks*/\r
+    uint32_t max_ref_blocks;\r
 };\r
 \r
-/**@brief      Static initializer of block cache structure.*/\r
-#define EXT4_BCACHE_STATIC_INSTANCE(__name, __cnt, __itemsize)      \\r
-        static uint32_t        __name##_refctr[(__cnt)];                   \\r
-        static uint32_t        __name##_lru_id[(__cnt)];                   \\r
-        static uint8_t         __name##_free_delay[(__cnt)];           \\r
-        static uint64_t        __name##_lba[(__cnt)];                      \\r
-        static uint8_t         __name##_data[(__cnt) * (__itemsize)];      \\r
-        static struct ext4_bcache      __name = {                      \\r
-                .cnt      = __cnt,                                 \\r
-                .itemsize  = __itemsize,                            \\r
-                .lru_ctr   = 0,                                     \\r
-                .refctr           = __name##_refctr,                       \\r
-                .lru_id    = __name##_lru_id,                       \\r
-                .lba      = __name##_lba,                          \\r
-                .free_delay= __name##_free_delay,                   \\r
-                .data     = __name##_data,                         \\r
-        }\r
-\r
-\r
-/**@brief      Dynamic initialization of block cache.\r
- * @param      bc block cache descriptor\r
- * @param      cnt items count in block cache\r
- * @param      itemsize single item size (in bytes)\r
- * @return     standard error code*/\r
-int    ext4_bcache_init_dynamic(struct ext4_bcache *bc, uint32_t cnt,\r
-    uint32_t itemsize);\r
-\r
-/**@brief      Dynamic de-initialization of block cache.\r
- * @param      bc block cache descriptor\r
- * @return     standard error code*/\r
-int ext4_bcache_fini_dynamic(struct    ext4_bcache *bc);\r
-\r
-/**@brief      Allocate block from block cache memory.\r
+/**@brief   Static initializer of block cache structure.*/\r
+#define EXT4_BCACHE_STATIC_INSTANCE(__name, __cnt, __itemsize)                 \\r
+    static uint8_t __name##_data[(__cnt) * (__itemsize)];                      \\r
+    static struct ext4_bcache __name = {                                       \\r
+        .cnt = __cnt,                                                          \\r
+        .itemsize = __itemsize,                                                \\r
+        .lru_ctr = 0,                                                          \\r
+        .data = __name##_data,                                                 \\r
+    }\r
+\r
+/**@brief   Dynamic initialization of block cache.\r
+ * @param   bc block cache descriptor\r
+ * @param   cnt items count in block cache\r
+ * @param   itemsize single item size (in bytes)\r
+ * @return  standard error code*/\r
+int ext4_bcache_init_dynamic(struct ext4_bcache *bc, uint32_t cnt,\r
+                             uint32_t itemsize);\r
+\r
+/**@brief   Dynamic de-initialization of block cache.\r
+ * @param   bc block cache descriptor\r
+ * @return  standard error code*/\r
+int ext4_bcache_fini_dynamic(struct ext4_bcache *bc);\r
+\r
+/**@brief   Allocate block from block cache memory.\r
  *          Unreferenced block allocation is based on LRU\r
  *          (Last Recently Used) algorithm.\r
- * @param      bc      block cache descriptor\r
- * @param      b block to alloc\r
- * @param      is_new block is new (needs to be read)\r
+ * @param   bc block cache descriptor\r
+ * @param   b block to alloc\r
+ * @param   is_new block is new (needs to be read)\r
  * @return  standard error code*/\r
 int ext4_bcache_alloc(struct ext4_bcache *bc, struct ext4_block *b,\r
-    bool *is_new);\r
+                      bool *is_new);\r
 \r
-/**@brief      Free block from cache memory (decrement reference counter).\r
- * @param      bc      block cache descriptor\r
- * @param      b block to free\r
+/**@brief   Free block from cache memory (decrement reference counter).\r
+ * @param   bc block cache descriptor\r
+ * @param   b block to free\r
+ * @param   cache writeback mode\r
  * @return  standard error code*/\r
-int ext4_bcache_free (struct ext4_bcache *bc, struct ext4_block *b,\r
-    uint8_t free_delay);\r
-\r
+int ext4_bcache_free(struct ext4_bcache *bc, struct ext4_block *b,\r
+                     uint8_t free_delay);\r
 \r
-/**@brief      Return a full status of block cache.\r
- * @param      bc      block cache descriptor\r
- * @return     full status*/\r
+/**@brief   Return a full status of block cache.\r
+ * @param   bc block cache descriptor\r
+ * @return  full status*/\r
 bool ext4_bcache_is_full(struct ext4_bcache *bc);\r
 \r
 #endif /* EXT4_BCACHE_H_ */\r