mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Jan Luebbe <jlu@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH] drivers/nor/m25p80.c: fix erase loop for unaligned addresses
Date: Wed, 27 Jun 2012 15:58:04 +0200	[thread overview]
Message-ID: <20120627135804.GP1623@pengutronix.de> (raw)
In-Reply-To: <1340632570-10034-1-git-send-email-jlu@pengutronix.de>

On Mon, Jun 25, 2012 at 03:56:10PM +0200, Jan Luebbe wrote:
> In some cases with unaligned addresses the loop would not abort.
> Instead, use the calculated sector numbers in a for-loop.
> 
> Based on a patch by Sascha Hauer <s.hauer@pengutronix.de>.
> 
> Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
> ---
>  drivers/nor/m25p80.c |   12 ++++--------
>  1 file changed, 4 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/nor/m25p80.c b/drivers/nor/m25p80.c
> index 1440227..b4dfbfa 100644
> --- a/drivers/nor/m25p80.c
> +++ b/drivers/nor/m25p80.c
> @@ -200,7 +200,7 @@ static ssize_t m25p80_erase(struct cdev *cdev, size_t count, loff_t offset)
>  	u32 addr, len;
>  	u32 start_sector;
>  	u32 end_sector;
> -	u32 progress = 0;
> +	u32 cur_sector;
>  	int eraseshift = ffs(flash->erasesize) - 1;

eraseshift does only exist in the 64bit branch. can you rebase this onto
master?

Sascha

>  
>  	dev_dbg(&flash->spi->dev, "%s %s 0x%llx, len %lld\n",
> @@ -232,17 +232,13 @@ static ssize_t m25p80_erase(struct cdev *cdev, size_t count, loff_t offset)
>  
>  	/* "sector"-at-a-time erase */
>  	} else {
> -		while (len) {
> +		for (cur_sector = start_sector; cur_sector <= end_sector; cur_sector++) {
>  			if (ctrlc())
>  				return -EINTR;
> -			if (erase_sector(flash, addr))
> +			if (erase_sector(flash, cur_sector << eraseshift))
>  				return -EIO;
>  
> -			show_progress(++progress);
> -			if (len <= flash->erasesize)
> -				break;
> -			addr += flash->erasesize;
> -			len -= flash->erasesize;
> +			show_progress(cur_sector - start_sector + 1);
>  		}
>  	}
>  
> -- 
> 1.7.10
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
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 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

      reply	other threads:[~2012-06-27 13:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-25 13:56 Jan Luebbe
2012-06-27 13:58 ` Sascha Hauer [this message]

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=20120627135804.GP1623@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=jlu@pengutronix.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox