diff options
author | Vimal Singh <vimal.newwork@gmail.com> | 2009-12-02 19:58:08 +0530 |
---|---|---|
committer | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2009-12-08 14:17:58 +0200 |
commit | 43feb39f35a9ee0ed318df80433243c0bfe263ea (patch) | |
tree | 49aec240e53e731b6480be53dc0e17aef2a436e5 /flash_lock.c | |
parent | 27d38823cc38f30ea9e2cb580f171fd722dd1734 (diff) |
flash_lock: fix length being passed
This patch fixes the 'length' calculation.
Making it:
+ mtdLockInfo.length = (num_sectors - 1) * mtdInfo.erasesize;
Rather:
- mtdLockInfo.length = num_sectors * mtdInfo.erasesize;
Say there are 240 blocks present in the device. Then:
offset starts from: 0x0
and full size of device: 0x1E00000
doing: 240 * 0x20000 gives -> 0x1E00000
But last block address should be 0x1DE0000 (which spans for 0x20000
bytes, adding upto size of 0x1E00000)
Signed-off-by: Vimal Singh <vimalsingh@ti.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'flash_lock.c')
-rw-r--r-- | flash_lock.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/flash_lock.c b/flash_lock.c index dca6794..37f2ad3 100644 --- a/flash_lock.c +++ b/flash_lock.c @@ -71,7 +71,7 @@ int main(int argc, char *argv[]) } mtdLockInfo.start = ofs; - mtdLockInfo.length = num_sectors * mtdInfo.erasesize; + mtdLockInfo.length = (num_sectors - 1) * mtdInfo.erasesize; if(ioctl(fd, MEMLOCK, &mtdLockInfo)) { fprintf(stderr, "Could not lock MTD device: %s\n", argv[1]); @@ -81,4 +81,3 @@ int main(int argc, char *argv[]) return 0; } - |