]> www.infradead.org Git - mtd-utils.git/commitdiff
flash_lock: fix length being passed
authorVimal Singh <vimal.newwork@gmail.com>
Wed, 2 Dec 2009 14:28:08 +0000 (19:58 +0530)
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Tue, 8 Dec 2009 12:17:58 +0000 (14:17 +0200)
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>
flash_lock.c

index dca679456ef1b9faa88899775e460ff561159ba5..37f2ad3156f8413ecb61813f33a41c10ed3b92b1 100644 (file)
@@ -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;
 }
-