From: Peter Menzebach <pm-mtd@mw-itcon.de>
To: "Jörn Engel" <joern@wohnheim.fh-wedel.de>
Cc: "Artem B. Bityuckiy" <dedekind@yandex.ru>,
Linux MTD <linux-mtd@lists.infradead.org>
Subject: Re: [PATCH] fix for mtd partitions for erase_size != 2^X
Date: Fri, 30 Sep 2005 13:23:44 +0200 [thread overview]
Message-ID: <433D2040.3090109@mw-itcon.de> (raw)
In-Reply-To: <20050925131630.GC28978@wohnheim.fh-wedel.de>
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
next prev parent reply other threads:[~2005-09-30 11:34 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-09-23 18:02 [PATCH] fix for mtd partitions for erase_size != 2^X Peter Menzebach
2005-09-25 13:16 ` Jörn Engel
2005-09-26 9:13 ` Peter Menzebach
2005-09-30 11:23 ` Peter Menzebach [this message]
2005-10-03 10:54 ` Jörn Engel
-- strict thread matches above, loose matches on Subject: below --
2005-09-23 18:00 Peter Menzebach
2005-09-23 10:05 Peter Menzebach
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=433D2040.3090109@mw-itcon.de \
--to=pm-mtd@mw-itcon.de \
--cc=dedekind@yandex.ru \
--cc=joern@wohnheim.fh-wedel.de \
--cc=linux-mtd@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.