You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2018/11/05 16:25:55 UTC

[GitHub] mkiiskila commented on a change in pull request #1472: flash_map; add flash_area_to_subareas().

mkiiskila commented on a change in pull request #1472: flash_map; add flash_area_to_subareas().
URL: https://github.com/apache/mynewt-core/pull/1472#discussion_r230816566
 
 

 ##########
 File path: sys/flash_map/src/flash_map.c
 ##########
 @@ -131,6 +131,73 @@ flash_area_getnext_sector(int id, int *sec_id, struct flash_area *ret)
     return rc;
 }
 
+int
+flash_area_to_subareas(int id, int *cnt, struct flash_area *ret)
+{
+    int rc;
+    int i, j;
+    const struct hal_flash *hf;
+    const struct flash_area *fa;
+    int max_cnt;
+    int next;
+    int first_idx;
+    int last_idx;
+    uint32_t start;
+    uint32_t size;
+    uint32_t min_size;
+
+    rc = flash_area_open(id, &fa);
+    if (rc != 0) {
+        return rc;
+    }
+    first_idx = last_idx = -1;
+    max_cnt = *cnt;
+    *cnt = 0;
+
+    hf = hal_bsp_flash_dev(fa->fa_device_id);
+    for (i = 0; i < hf->hf_sector_cnt; i++) {
+        hf->hf_itf->hff_sector_info(hf, i, &start, &size);
+        if (start >= fa->fa_off && start < fa->fa_off + fa->fa_size) {
+            if (first_idx == -1) {
+                first_idx = i;
+            }
+            last_idx = i;
+            *cnt = *cnt + 1;
 
 Review comment:
   Good point.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services