All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] fs: fat: don't call disk_write with zero sector num
@ 2013-07-24  9:55 Josh Wu
  2013-07-25  7:23 ` Josh Wu
  2013-09-06 21:24 ` [U-Boot] " Tom Rini
  0 siblings, 2 replies; 3+ messages in thread
From: Josh Wu @ 2013-07-24  9:55 UTC (permalink / raw)
  To: u-boot

In the set_cluster() function, it will convert the buffer size to sector
numbers. Then call disk_write() to write by sector.
For remaining buffer, the size is less than a sector, call disk_write()
again to write them in one sector.

But if the total buffer size is less then one sector, the original code
will call disk_write() with zero sector number. It is unnecessary.
So this patch fix this. Now it will not call disk_write() if total buffer size
is less than one sector.

Signed-off-by: Josh Wu <josh.wu@atmel.com>
---
 fs/fat/fat_write.c |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/fs/fat/fat_write.c b/fs/fat/fat_write.c
index fd07240..a05327c 100644
--- a/fs/fat/fat_write.c
+++ b/fs/fat/fat_write.c
@@ -568,9 +568,11 @@ set_cluster(fsdata *mydata, __u32 clustnum, __u8 *buffer,
 
 	debug("clustnum: %d, startsect: %d\n", clustnum, startsect);
 
-	if (disk_write(startsect, size / mydata->sect_size, buffer) < 0) {
-		debug("Error writing data\n");
-		return -1;
+	if ((size / mydata->sect_size) > 0) {
+		if (disk_write(startsect, size / mydata->sect_size, buffer) < 0) {
+			debug("Error writing data\n");
+			return -1;
+		}
 	}
 
 	if (size % mydata->sect_size) {
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [U-Boot] [PATCH] fs: fat: don't call disk_write with zero sector num
  2013-07-24  9:55 [U-Boot] [PATCH] fs: fat: don't call disk_write with zero sector num Josh Wu
@ 2013-07-25  7:23 ` Josh Wu
  2013-09-06 21:24 ` [U-Boot] " Tom Rini
  1 sibling, 0 replies; 3+ messages in thread
From: Josh Wu @ 2013-07-25  7:23 UTC (permalink / raw)
  To: u-boot

Hi, All

On 7/24/2013 5:55 PM, Josh Wu wrote:
> In the set_cluster() function, it will convert the buffer size to sector
> numbers. Then call disk_write() to write by sector.
> For remaining buffer, the size is less than a sector, call disk_write()
> again to write them in one sector.
>
> But if the total buffer size is less then one sector, the original code
> will call disk_write() with zero sector number. It is unnecessary.
> So this patch fix this. Now it will not call disk_write() if total buffer size
> is less than one sector.
>
> Signed-off-by: Josh Wu <josh.wu@atmel.com>

Forgot to mention that: this is the v2 patch for [PATCH] fs: fat: fix 
bug when write size is less than a sector size 
(http://thread.gmane.org/gmane.comp.boot-loaders.u-boot/165997)

Best Regards,
Josh Wu

> ---
>   fs/fat/fat_write.c |    8 +++++---
>   1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/fs/fat/fat_write.c b/fs/fat/fat_write.c
> index fd07240..a05327c 100644
> --- a/fs/fat/fat_write.c
> +++ b/fs/fat/fat_write.c
> @@ -568,9 +568,11 @@ set_cluster(fsdata *mydata, __u32 clustnum, __u8 *buffer,
>   
>   	debug("clustnum: %d, startsect: %d\n", clustnum, startsect);
>   
> -	if (disk_write(startsect, size / mydata->sect_size, buffer) < 0) {
> -		debug("Error writing data\n");
> -		return -1;
> +	if ((size / mydata->sect_size) > 0) {
> +		if (disk_write(startsect, size / mydata->sect_size, buffer) < 0) {
> +			debug("Error writing data\n");
> +			return -1;
> +		}
>   	}
>   
>   	if (size % mydata->sect_size) {

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [U-Boot] fs: fat: don't call disk_write with zero sector num
  2013-07-24  9:55 [U-Boot] [PATCH] fs: fat: don't call disk_write with zero sector num Josh Wu
  2013-07-25  7:23 ` Josh Wu
@ 2013-09-06 21:24 ` Tom Rini
  1 sibling, 0 replies; 3+ messages in thread
From: Tom Rini @ 2013-09-06 21:24 UTC (permalink / raw)
  To: u-boot

On Wed, Jul 24, 2013 at 05:55:30PM +0800, Wu, Josh wrote:

> In the set_cluster() function, it will convert the buffer size to sector
> numbers. Then call disk_write() to write by sector.
> For remaining buffer, the size is less than a sector, call disk_write()
> again to write them in one sector.
> 
> But if the total buffer size is less then one sector, the original code
> will call disk_write() with zero sector number. It is unnecessary.
> So this patch fix this. Now it will not call disk_write() if total buffer size
> is less than one sector.
> 
> Signed-off-by: Josh Wu <josh.wu@atmel.com>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20130906/64a8d9d0/attachment.pgp>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-09-06 21:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-24  9:55 [U-Boot] [PATCH] fs: fat: don't call disk_write with zero sector num Josh Wu
2013-07-25  7:23 ` Josh Wu
2013-09-06 21:24 ` [U-Boot] " Tom Rini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.