[PATCH 1/1] mtd: nand: fix unaligned write support

Jean-Christophe PLAGNIOL-VILLARD plagnioj at jcrosoft.com
Fri Dec 7 08:17:05 EST 2012


On 19:28 Wed 05 Dec     , Sascha Hauer wrote:
> On Wed, Dec 05, 2012 at 06:15:20PM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > via cdev we may write unaligned data the code was drop in the commit
> > 0a4b1c7e440a81819eb2137f923573a3055dc7a2
> > mtd core: call driver write function with complete buffer
> > 
> > which is true for spi flashes but the code is still mandatory on nand
> 
> I suggest the following simpler approach.
> 
> Sascha
> 
yes it work here

Best Regards,
J.
> 
> From 5248abe7e59f60085b9a2affd3db11a6ac0a9da9 Mon Sep 17 00:00:00 2001
> From: Sascha Hauer <s.hauer at pengutronix.de>
> Date: Wed, 5 Dec 2012 19:24:41 +0100
> Subject: [PATCH] mtd nand: allow partial page writes
> 
> The nand layer handles partial page writes just fine. If the start or
> end of the data is not page aligned, the nand layer will copy the data
> to a temporary page buffer.
> Remove the check which disallows partial page writes since this is what
> we want to do on barebox when for example an image is written to nand
> which is not padded to page size.
> 
> Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
> ---
>  drivers/mtd/nand/nand_write.c |    7 -------
>  1 file changed, 7 deletions(-)
> 
> diff --git a/drivers/mtd/nand/nand_write.c b/drivers/mtd/nand/nand_write.c
> index 5ed04ce..9997127 100644
> --- a/drivers/mtd/nand/nand_write.c
> +++ b/drivers/mtd/nand/nand_write.c
> @@ -273,13 +273,6 @@ int nand_do_write_ops(struct mtd_info *mtd, loff_t to,
>  	if (!writelen)
>  		return 0;
>  
> -	/* reject writes, which are not page aligned */
> -	if (NOTALIGNED(to) || NOTALIGNED(ops->len)) {
> -		printk(KERN_NOTICE "nand_write: "
> -		       "Attempt to write not page aligned data\n");
> -		return -EINVAL;
> -	}
> -
>  	column = to & (mtd->writesize - 1);
>  	subpage = column || (writelen & (mtd->writesize - 1));
>  
> -- 
> 1.7.10.4
> 
> -- 
> Pengutronix e.K.                           |                             |
> Industrial Linux Solutions                 | http://www.pengutronix.de/  |
> Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
> Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



More information about the barebox mailing list