* [RFC] [PATCH] [MTD-UTILS]: flash_lock: fix length being passed
@ 2009-12-02 14:28 Vimal Singh
2009-12-02 14:33 ` Vimal Singh
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Vimal Singh @ 2009-12-02 14:28 UTC (permalink / raw)
To: Linux MTD
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>
---
--- flash_lock.c.org 2009-11-24 19:33:18.000000000 +0530
+++ flash_lock.c 2009-11-24 19:33:13.000000000 +0530
@@ -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;
}
-
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [RFC] [PATCH] [MTD-UTILS]: flash_lock: fix length being passed
2009-12-02 14:28 [RFC] [PATCH] [MTD-UTILS]: flash_lock: fix length being passed Vimal Singh
@ 2009-12-02 14:33 ` Vimal Singh
2009-12-04 8:41 ` Artem Bityutskiy
2009-12-08 12:19 ` Artem Bityutskiy
2 siblings, 0 replies; 5+ messages in thread
From: Vimal Singh @ 2009-12-02 14:33 UTC (permalink / raw)
To: Linux MTD
On Wed, Dec 2, 2009 at 7:58 PM, Vimal Singh <vimal.newwork@gmail.com> wrote:
> 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>
> ---
>
> --- flash_lock.c.org 2009-11-24 19:33:18.000000000 +0530
> +++ flash_lock.c 2009-11-24 19:33:13.000000000 +0530
Sorry, this patch was generated using 'diff'. Below is the correct patch.
-vimal
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>
---
--- a/flash_lock.c 2009-11-24 19:33:18.000000000 +0530
+++ b/flash_lock.c 2009-11-24 19:33:13.000000000 +0530
@@ -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;
}
-
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [RFC] [PATCH] [MTD-UTILS]: flash_lock: fix length being passed
2009-12-02 14:28 [RFC] [PATCH] [MTD-UTILS]: flash_lock: fix length being passed Vimal Singh
2009-12-02 14:33 ` Vimal Singh
@ 2009-12-04 8:41 ` Artem Bityutskiy
2009-12-07 6:54 ` Vimal Singh
2009-12-08 12:19 ` Artem Bityutskiy
2 siblings, 1 reply; 5+ messages in thread
From: Artem Bityutskiy @ 2009-12-04 8:41 UTC (permalink / raw)
To: Vimal Singh; +Cc: Linux MTD
On Wed, 2009-12-02 at 19:58 +0530, Vimal Singh wrote:
> 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>
> ---
>
> --- flash_lock.c.org 2009-11-24 19:33:18.000000000 +0530
> +++ flash_lock.c 2009-11-24 19:33:13.000000000 +0530
> @@ -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[])
So if num_sectors is 1, mtdLockInfo.length is 0 - is it expected?
--
Best Regards,
Artem Bityutskiy (Артём Битюцкий)
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [RFC] [PATCH] [MTD-UTILS]: flash_lock: fix length being passed
2009-12-04 8:41 ` Artem Bityutskiy
@ 2009-12-07 6:54 ` Vimal Singh
0 siblings, 0 replies; 5+ messages in thread
From: Vimal Singh @ 2009-12-07 6:54 UTC (permalink / raw)
To: dedekind1; +Cc: Linux MTD
On Fri, Dec 4, 2009 at 2:11 PM, Artem Bityutskiy <dedekind1@gmail.com> wrote:
> On Wed, 2009-12-02 at 19:58 +0530, Vimal Singh wrote:
>> 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>
>> ---
>>
>> --- flash_lock.c.org 2009-11-24 19:33:18.000000000 +0530
>> +++ flash_lock.c 2009-11-24 19:33:13.000000000 +0530
>> @@ -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[])
>
> So if num_sectors is 1, mtdLockInfo.length is 0 - is it expected?
I think so. Suppose you want to lock 1st block: 'start' will be '0x0' and
if you pass 'length' as one block size then boundaries will be:
start: 0x0 ('0'th block)
end: 0x20000 (1st block) if 0x20000 is the block size
so you will lock 2 blocks here.
While passing 'length' as '0' for this case will lock only 1st block
(0th block).
--
Regards,
Vimal Singh
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFC] [PATCH] [MTD-UTILS]: flash_lock: fix length being passed
2009-12-02 14:28 [RFC] [PATCH] [MTD-UTILS]: flash_lock: fix length being passed Vimal Singh
2009-12-02 14:33 ` Vimal Singh
2009-12-04 8:41 ` Artem Bityutskiy
@ 2009-12-08 12:19 ` Artem Bityutskiy
2 siblings, 0 replies; 5+ messages in thread
From: Artem Bityutskiy @ 2009-12-08 12:19 UTC (permalink / raw)
To: Vimal Singh; +Cc: Linux MTD
On Wed, 2009-12-02 at 19:58 +0530, Vimal Singh wrote:
> 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>
Pushed, thanks!
--
Best Regards,
Artem Bityutskiy (Артём Битюцкий)
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2009-12-08 12:20 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-02 14:28 [RFC] [PATCH] [MTD-UTILS]: flash_lock: fix length being passed Vimal Singh
2009-12-02 14:33 ` Vimal Singh
2009-12-04 8:41 ` Artem Bityutskiy
2009-12-07 6:54 ` Vimal Singh
2009-12-08 12:19 ` Artem Bityutskiy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox