mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #13699 from boraozgen/bugfix/sfdp-find-addr-region
Fix sfdp_find_addr_region algorithmpull/13904/head
commit
f333c3ead1
|
@ -129,7 +129,7 @@ int sfdp_detect_erase_types_inst_and_size(uint8_t *bptbl_ptr, sfdp_hdr_info &sfd
|
|||
*
|
||||
* @return Region number
|
||||
*/
|
||||
int sfdp_find_addr_region(bd_size_t offset, const sfdp_hdr_info &sfdp_info);
|
||||
int sfdp_find_addr_region(bd_addr_t offset, const sfdp_hdr_info &sfdp_info);
|
||||
|
||||
/** Finds the largest Erase Type of the Region to which the offset belongs to
|
||||
*
|
||||
|
|
|
@ -373,9 +373,9 @@ int sfdp_detect_erase_types_inst_and_size(uint8_t *bptbl_ptr, sfdp_hdr_info &sfd
|
|||
return 0;
|
||||
}
|
||||
|
||||
int sfdp_find_addr_region(bd_size_t offset, const sfdp_hdr_info &sfdp_info)
|
||||
int sfdp_find_addr_region(bd_addr_t offset, const sfdp_hdr_info &sfdp_info)
|
||||
{
|
||||
if ((offset > sfdp_info.bptbl.device_size_bytes) || (sfdp_info.smptbl.region_cnt == 0)) {
|
||||
if ((offset >= sfdp_info.bptbl.device_size_bytes) || (sfdp_info.smptbl.region_cnt == 0)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -383,10 +383,10 @@ int sfdp_find_addr_region(bd_size_t offset, const sfdp_hdr_info &sfdp_info)
|
|||
return 0;
|
||||
}
|
||||
|
||||
for (int idx = sfdp_info.smptbl.region_cnt - 2; idx >= 0; idx--) {
|
||||
for (int idx = 0; idx < sfdp_info.smptbl.region_cnt; idx++) {
|
||||
|
||||
if (offset > sfdp_info.smptbl.region_high_boundary[idx]) {
|
||||
return (idx + 1);
|
||||
if (offset <= sfdp_info.smptbl.region_high_boundary[idx]) {
|
||||
return idx;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
|
|
Loading…
Reference in New Issue