[PATCH] mtd: partitions: no unnecessary check for erase block

Boris Brezillon boris.brezillon at free-electrons.com
Mon Jan 9 02:18:55 PST 2017


On Fri,  6 Jan 2017 17:26:24 +0100
Bastian Stender <bst at pengutronix.de> wrote:

> Partitions must start/end on erase block or boundary to be writeable.
> This makes only sense if erasing is necessary. Do not force the
> partition to be read-only if MTD_NO_ERASE flag is set.

Shouldn't the partition be aligned on ->writesize in this case?

> 
> Signed-off-by: Bastian Stender <bst at pengutronix.de>
> ---
>  drivers/mtd/mtdpart.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c
> index fccdd49bb964..cd138023ed32 100644
> --- a/drivers/mtd/mtdpart.c
> +++ b/drivers/mtd/mtdpart.c
> @@ -557,6 +557,7 @@ static struct mtd_part *allocate_partition(struct mtd_info *master,
>  	}
>  
>  	if ((slave->mtd.flags & MTD_WRITEABLE) &&
> +	    !(slave->mtd.flags & MTD_NO_ERASE) &&
>  	    mtd_mod_by_eb(slave->offset, &slave->mtd)) {
>  		/* Doesn't start on a boundary of major erase size */
>  		/* FIXME: Let it be writable if it is on a boundary of
> @@ -566,6 +567,7 @@ static struct mtd_part *allocate_partition(struct mtd_info *master,
>  			part->name);
>  	}
>  	if ((slave->mtd.flags & MTD_WRITEABLE) &&
> +	    !(slave->mtd.flags & MTD_NO_ERASE) &&
>  	    mtd_mod_by_eb(slave->mtd.size, &slave->mtd)) {
>  		slave->mtd.flags &= ~MTD_WRITEABLE;
>  		printk(KERN_WARNING"mtd: partition \"%s\" doesn't end on an erase block -- force read-only\n",




More information about the linux-mtd mailing list