lkml.org 
[lkml]   [2014]   [Nov]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v3 3/3] mtd: block2mtd: Removes PAGE_MASK as a index to partition size
On Sun, Nov 09, 2014 at 07:23:12AM -0500, Rodrigo Freire wrote:
> From: Felix Fietkau <nbd@openwrt.org>
>
> mtd: block2mtd: Removes PAGE_MASK as a index to partition size

You don't need to repeat the subject here.

>
> PAGE_MASK is no longer needed with the new term.

This isn't too descriptive. What you probably mean is that we assume the
erase size is always larger than PAGE_SIZE.

> This patch keeps the device size aligned with the erase_size.
>
> Signed-off-by: Felix Fietkau <nbd@openwrt.org>
> Signed-off-by: Rodrigo Freire <rfreire@redhat.com>
> Signed-off-by: Herton Krzesinski <herton@redhat.com>
> ---
> V3: Separated on a single patch
> --- a/drivers/mtd/devices/block2mtd.c 2014-11-07 17:40:58.688747820 -0200
> +++ b/drivers/mtd/devices/block2mtd.c 2014-11-07 17:41:28.054750893 -0200
> @@ -291,8 +291,7 @@ static struct block2mtd_dev *add_device(
> goto err_destroy_mutex;
>
> dev->mtd.name = name;
> -
> - dev->mtd.size = dev->blkdev->bd_inode->i_size & PAGE_MASK;
> + dev->mtd.size = dev->blkdev->bd_inode->i_size & ~(erase_size - 1);

You never guaranteed that erase_size is a power of two, so this doesn't
necessarily mask the way you'd like...

But also, why is this even necessary? I see that we should already have
errored out if this was actually significant, since we have above:

if ((long)dev->blkdev->bd_inode->i_size % erase_size) {
pr_err("erasesize must be a divisor of device size\n");
goto err_free_block2mtd;
}

> dev->mtd.erasesize = erase_size;
> dev->mtd.writesize = 1;
> dev->mtd.writebufsize = PAGE_SIZE;

Brian


\
 
 \ /
  Last update: 2014-11-26 09:01    [W:0.114 / U:0.172 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site