Open CosmicRoach opened 5 months ago
Assigned to @xxkent for review.
Looks good to me, in case of caller set sz > 0.
Checking the input parameters (address and size) is another matter, here we should make sure that address>=0
and size>0
;
Assuming a correct parameter input, if we do not subtract 1 when calculating the last address of the erase, it will cause us to erase one more sector when the size of the erase is exactly one or more sectors-size.
Examples of errors:
When address=0x0, size=4096, dev->sector_sz=4096
, this means that the user wants to erase the first sector,
So, last_address = (address + size) & (~(dev-> sector_sz-1))=4096
; however, because of the loop condition while (address <= last_address);
We enter two loops, causing the second sector to be erased by mistake.
Summary
ToDos