Patchwork [U-Boot,v3,1/2] cmd_sf: let "sf update" erase last sector as a whole

login
register
mail settings
Submitter Gerlando Falauto
Date July 3, 2013, 6:33 p.m.
Message ID <1372876438-18305-2-git-send-email-gerlando.falauto@keymile.com>
Download mbox | patch
Permalink /patch/256724/
State Accepted
Delegated to: Jagannadha Sutradharudu Teki
Headers show

Comments

Gerlando Falauto - July 3, 2013, 6:33 p.m.
make "sf update" work with unaligned `len' parameter, by deleting the
whole last sector before writing, so to allow for:

 sf update ${load_addr_r} 0 ${filesize}

Signed-off-by: Gerlando Falauto <gerlando.falauto@keymile.com>
Cc: Valentin Longchamp <valentin.longchamp@keymile.com>
Cc: Holger Brunck <holger.brunck@keymile.com>
Acked-by: Simon Glass <sjg@chromium.org>
---
 common/cmd_sf.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Jagannadha Sutradharudu Teki - Aug. 6, 2013, 6:57 p.m.
On 04-07-2013 00:03, Gerlando Falauto wrote:
> make "sf update" work with unaligned `len' parameter, by deleting the
> whole last sector before writing, so to allow for:
>
>   sf update ${load_addr_r} 0 ${filesize}
>
> Signed-off-by: Gerlando Falauto <gerlando.falauto@keymile.com>
> Cc: Valentin Longchamp <valentin.longchamp@keymile.com>
> Cc: Holger Brunck <holger.brunck@keymile.com>
> Acked-by: Simon Glass <sjg@chromium.org>
> ---
>   common/cmd_sf.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/common/cmd_sf.c b/common/cmd_sf.c
> index 19b0dc9..ab35a94 100644
> --- a/common/cmd_sf.c
> +++ b/common/cmd_sf.c
> @@ -160,7 +160,8 @@ static const char *spi_flash_update_block(struct spi_flash *flash, u32 offset,
>   		*skipped += len;
>   		return NULL;
>   	}
> -	if (spi_flash_erase(flash, offset, len))
> +	/* Erase the entire sector */
> +	if (spi_flash_erase(flash, offset, flash->sector_size))
>   		return "erase";
>   	if (spi_flash_write(flash, offset, len, buf))
>   		return "write";
>
Reviewed-by: Jagannadha Sutradharudu Teki <jagannadh.teki@gmail.com>

--
Thanks,
Jagan.
Jagannadha Sutradharudu Teki - Aug. 6, 2013, 7:02 p.m.
On 07-08-2013 00:27, Jagan Teki wrote:
> On 04-07-2013 00:03, Gerlando Falauto wrote:
>> make "sf update" work with unaligned `len' parameter, by deleting the
>> whole last sector before writing, so to allow for:
>>
>>   sf update ${load_addr_r} 0 ${filesize}
>>
>> Signed-off-by: Gerlando Falauto <gerlando.falauto@keymile.com>
>> Cc: Valentin Longchamp <valentin.longchamp@keymile.com>
>> Cc: Holger Brunck <holger.brunck@keymile.com>
>> Acked-by: Simon Glass <sjg@chromium.org>
>> ---
>>   common/cmd_sf.c | 3 ++-
>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/common/cmd_sf.c b/common/cmd_sf.c
>> index 19b0dc9..ab35a94 100644
>> --- a/common/cmd_sf.c
>> +++ b/common/cmd_sf.c
>> @@ -160,7 +160,8 @@ static const char *spi_flash_update_block(struct
>> spi_flash *flash, u32 offset,
>>           *skipped += len;
>>           return NULL;
>>       }
>> -    if (spi_flash_erase(flash, offset, len))
>> +    /* Erase the entire sector */
>> +    if (spi_flash_erase(flash, offset, flash->sector_size))
>>           return "erase";
>>       if (spi_flash_write(flash, offset, len, buf))
>>           return "write";
>>
> Reviewed-by: Jagannadha Sutradharudu Teki <jagannadh.teki@gmail.com>
>
> --
> Thanks,
> Jagan.

Applied to u-boot-spi/master

--
Thanks,
Jagan.

Patch

diff --git a/common/cmd_sf.c b/common/cmd_sf.c
index 19b0dc9..ab35a94 100644
--- a/common/cmd_sf.c
+++ b/common/cmd_sf.c
@@ -160,7 +160,8 @@  static const char *spi_flash_update_block(struct spi_flash *flash, u32 offset,
 		*skipped += len;
 		return NULL;
 	}
-	if (spi_flash_erase(flash, offset, len))
+	/* Erase the entire sector */
+	if (spi_flash_erase(flash, offset, flash->sector_size))
 		return "erase";
 	if (spi_flash_write(flash, offset, len, buf))
 		return "write";