* [PATCH] fix for mtd partitions for erase_size != 2^X
@ 2005-09-23 10:05 Peter Menzebach
0 siblings, 0 replies; 7+ messages in thread
From: Peter Menzebach @ 2005-09-23 10:05 UTC (permalink / raw)
To: linux-mtd; +Cc: Artem B. Bityuckiy
[-- Attachment #1: Type: text/plain, Size: 147 bytes --]
Here a trivial patch,
which allows correct creation of mtd partitions, which have erase sizes
which are not a power of 2.
Best regards
Peter
[-- Attachment #2: patch.mtdpart.c --]
[-- Type: text/plain, Size: 691 bytes --]
--- drivers/mtd/mtdpart.c.orig 2005-09-23 09:28:07.000000000 +0200
+++ drivers/mtd/mtdpart.c 2005-09-23 09:29:37.000000000 +0200
@@ -465,9 +465,9 @@
if (slave->offset == MTDPART_OFS_APPEND)
slave->offset = cur_offset;
if (slave->offset == MTDPART_OFS_NXTBLK) {
- u_int32_t emask = master->erasesize-1;
- slave->offset = (cur_offset + emask) & ~emask;
- if (slave->offset != cur_offset) {
+ slave->offset = cur_offset;
+ if ((cur_offset % master->erasesize) != 0) {
+ slave->offset = ((cur_offset / master->erasesize) + 1) * master->erasesize;
printk(KERN_NOTICE "Moving partition %d: "
"0x%08x -> 0x%08x\n", i,
cur_offset, slave->offset);
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] fix for mtd partitions for erase_size != 2^X
@ 2005-09-23 18:00 Peter Menzebach
0 siblings, 0 replies; 7+ messages in thread
From: Peter Menzebach @ 2005-09-23 18:00 UTC (permalink / raw)
To: Linux MTD
Here a trivial patch,
which allows correct creation of mtd partitions, which have erase sizes
which are not a power of 2.
Best regards
Peter
Sorry, I didn't succeed to get the patch accepted by the mailing list as
attachment.
--
Peter Menzebach
Menzebach und Wolff IT-Consulting GbR
Phone +49 751 355 387 1
--- drivers/mtd/mtdpart.c.orig 2005-09-23 09:28:07.000000000 +0200
+++ drivers/mtd/mtdpart.c 2005-09-23 09:29:37.000000000 +0200
@@ -465,9 +465,9 @@
if (slave->offset == MTDPART_OFS_APPEND)
slave->offset = cur_offset;
if (slave->offset == MTDPART_OFS_NXTBLK) {
- u_int32_t emask = master->erasesize-1;
- slave->offset = (cur_offset + emask) & ~emask;
- if (slave->offset != cur_offset) {
+ slave->offset = cur_offset;
+ if ((cur_offset % master->erasesize) != 0) {
+ slave->offset = ((cur_offset / master->erasesize) + 1) *
master->erasesize;
printk(KERN_NOTICE "Moving partition %d: "
"0x%08x -> 0x%08x\n", i,
cur_offset, slave->offset);
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] fix for mtd partitions for erase_size != 2^X
@ 2005-09-23 18:02 Peter Menzebach
2005-09-25 13:16 ` Jörn Engel
0 siblings, 1 reply; 7+ messages in thread
From: Peter Menzebach @ 2005-09-23 18:02 UTC (permalink / raw)
To: Linux MTD
Here a trivial patch,
which allows correct creation of mtd partitions, which have erase sizes
which are not a power of 2.
Best regards
Peter
Sorry, I didn't succeed to get the patch accepted by the mailing list as
attachment.
--- drivers/mtd/mtdpart.c.orig 2005-09-23 09:28:07.000000000 +0200
+++ drivers/mtd/mtdpart.c 2005-09-23 09:29:37.000000000 +0200
@@ -465,9 +465,9 @@
if (slave->offset == MTDPART_OFS_APPEND)
slave->offset = cur_offset;
if (slave->offset == MTDPART_OFS_NXTBLK) {
- u_int32_t emask = master->erasesize-1;
- slave->offset = (cur_offset + emask) & ~emask;
- if (slave->offset != cur_offset) {
+ slave->offset = cur_offset;
+ if ((cur_offset % master->erasesize) != 0) {
+ slave->offset = ((cur_offset / master->erasesize) + 1)
* master->erasesize;
printk(KERN_NOTICE "Moving partition %d: "
"0x%08x -> 0x%08x\n", i,
cur_offset, slave->offset);
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] fix for mtd partitions for erase_size != 2^X
2005-09-23 18:02 Peter Menzebach
@ 2005-09-25 13:16 ` Jörn Engel
2005-09-26 9:13 ` Peter Menzebach
2005-09-30 11:23 ` Peter Menzebach
0 siblings, 2 replies; 7+ messages in thread
From: Jörn Engel @ 2005-09-25 13:16 UTC (permalink / raw)
To: Peter Menzebach; +Cc: Linux MTD
On Fri, 23 September 2005 20:02:42 +0200, Peter Menzebach wrote:
>
> Here a trivial patch,
> which allows correct creation of mtd partitions, which have erase sizes
> which are not a power of 2.
>
> Best regards
> Peter
>
> Sorry, I didn't succeed to get the patch accepted by the mailing list as
> attachment.
I actually prefer inline. Except that your mailer seems to have
messed things up - grr.
> --- drivers/mtd/mtdpart.c.orig 2005-09-23 09:28:07.000000000 +0200
> +++ drivers/mtd/mtdpart.c 2005-09-23 09:29:37.000000000 +0200
> @@ -465,9 +465,9 @@
> if (slave->offset == MTDPART_OFS_APPEND)
> slave->offset = cur_offset;
> if (slave->offset == MTDPART_OFS_NXTBLK) {
> - u_int32_t emask = master->erasesize-1;
> - slave->offset = (cur_offset + emask) & ~emask;
> - if (slave->offset != cur_offset) {
> + slave->offset = cur_offset;
> + if ((cur_offset % master->erasesize) != 0) {
> + slave->offset = ((cur_offset / master->erasesize) + 1)
> * master->erasesize;
> printk(KERN_NOTICE "Moving partition %d: "
> "0x%08x -> 0x%08x\n", i,
> cur_offset, slave->offset);
Looks complicated. I guess we could use the equivalent of this:
#define ALIGN(x,a) (((x)+(a)-1)&~((a)-1))
in some header. Then your patch would be as simple as
if (slave->offset == MTDPART_OFS_APPEND)
slave->offset = cur_offset;
if (slave->offset == MTDPART_OFS_NXTBLK) {
- u_int32_t emask = master->erasesize-1;
- slave->offset = (cur_offset + emask) & ~emask;
+ slave->offset = TRUE_ALIGN(cur_offset, master->erasesize);
if (slave->offset != cur_offset) {
printk(KERN_NOTICE "Moving partition %d: "
"0x%08x -> 0x%08x\n", i,
Maybe this:
#define TRUE_ALIGN(x,a) (((x)+(a)-1) - ((x)+(a)-1) % a)
The macro is still complicated, but we just have to get it right once.
Jörn
--
Public Domain - Free as in Beer
General Public - Free as in Speech
BSD License - Free as in Enterprise
Shared Source - Free as in "Work will make you..."
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] fix for mtd partitions for erase_size != 2^X
2005-09-25 13:16 ` Jörn Engel
@ 2005-09-26 9:13 ` Peter Menzebach
2005-09-30 11:23 ` Peter Menzebach
1 sibling, 0 replies; 7+ messages in thread
From: Peter Menzebach @ 2005-09-26 9:13 UTC (permalink / raw)
To: Jörn Engel; +Cc: Linux MTD
Jörn Engel wrote:
> Maybe this:
> #define TRUE_ALIGN(x,a) (((x)+(a)-1) - ((x)+(a)-1) % a)
>
> The macro is still complicated, but we just have to get it right once.
>
> Jörn
>
Are you sure, this is not as complicated as my version ;) ?
But if you like it, no problem.
Shall I resubmit the patch?
Is there any known good way to submit a patch here? I have two mailer
here, but the mailing list refuses both (as attachment and inline
attachment).
Best regards
Peter
--
Peter Menzebach
Menzebach und Wolff IT-Consulting GbR
Phone +49 751 355 387 1
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] fix for mtd partitions for erase_size != 2^X
2005-09-25 13:16 ` Jörn Engel
2005-09-26 9:13 ` Peter Menzebach
@ 2005-09-30 11:23 ` Peter Menzebach
2005-10-03 10:54 ` Jörn Engel
1 sibling, 1 reply; 7+ messages in thread
From: Peter Menzebach @ 2005-09-30 11:23 UTC (permalink / raw)
To: Jörn Engel; +Cc: Artem B. Bityuckiy, Linux MTD
Jörn Engel wrote:
> On Fri, 23 September 2005 20:02:42 +0200, Peter Menzebach wrote:
>
>>Here a trivial patch,
>>which allows correct creation of mtd partitions, which have erase sizes
>>which are not a power of 2.
>>
>>Best regards
>>Peter
>>
>>Sorry, I didn't succeed to get the patch accepted by the mailing list as
>>attachment.
>
>
> I actually prefer inline. Except that your mailer seems to have
> messed things up - grr.
>
>
>>--- drivers/mtd/mtdpart.c.orig 2005-09-23 09:28:07.000000000 +0200
>>+++ drivers/mtd/mtdpart.c 2005-09-23 09:29:37.000000000 +0200
>>@@ -465,9 +465,9 @@
>> if (slave->offset == MTDPART_OFS_APPEND)
>> slave->offset = cur_offset;
>> if (slave->offset == MTDPART_OFS_NXTBLK) {
>>- u_int32_t emask = master->erasesize-1;
>>- slave->offset = (cur_offset + emask) & ~emask;
>>- if (slave->offset != cur_offset) {
>>+ slave->offset = cur_offset;
>>+ if ((cur_offset % master->erasesize) != 0) {
>>+ slave->offset = ((cur_offset / master->erasesize) + 1)
>>* master->erasesize;
>> printk(KERN_NOTICE "Moving partition %d: "
>> "0x%08x -> 0x%08x\n", i,
>> cur_offset, slave->offset);
>
>
> Looks complicated. I guess we could use the equivalent of this:
> #define ALIGN(x,a) (((x)+(a)-1)&~((a)-1))
> in some header. Then your patch would be as simple as
>
> if (slave->offset == MTDPART_OFS_APPEND)
> slave->offset = cur_offset;
> if (slave->offset == MTDPART_OFS_NXTBLK) {
> - u_int32_t emask = master->erasesize-1;
> - slave->offset = (cur_offset + emask) & ~emask;
> + slave->offset = TRUE_ALIGN(cur_offset, master->erasesize);
> if (slave->offset != cur_offset) {
> printk(KERN_NOTICE "Moving partition %d: "
> "0x%08x -> 0x%08x\n", i,
>
> Maybe this:
> #define TRUE_ALIGN(x,a) (((x)+(a)-1) - ((x)+(a)-1) % a)
>
> The macro is still complicated, but we just have to get it right once.
>
> Jörn
>
Here the patch again. As the macro does not seem to reduce the
complexity of the line seriously and would be used only once, I did put
in a comment, which explains inline, what should go on there.
The patch now as link:
http://www.mw-itcon.de/patches/patch.dataflash.mtdpart.c
Best regards
Peter
--
Peter Menzebach
Menzebach und Wolff IT-Consulting GbR
Phone +49 751 355 387 1
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] fix for mtd partitions for erase_size != 2^X
2005-09-30 11:23 ` Peter Menzebach
@ 2005-10-03 10:54 ` Jörn Engel
0 siblings, 0 replies; 7+ messages in thread
From: Jörn Engel @ 2005-10-03 10:54 UTC (permalink / raw)
To: Peter Menzebach; +Cc: Artem B. Bityuckiy, Linux MTD
On Fri, 30 September 2005 13:23:44 +0200, Peter Menzebach wrote:
> >
> Here the patch again. As the macro does not seem to reduce the
> complexity of the line seriously and would be used only once, I did put
> in a comment, which explains inline, what should go on there.
All right. I still don't like it, but since I don't have any better
idea...
Jörn
--
Das Aufregende am Schreiben ist es, eine Ordnung zu schaffen, wo
vorher keine existiert hat.
-- Doris Lessing
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2005-10-03 10:54 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-09-23 18:00 [PATCH] fix for mtd partitions for erase_size != 2^X Peter Menzebach
-- strict thread matches above, loose matches on Subject: below --
2005-09-23 18:02 Peter Menzebach
2005-09-25 13:16 ` Jörn Engel
2005-09-26 9:13 ` Peter Menzebach
2005-09-30 11:23 ` Peter Menzebach
2005-10-03 10:54 ` Jörn Engel
2005-09-23 10:05 Peter Menzebach
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox