This is an automated email from the ASF dual-hosted git repository.

marko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git

commit 77d0aff5a9e2c0617ad0c3029050895104707c48
Author: Marko Kiiskila <ma...@apache.org>
AuthorDate: Wed Aug 21 15:54:00 2019 +0300

    fs/fcb2; minor cleanup.
    Removed few unused function prototypes, unused struct elements.
    Export fcb_sector_erase().
---
 fs/fcb2/include/fcb/fcb.h | 22 ++++++++++++----------
 fs/fcb2/src/fcb_append.c  |  8 +++++---
 fs/fcb2/src/fcb_priv.h    | 18 ++++++------------
 3 files changed, 23 insertions(+), 25 deletions(-)

diff --git a/fs/fcb2/include/fcb/fcb.h b/fs/fcb2/include/fcb/fcb.h
index 9be2630..d481297 100644
--- a/fs/fcb2/include/fcb/fcb.h
+++ b/fs/fcb2/include/fcb/fcb.h
@@ -45,8 +45,7 @@ struct fcb;
  * within that sector.
  */
 struct fcb_entry {
-    struct fcb *fe_fcb;
-    struct flash_sector_range *fe_range;  /* ptr to area within fcb->f_ranages 
*/
+    struct flash_sector_range *fe_range;  /* ptr to area within fcb->f_ranges 
*/
     uint16_t fe_sector;     /* sector number in fcb flash */
     uint16_t fe_data_len;   /* size of data area */
     uint32_t fe_data_off;   /* start of data in sector */
@@ -64,20 +63,13 @@ struct fcb {
     uint8_t f_scratch_cnt;  /* How many sectors should be kept empty */
     uint8_t f_range_cnt;    /* Number of elements in range array */
     uint16_t f_sector_cnt;  /* Number of sectors used by fcb */
+    uint16_t f_oldest_sec;  /* Index of oldest sector */
     struct flash_sector_range *f_ranges;
 
     /* Flash circular buffer internal state */
     struct os_mutex f_mtx;     /* Locking for accessing the FCB data */
-    uint16_t f_oldest_sec;
     struct fcb_entry f_active;
     uint16_t f_active_id;
-    uint16_t f_sector_entries; /* Number of entries in current sector */
-};
-
-struct fcb_sector_info {
-    struct flash_sector_range *si_range;  /* Sector range */
-    uint32_t si_sector_offset;            /* Sector offset in fcb */
-    uint16_t si_sector_in_range;          /* Sector number relative to 
si_range */
 };
 
 /**
@@ -175,6 +167,16 @@ fcb_offset_last_n(struct fcb *fcb, uint8_t entries,
         struct fcb_entry *last_n_entry);
 
 /**
+ * Erase sector in FCB
+ *
+ * @param fcb     FCB to use
+ * @param sector  sector number to erase 0..f_sector_cnt
+ *
+ * return 0 on success, error code on failure
+ */
+int fcb_sector_erase(const struct fcb *fcb, int sector);
+
+/**
  * Get total size of FCB
  *
  * @param fcb     FCB to use
diff --git a/fs/fcb2/src/fcb_append.c b/fs/fcb2/src/fcb_append.c
index 616d62b..04cb340 100644
--- a/fs/fcb2/src/fcb_append.c
+++ b/fs/fcb2/src/fcb_append.c
@@ -112,7 +112,8 @@ fcb_entry_location_in_range(const struct fcb_entry *loc)
 {
     const struct flash_sector_range *range = loc->fe_range;
 
-    return range->fsr_sector_size * (1 + loc->fe_sector - 
range->fsr_first_sector) -
+    return range->fsr_sector_size *
+        (1 + loc->fe_sector - range->fsr_first_sector) -
         (loc->fe_entry_num * fcb_len_in_flash(loc->fe_range, FCB_ENTRY_SIZE));
 }
 
@@ -141,7 +142,7 @@ int
 fcb_read(struct fcb_entry *loc, uint16_t off, void *buf, uint16_t len)
 {
     int pos = loc->fe_data_off + off;
-    /* Make sure tha read is only from entry data */
+    /* Make sure that read is only from entry data */
     if (off + len > loc->fe_data_len) {
         len = loc->fe_data_len - off;
     }
@@ -173,7 +174,8 @@ fcb_append(struct fcb *fcb, uint16_t len, struct fcb_entry 
*append_loc)
         return FCB_ERR_ARGS;
     }
     active = &fcb->f_active;
-    if (fcb_active_sector_free_space(fcb) < 
fcb_element_length_in_flash(active, len)) {
+    if (fcb_active_sector_free_space(fcb) < fcb_element_length_in_flash(active,
+                                                                        len)) {
         sector = fcb_new_sector(fcb, fcb->f_scratch_cnt);
         if (sector >= 0) {
             range = fcb_get_sector_range(fcb, sector);
diff --git a/fs/fcb2/src/fcb_priv.h b/fs/fcb2/src/fcb_priv.h
index e87a944..63f18e3 100644
--- a/fs/fcb2/src/fcb_priv.h
+++ b/fs/fcb2/src/fcb_priv.h
@@ -34,6 +34,12 @@ struct fcb_disk_area {
     uint16_t fd_id;
 };
 
+struct fcb_sector_info {
+    struct flash_sector_range *si_range;  /* Sector range */
+    uint32_t si_sector_offset;            /* Sector offset in fcb */
+    uint16_t si_sector_in_range;          /* Sector number relative to 
si_range */
+};
+
 static inline int
 fcb_len_in_flash(const struct flash_sector_range *range, uint16_t len)
 {
@@ -44,7 +50,6 @@ fcb_len_in_flash(const struct flash_sector_range *range, 
uint16_t len)
 }
 
 int fcb_getnext_in_area(struct fcb *fcb, struct fcb_entry *loc);
-struct flash_area *fcb_getnext_area(struct fcb *fcb, struct flash_area *fap);
 
 static inline int
 fcb_getnext_sector(struct fcb *fcb, int sector)
@@ -58,7 +63,6 @@ fcb_getnext_sector(struct fcb *fcb, int sector)
 int fcb_getnext_nolock(struct fcb *fcb, struct fcb_entry *loc);
 
 int fcb_elem_info(struct fcb_entry *loc);
-int fcb_elem_crc8(struct fcb_entry *loc, uint8_t *crc8p);
 int fcb_elem_crc16(struct fcb_entry *loc, uint16_t *c16p);
 int fcb_sector_hdr_init(struct fcb *fcb, int sector, uint16_t id);
 int fcb_entry_location_in_range(const struct fcb_entry *loc);
@@ -115,16 +119,6 @@ int fcb_write_to_sector(struct fcb_entry *loc, int off,
  */
 int fcb_read_from_sector(struct fcb_entry *loc, int off, void *buf, int len);
 
-/**
- * Erase sector in FCB
- *
- * @param fcb     FCB to use
- * @param sector  sector number to erase 0..f_sector_cnt
- *
- * return 0 on success, error code on failure
- */
-int fcb_sector_erase(const struct fcb *fcb, int sector);
-
 #ifdef __cplusplus
 }
 #endif

Reply via email to