From: Josh Wu <josh.wu@atmel.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] fs: fat: don't call disk_write with zero sector num
Date: Thu, 25 Jul 2013 15:23:21 +0800 [thread overview]
Message-ID: <51F0D269.5060309@atmel.com> (raw)
In-Reply-To: <1374659730-2634-1-git-send-email-josh.wu@atmel.com>
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) {
next prev parent reply other threads:[~2013-07-25 7:23 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2013-09-06 21:24 ` [U-Boot] " Tom Rini
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=51F0D269.5060309@atmel.com \
--to=josh.wu@atmel.com \
--cc=u-boot@lists.denx.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 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.