You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ma...@apache.org on 2016/03/29 02:40:51 UTC
[06/15] incubator-mynewt-core git commit: Add a routine to report
number of free sectors. Fix a bug in initialization.
Add a routine to report number of free sectors. Fix a bug in
initialization.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/a4b302aa
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/a4b302aa
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/a4b302aa
Branch: refs/heads/develop
Commit: a4b302aa5e5c93078f6ef2749f6f599462b1d432
Parents: 9bd0b3a
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Mon Mar 28 17:34:05 2016 -0700
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Mon Mar 28 17:37:31 2016 -0700
----------------------------------------------------------------------
sys/fcb/src/fcb.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/a4b302aa/sys/fcb/src/fcb.c
----------------------------------------------------------------------
diff --git a/sys/fcb/src/fcb.c b/sys/fcb/src/fcb.c
index 03a9a2c..1c3ac3e 100644
--- a/sys/fcb/src/fcb.c
+++ b/sys/fcb/src/fcb.c
@@ -56,8 +56,10 @@ fcb_init(struct fcb *fcb)
}
if (FCB_ID_GT(fda.fd_id, newest)) {
newest = fda.fd_id;
+ newest_fap = fap;
} else if (FCB_ID_GT(oldest, fda.fd_id)) {
oldest = fda.fd_id;
+ oldest_fap = fap;
}
}
if (oldest < 0) {
@@ -87,6 +89,22 @@ fcb_init(struct fcb *fcb)
return FCB_OK;
}
+int
+fcb_free_sector_cnt(struct fcb *fcb)
+{
+ int i;
+ struct flash_area *fa;
+
+ fa = fcb->f_active.fe_area;
+ for (i = 0; i < fcb->f_sector_cnt; i++) {
+ fa = fcb_getnext_area(fcb, fa);
+ if (fa == fcb->f_oldest) {
+ break;
+ }
+ }
+ return i;
+}
+
/*
* Length of an element is encoded in 1 or 2 bytes.
* 1 byte for lengths < 128 bytes, and 2 bytes for < 16384.