From: "Benoît Thébaudeau" <benoit.thebaudeau@advansee.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] mmc and fat bug fixes
Date: Wed, 15 May 2013 17:37:04 +0200 (CEST) [thread overview]
Message-ID: <1808571307.844971.1368632224152.JavaMail.root@advansee.com> (raw)
In-Reply-To: <15AE5A936F5E3A42A9144E66875A0A89308F2E@server1-derijp.CLB-Benelux.lokaal>
Hi Ruud,
On Wednesday, May 15, 2013 4:23:51 PM, Ruud Commandeur wrote:
> This patch fixes a number of mmc and fat-related bugs:
There should be only one logical change per patch.
>
> > Added a check for blkcnt > 0 in mmc_write_blocks (drivers/mmc.c) to prevent
> > a hangup for further mmc commands.
Adding Andy, the MMC custodian, to Cc.
>
> > Solved a checksum issue in fs/fat/fat.c. The mkcksum has const char
> > arguments with a size specifier, like "const char name[8]". In the
> > function, it is assumed that sizeof(name) will have the value 8, but this
> > is not the case (at least not for the Sourcery CodeBench compiler and
> > probably not according to ANSI C). This causes "long filename checksum
> > errors" for each fat file listed or written.
>
> > Made some changes to fs/fat/fat_write.c. Fixed testing fat_val for
> > 0xffff/0xfff8 and 0xfffffff/0xffffff8 by adding the corresponding fatsize
> > in the test (as read in earlier posts) and some changes in debug output.
Expressions like "as read in earlier posts" should not be present in a patch
description since it is unclear what it refers to once the patch has been
applied.
Line lengths should be at most 80 characters, including in the patch
description.
>
> Signed-off-by: Ruud Commandeur <rcommandeur@clb.nl>
> Cc: Tom Rini <trini@ti.com>
> Cc: Beno?t Th?baudeau <benoit.thebaudeau@advansee.com>
> Cc: Mats Karrman <Mats.Karrman@tritech.se>
>
> Index: drivers/mmc/mmc.c
> ===================================================================
> --- drivers/mmc/mmc.c (revision 9)
> +++ drivers/mmc/mmc.c (working copy)
> @@ -282,8 +282,9 @@
>
> if (blkcnt > 1)
> cmd.cmdidx = MMC_CMD_WRITE_MULTIPLE_BLOCK;
> - else
> + else if (blkcnt > 0)
> cmd.cmdidx = MMC_CMD_WRITE_SINGLE_BLOCK;
> + else return 0; //Called with blkcnt = 0
The comment above is useless. Also, the comment style in U-Boot is /**/, not //.
>
> if (mmc->high_capacity)
> cmd.cmdarg = start;
> Index: fs/fat/fat.c
> ===================================================================
> --- fs/fat/fat.c (revision 9)
> +++ fs/fat/fat.c (working copy)
> @@ -569,10 +569,12 @@
>
> __u8 ret = 0;
>
> - for (i = 0; i < sizeof(name); i++)
> + for (i = 0; i < 8; i++) {
> ret = (((ret & 1) << 7) | ((ret & 0xfe) >> 1)) + name[i];
> - for (i = 0; i < sizeof(ext); i++)
> + }
> + for (i = 0; i < 3; i++) {
> ret = (((ret & 1) << 7) | ((ret & 0xfe) >> 1)) + ext[i];
> + }
>
> return ret;
> }
There should not be curly braces for single-line blocks.
Anyway, this has already been done by Marek in commit 6ad77d8, so this hunk
should be dropped.
> Index: fs/fat/fat_write.c
> ===================================================================
> --- fs/fat/fat_write.c (revision 9)
> +++ fs/fat/fat_write.c (working copy)
> @@ -41,6 +41,7 @@
> }
>
> static int total_sector;
> +
> static int disk_write(__u32 block, __u32 nr_blocks, void *buf)
> {
> if (!cur_dev || !cur_dev->block_write)
This hunk is not very useful.
> @@ -104,8 +105,7 @@
> } else
> memcpy(dirent->ext, s_name + period_location + 1, 3);
>
> - debug("name : %s\n", dirent->name);
> - debug("ext : %s\n", dirent->ext);
> + debug("name.ext : %.8s.%.3s\n", dirent->name, dirent->ext);
Correct. You could just remove the space before the colon since this is the
standard English formatting.
> }
>
> static __u8 num_of_fats;
> @@ -264,6 +264,7 @@
> goto name0_4;
> }
> slotptr->name0_4[j] = name[*idx];
> + slotptr->name0_4[j + 1] = 0x00;
> (*idx)++;
> end_idx++;
> }
> @@ -275,6 +276,7 @@
> goto name5_10;
> }
> slotptr->name5_10[j] = name[*idx];
> + slotptr->name5_10[j + 1] = 0x00;
> (*idx)++;
> end_idx++;
> }
> @@ -286,6 +288,7 @@
> goto name11_12;
> }
> slotptr->name11_12[j] = name[*idx];
> + slotptr->name11_12[j + 1] = 0x00;
> (*idx)++;
> end_idx++;
> }
These 3 hunks are correct, but they should be mentioned in the patch
description.
> @@ -569,7 +572,7 @@
> else
> startsect = mydata->rootdir_sect;
>
> - debug("clustnum: %d, startsect: %d\n", clustnum, startsect);
> + debug("clustnum: %d, startsect: %d, size %lu\n", clustnum, startsect,
> size);
Line too long: max 80 chars.
>
> if (disk_write(startsect, size / mydata->sect_size, buffer) < 0) {
> debug("Error writing data\n");
> @@ -587,10 +590,7 @@
> debug("Error writing data\n");
> return -1;
> }
> -
> - return 0;
OK.
> }
> -
This empty line would be better kept for code legibility.
> return 0;
> }
>
> @@ -656,7 +656,8 @@
> else
> break;
>
> - if (fat_val == 0xfffffff || fat_val == 0xffff)
> + if (((fat_val == 0xfffffff) && (mydata->fatsize == 32)) ||
> + ((fat_val == 0xffff) && (mydata->fatsize == 16)))
> break;
>
> entry = fat_val;
> @@ -901,7 +902,8 @@
> }
>
> curclust = get_fatent_value(mydata, dir_curclust);
> - if ((curclust >= 0xffffff8) || (curclust >= 0xfff8)) {
> + if (((curclust >= 0xffffff8) && (mydata->fatsize == 32)) ||
> + ((curclust >= 0xfff8) && (mydata->fatsize == 16))) {
> empty_dentptr = dentptr;
> return NULL;
> }
>
These 2 hunks are correct, but please remove the parentheses around the "=="
expressions: They make the code less readable. And add another tab to indent the
2nd line of the if-s so that it is more indented than the if block contents.
Best regards,
Beno?t
next prev parent reply other threads:[~2013-05-15 15:37 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-15 14:23 [U-Boot] [PATCH] mmc and fat bug fixes Ruud Commandeur
2013-05-15 15:37 ` Benoît Thébaudeau [this message]
2013-05-15 23:07 ` Tom Rini
2013-05-15 22:14 ` Andy Fleming
2013-05-16 9:26 ` Ruud Commandeur
2013-05-17 20:17 ` Andy Fleming
2013-05-16 5:55 ` Wolfgang Denk
2013-05-16 8:04 ` Ruud Commandeur
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=1808571307.844971.1368632224152.JavaMail.root@advansee.com \
--to=benoit.thebaudeau@advansee.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.